Skip to content

Commit

Permalink
#128 Use local config for persistent state
Browse files Browse the repository at this point in the history
Move state that should be persistent between restarts to local config.
  • Loading branch information
jelemux committed Jun 4, 2024
1 parent 6c1f0d7 commit 42e4906
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- [#128] Move state that should be persistent between restarts to local config.

## [v5.0.8-1] - 2024-03-07
### Changed
Expand Down
1 change: 1 addition & 0 deletions docs/development/figures/post_upgrade_workflow.puml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ endif
:render templates and update plugins

:execute command: doguctl state "upgrade done";
:execute command: doguctl config --rm "local_state";

end

Expand Down
2 changes: 1 addition & 1 deletion docs/development/figures/pre_upgrade_workflow.puml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ endif
if (FROM_VERSION is equal to TO_VERSION) then (yes)
stop
else (no)
:execute command: doguctl state "upgrading";
:execute command: doguctl config "local_state" "upgrading";
endif

if (is FROM_VERSION less or equal than "4.2.3-4") then (no)
Expand Down
7 changes: 7 additions & 0 deletions dogu.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@
"Owner": "1000",
"Group": "1000",
"NeedsBackup": false
},
{
"Name": "localConfig",
"Path": "/var/ces/config",
"Owner": "1000",
"Group": "1000",
"NeedsBackup": true
}
],
"ServiceAccounts": [
Expand Down
1 change: 1 addition & 0 deletions resources/post-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function run_postupgrade() {

echo "Set registry flag so startup script can start afterwards..."
doguctl state "upgrade done"
doguctl config --rm "local_state"

echo "Redmine post-upgrade done"
}
Expand Down
2 changes: 1 addition & 1 deletion resources/pre-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function run_preupgrade() {
fi

echo "Set registry flag so startup script waits for post-upgrade to finish..."
doguctl state "upgrading"
doguctl config "local_state" "upgrading"

if versionXLessOrEqualThanY "${FROM_VERSION}" "4.2.3-4" ; then
# this migration only needs to be done if the additional plugins volume was already created
Expand Down
4 changes: 2 additions & 2 deletions resources/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sourceUtilExitCode=0
source "${STARTUP_DIR}"/util.sh || sourceUtilExitCode=$?
if [[ ${sourceUtilExitCode} -ne 0 ]]; then
echo "ERROR: An error occurred while sourcing util functions."
doguctl state "ErrorSourceUtilFunctions"
doguctl config "local_state" "ErrorSourceUtilFunctions"
sleep 300
exit 2
fi
Expand Down Expand Up @@ -63,7 +63,7 @@ function setDoguLogLevel() {

function runMain() {
# check whether post-upgrade script is still running
while [[ "$(doguctl state)" == "upgrading" ]]; do
while [[ "$(doguctl config "local_state" -d "empty")" == "upgrading" ]]; do
echo "Upgrade script is running. Waiting..."
sleep 3
done
Expand Down

0 comments on commit 42e4906

Please sign in to comment.