-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from jembi/PLAT-200-jsr-config-importing
PLAT-200 jsr config importing
- Loading branch information
Showing
10 changed files
with
161 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
dashboard-visualiser-jsreport/docker-compose.await-helper.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3.9' | ||
|
||
services: | ||
await-helper: | ||
image: jembi/await-helper:1.0.0 | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: none | ||
command: 'http://dashboard-visualiser-jsreport:5488/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
dashboard-visualiser-jsreport/importer/docker-compose.config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: '3.9' | ||
|
||
services: | ||
jsreport-config-importer: | ||
# TODO: Update image to use published version of jembi/config-importer | ||
image: jembi/api-config-importer:latest | ||
environment: | ||
SERVICE_NAME: 'dashboard-visualiser-jsreport' | ||
SERVICE_API_PORT: 5488 | ||
API_USERNAME: ${JS_REPORT_USERNAME:-admin} | ||
API_PASSWORD: ${JS_REPORT:-dev_password_only} | ||
SSL: ${JS_REPORT_SSL:-true} | ||
API_PATH: '/api/import' | ||
MIME_TYPE: 'multipart/form-data' | ||
CONFIG_FILE: ${JS_REPORT_CONFIG_FILE:-export.jsrexport} | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: none | ||
configs: | ||
- source: JSR-export.jsrexport | ||
target: /export.jsrexport | ||
|
||
configs: | ||
JSR-export.jsrexport: | ||
file: ./export.jsrexport | ||
name: JSR-export.jsrexport-${JSR_export_jsrexport_DIGEST:?err} | ||
labels: | ||
name: jsreport |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,85 @@ | ||
#!/bin/bash | ||
|
||
Action=$1 | ||
Mode=$2 | ||
|
||
STATEFUL_NODES=${STATEFUL_NODES:-"cluster"} | ||
|
||
ComposeFilePath=$( | ||
COMPOSE_FILE_PATH=$( | ||
cd "$(dirname "${BASH_SOURCE[0]}")" || exit | ||
pwd -P | ||
) | ||
|
||
if [[ "$2" == "dev" ]]; then | ||
ROOT_PATH="${COMPOSE_FILE_PATH}/.." | ||
. "${ROOT_PATH}/utils/config-utils.sh" | ||
|
||
if [[ "$Mode" == "dev" ]]; then | ||
printf "\nRunning JS Reports package in DEV mode\n" | ||
JsReportDevComposeParam="-c ${ComposeFilePath}/docker-compose.dev.yml" | ||
JsReportDevComposeParam="-c ${COMPOSE_FILE_PATH}/docker-compose.dev.yml" | ||
else | ||
printf "\nRunning JS Reports package in PROD mode\n" | ||
JsReportDevComposeParam="" | ||
fi | ||
|
||
if [[ "$1" == "init" ]]; then | ||
docker stack deploy -c "$ComposeFilePath"/docker-compose.yml $JsReportDevComposeParam instant | ||
elif [[ "$1" == "up" ]]; then | ||
docker stack deploy -c "$ComposeFilePath"/docker-compose.yml $JsReportDevComposeParam instant | ||
elif [[ "$1" == "down" ]]; then | ||
AwaitJsrRunning() { | ||
local startTime=$(date +%s) | ||
until [[ $(docker service ls -f name=instant_dashboard-visualiser-jsreport --format "{{.Replicas}}") == *"${JS_REPORT_INSTANCES}/${JS_REPORT_INSTANCES}"* ]]; do | ||
config::timeout_check $startTime "dashboard-visualiser-jsreport to start" | ||
sleep 1 | ||
done | ||
|
||
local awaitHelperState=$(docker service ps instant_await-helper --format "{{.CurrentState}}") | ||
until [[ $awaitHelperState == *"Complete"* ]]; do | ||
config::timeout_check $startTime "dashboard-visualiser-jsreport status check" | ||
sleep 1 | ||
|
||
awaitHelperState=$(docker service ps instant_await-helper --format "{{.CurrentState}}") | ||
if [[ $awaitHelperState == *"Failed"* ]] || [[ $awaitHelperState == *"Rejected"* ]]; then | ||
echo "Fatal: Received error when trying to verify state of dashboard-visualiser-jsreport. Error: | ||
$(docker service ps instant_await-helper --no-trunc --format \"{{.Error}}\")" | ||
exit 1 | ||
fi | ||
done | ||
|
||
docker service rm instant_await-helper | ||
} | ||
|
||
RemoveConfigImporter() { | ||
local complete="false" | ||
local startTime=$(date +%s) | ||
local configImporterState=$(docker service ps instant_jsreport-config-importer --format "{{.CurrentState}}") | ||
until [[ $configImporterState == *"Complete"* ]]; do | ||
config::timeout_check $startTime "jsreport-config-importer to run" | ||
sleep 1 | ||
|
||
configImporterState=$(docker service ps instant_jsreport-config-importer --format "{{.CurrentState}}") | ||
if [[ $configImporterState == *"Failed"* ]] || [[ $configImporterState == *"Rejected"* ]]; then | ||
echo "Fatal: JS Reports config importer failed with error: | ||
$(docker service ps instant_jsreport-config-importer --no-trunc --format \"{{.Error}}\")" | ||
exit 1 | ||
fi | ||
done | ||
|
||
docker service rm instant_jsreport-config-importer | ||
} | ||
|
||
if [[ "$Action" == "init" ]] || [[ "$Action" == "up" ]]; then | ||
docker stack deploy -c "$COMPOSE_FILE_PATH"/docker-compose.yml $JsReportDevComposeParam instant | ||
|
||
docker stack deploy -c "${COMPOSE_FILE_PATH}"/docker-compose.await-helper.yml instant | ||
|
||
echo "Verifying JS Reports service status" | ||
AwaitJsrRunning | ||
|
||
config::set_config_digests "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml | ||
docker stack deploy -c "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml instant | ||
|
||
RemoveConfigImporter | ||
config::remove_stale_service_configs "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml "jsreport" | ||
elif [[ "$Action" == "down" ]]; then | ||
docker service scale instant_dashboard-visualiser-jsreport=0 | ||
elif [[ "$1" == "destroy" ]]; then | ||
docker service rm instant_dashboard-visualiser-jsreport | ||
elif [[ "$Action" == "destroy" ]]; then | ||
docker service rm instant_dashboard-visualiser-jsreport instant_jsreport-config-importer instant_await-helper | ||
else | ||
echo "Valid options are: init, up, down, or destroy" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters