Skip to content

Commit 3f97aa1

Browse files
DavidEdellDavid Linko
andauthored
Feature/tag based ghcr images (#300)
* Grafana updates including: Upgraded to v12, switched internal DB to PostgresSQL, consolidated dashboard+widget definitions and moved to a text provisioning file, and updated anms-ui monitor to use the new dashboard. Address #282 and #283 * Added to UI a prototype Help page and a Not Found page handler. * Resolve default database warning in grafana (hopefully). * Added upgrading file * Add amp-manager to UI Status page * added inifinity-datasource plugin and example panels * updated layout of panels * Fix core '/services' REST API to return JSON instead of text * Core REST API bugfixes to detect timeouts and resolve potential error with overloaded status variable. * initial dev creating a internal transcoder * working version, added new profile default is internal transcoding * working transcoder fixed issue with threading and DB * Automatically create GHCR images when a tag is created. This supplements the formal release process which also triggers publication. * Fix ghcr name if triggered by tag * Fixing grafana authnz/demo websocket proxy configuration. * removed services related to transcoder since they arent up by default * added --ignore flag for podman volume creaete to avoid name error * moved grafana db password to enviroment var * Updated build-test workflow to use SHA instead of user-friendly branch in internal (not pushed) docker tags to prevent errors with docker not overwriting local tags by default. * updated test to include new changes --------- Co-authored-by: David Linko <david.linko@jhuapl.edu>
1 parent de086b9 commit 3f97aa1

File tree

33 files changed

+1342
-220
lines changed

33 files changed

+1342
-220
lines changed

.env

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
COMPOSE_PROFILES=full,dev
88

99
# Port Services; Uncomment below lines to override default mappings
10-
#AUTHNZ_PORT=8084
11-
#AUTHNZ_HTTPS_PORT=8443
10+
AUTHNZ_PORT=8084
11+
AUTHNZ_HTTPS_PORT=8443
1212
#OPENSEARCH_PORT1=
1313
#OPENSEARCH_PORT2=
1414
#OPENSEARCH_DASH_PORT=
@@ -42,6 +42,8 @@ DB_HEALTHCHECK_PASSWORD=healthcheck
4242
GRAFANA_CONTAINER_PORT=3000
4343
GRAFANA_HOST_PORT=grafana:${GRAFANA_CONTAINER_PORT}
4444
GRAFANA_PROXIES_PATH=localhost/grafana
45+
GRAFANA_DB_NAME=grafana_internal_db
46+
4547
REDIS_PORT=6379
4648
JS_AMP_PORT=3001
4749
ANMS_UI_HTTP_PORT=9030
@@ -55,7 +57,7 @@ KIBANA_PORT=5601
5557
ADMINER_PORT=8080
5658
RENDERER_PORT=8081
5759
RENDERER_HOST_PORT=grafana-image-renderer:${RENDERER_PORT}
58-
ION_MGR_PORT=8089
60+
ION_MGR_PORT=9089
5961
HTTP_PORT=80
6062

6163
# Path (or volume name) on the host
@@ -64,3 +66,5 @@ HOST_SOCKDIR=sockdir
6466
CTR_SOCKDIR=/var/tmp/nm
6567

6668
ADM_PATH=deps/dtnma-adms
69+
70+
GRAFANA_PASS=grafana

.github/workflows/build-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
submodules: recursive
4141
- name: Tag name env
4242
run: |
43-
DOCKER_IMAGE_TAG=$(echo ${{ github.head_ref || github.ref_name }} | sed 's/[^a-zA-Z0-9\-\._]/-/g')
43+
DOCKER_IMAGE_TAG=${{ github.sha }}
4444
echo "DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}" >> $GITHUB_ENV
4545
- name: Build ANMS
4646
run: ${DOCKER_CMD} compose ${ANMS_COMPOSE_OPTS} build

.github/workflows/publish_images.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
push:
66
branches:
77
- main
8+
tags:
9+
- 'v*' # Triggers the workflow for any tag starting with 'v', e.g., v1.0.0
810
release:
911
types: [published]
1012

@@ -36,6 +38,8 @@ jobs:
3638
run: |
3739
if [[ "${{ github.event_name }}" == "release" ]]; then
3840
echo "DOCKER_IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
41+
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
42+
echo "DOCKER_IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
3943
else
4044
echo "DOCKER_IMAGE_TAG=latest" >> $GITHUB_ENV
4145
fi

UPGRADING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This file will contain upgrading instructions for all future tagged releases.
2+
3+
# Upgrading v2.0.0 to main
4+
5+
## Grafana DB Update
6+
A new database named `grafana_internal_db` needs to be created in postgres.
7+
8+
This can be done from the commandline or via the dev UI.
9+
10+
In the latter case, ensure your instance is started with the `dev` and `full` profiles. Go to Adminer (link provided in UI Help page) and either manually create the DB or 'Execute SQL' and upload the file `grafana/create_grafana_db.sql`
11+
12+
# Upgrading v1.x to v.2.0.0
13+
14+
It is recommended to start fresh (delete any existing ANMS-related containers and volumes) when transitioning from ANMS v1 to v2.
15+
16+
If you have data or customizations in a v1 installation that you need to migrate, please contact us or open an issue to discuss.
17+

anms-core/anms/config_template.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,6 @@ EMAIL_ENABLED: EMAIL_ENABLED_TEMPLATE
108108
EMAIL_FROM_NAME: EMAIL_FROM_NAME_TEMPLATE
109109
EMAIL_FROM_EMAIL: EMAIL_FROM_EMAIL_TEMPLATE
110110
EMAIL_TEMPLATES_DIR: EMAIL_TEMPLATES_DIR_TEMPLATE
111-
EMAIL_RESET_TOKEN_EXPIRE_LIFETIME: EMAIL_RESET_TOKEN_EXPIRE_LIFETIME_TEMPLATE
111+
EMAIL_RESET_TOKEN_EXPIRE_LIFETIME: EMAIL_RESET_TOKEN_EXPIRE_LIFETIME_TEMPLATE
112+
113+
Transcoder: TRANSCODER_TEMPLATE

anms-core/anms/init_adms.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from anms.routes.adms.adm import handle_adm
3232
from anms.shared.config_utils import ConfigBuilder
3333
from anms.shared.opensearch_logger import OpenSearchLogger
34+
from anms.shared.transmogrifier import TRANSMORGIFIER
3435

3536

3637
logger = OpenSearchLogger(__name__).logger
@@ -67,17 +68,10 @@ async def import_adms():
6768
logger.error('ADM %s handling failed: %s', adm_file.norm_name, err)
6869
logger.debug('%s', traceback.format_exc())
6970

71+
7072
# Notify the aricodec of startup
71-
config = ConfigBuilder.get_config()
72-
host = config.get('MQTT_HOST')
73-
port = config.get('MQTT_PORT')
74-
75-
logger.info('Connecting to MQTT broker %s to notify aricodec', host)
76-
client = mqtt.client.Client()
77-
client.connect(host, port)
78-
msg = client.publish('aricodec/reload', b'')
79-
msg.wait_for_publish()
80-
client.disconnect()
73+
TRANSMORGIFIER.reload()
74+
8175

8276
logger.info('Startup finished')
8377

anms-core/anms/routes/adms/adm.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,17 @@
2929
from pydantic import BaseModel
3030
import io
3131
import traceback
32-
from typing import TextIO
3332

3433
# Internal modules
35-
from sqlalchemy import delete, select, and_
36-
from sqlalchemy.engine import Result
37-
from sqlalchemy.ext.asyncio import AsyncSession
34+
from sqlalchemy import delete, and_
3835

3936
from anms.models.relational.adms import (adm_data, data_model_view)
40-
from anms.models.relational.adms.data_model_view import DataModel as ADM
4137

4238
from anms.routes.adms.adm_compare import (AdmCompare)
4339
from anms.shared.opensearch_logger import OpenSearchLogger
44-
from anms.shared.mqtt_client import MQTT_CLIENT
45-
from anms.models.relational import get_async_session, get_session
40+
41+
from anms.shared.transmogrifier import TRANSMORGIFIER
42+
from anms.models.relational import get_async_session
4643
from anms.components.schemas.adm import DataModelSchema
4744
import ace
4845
from camp.generators import (create_sql)
@@ -296,7 +293,7 @@ async def update_adm(file: UploadFile, request: Request):
296293
if error_message:
297294
raise Exception(error_message)
298295
# Notify the transcoder
299-
MQTT_CLIENT.publish('aricodec/reload', adm_file.norm_name)
296+
TRANSMORGIFIER.reload(adm_file.norm_name)
300297
logger.info(f"{info_message} adm file: {file.filename} successfully")
301298
except Exception as err:
302299
logger.error(f"{sql_dialect} execution error: {err.args}")

anms-core/anms/routes/network_manager.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@ def do_nm_put_hex_eid(eid: str, ari: str):
9191
logger.info('post to nm manager %s with eid %s and data %s' % (url, eid, ari))
9292

9393
try:
94-
request = requests.post(url=url, data=ari, headers={'Content-Type': 'text/plain'})
94+
request = requests.post(url=url,
95+
data=ari,
96+
headers={'Content-Type': 'text/plain'},
97+
timeout=(2.0, 8.0) # 2s for manager to connect, 8s for it to respond
98+
)
99+
except requests.exceptions.ConnectTimeout:
100+
return status.HTTP_504_GATEWAY_TIMEOUT
101+
except requests.exceptions.ReadTimeout:
102+
return status.HTTP_504_GATEWAY_TIMEOUT
103+
except requests.exceptions.Timeout:
104+
return status.HTTP_504_GATEWAY_TIMEOUT
95105
except Exception:
96106
return status.HTTP_500_INTERNAL_SERVER_ERROR
97107
return request.status_code

anms-core/anms/routes/system_status.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,5 @@ async def sys_status_get_version():
138138
async def sys_status_get_services_status():
139139
statuses = get_containers_status()
140140
logger.debug(f"Checking all services' status: {str(statuses)}")
141-
return json.dumps(statuses)
141+
return statuses
142+

0 commit comments

Comments
 (0)