fix: fix old app version deploy wrt. compose files
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

See coop-cloud/organising#617
This commit is contained in:
decentral1se 2024-06-19 20:32:09 +02:00
parent 316fdd3643
commit 91ea2c01a5
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
3 changed files with 57 additions and 9 deletions

View File

@ -97,6 +97,19 @@ recipes.
logrus.Fatal(err) logrus.Fatal(err)
} }
// NOTE(d1): check out specific version before dealing with secrets. This
// is because we need to deal with GetComposeFiles under the hood and these
// files change from version to version which therefore affects which
// secrets might be generated
version := deployedVersion
if specificVersion != "" {
version = specificVersion
logrus.Debugf("choosing %s as version to deploy", version)
if err := recipe.EnsureVersion(app.Recipe, version); err != nil {
logrus.Fatal(err)
}
}
secStats, err := secret.PollSecretsStatus(cl, app) secStats, err := secret.PollSecretsStatus(cl, app)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
@ -116,15 +129,6 @@ recipes.
} }
} }
version := deployedVersion
if specificVersion != "" {
version = specificVersion
logrus.Debugf("choosing %s as version to deploy", version)
if err := recipe.EnsureVersion(app.Recipe, version); err != nil {
logrus.Fatal(err)
}
}
if !internal.Chaos && specificVersion == "" { if !internal.Chaos && specificVersion == "" {
catl, err := recipe.ReadRecipeCatalogue(internal.Offline) catl, err := recipe.ReadRecipeCatalogue(internal.Offline)
if err != nil { if err != nil {

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
setup_file(){ setup_file(){
load "$PWD/tests/integration/helpers/git"
load "$PWD/tests/integration/helpers/common" load "$PWD/tests/integration/helpers/common"
_common_setup _common_setup
_add_server _add_server
@ -362,6 +363,7 @@ teardown(){
_reset_app _reset_app
} }
# bats test_tags=slow
@test "recipe config comments not present in values" { @test "recipe config comments not present in values" {
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input
assert_success assert_success
@ -370,3 +372,36 @@ teardown(){
assert_success assert_success
refute_output --partial 'should be removed' refute_output --partial 'should be removed'
} }
# bats test_tags=slow
@test "deploy specific version with incompatible HEAD" {
run sed -i 's/COMPOSE_FILE="compose.yml"/COMPOSE_FILE="compose.yml:compose.extra_secret.yml"/g' \
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success
run sed -i 's/#SECRET_EXTRA_PASS_VERSION=v1/SECRET_EXTRA_PASS_VERSION=v1/g' \
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
assert_success
assert_output --partial 'extra_pass'
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/compose.extra_secret.yml"
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/compose.extra_secret.yml"
_git_commit
# NOTE(d1): 0.1.1+1.20.2 is a previous version which includes compose.extra_secret.yml
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks
assert_success
refute_output --partial 'no such file or directory'
_undeploy_app
_reset_app
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
assert_success
_reset_recipe
}

View File

@ -32,6 +32,7 @@ _reset_tags() {
_set_git_author() { _set_git_author() {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" config --local user.email test@example.com run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" config --local user.email test@example.com
assert_success assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" config --local user.name test run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" config --local user.name test
assert_success assert_success
} }
@ -43,3 +44,11 @@ _latest_tag() {
_latest_hash() { _latest_hash() {
export LATEST_HASH=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" log -1 --pretty=format:%h) export LATEST_HASH=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" log -1 --pretty=format:%h)
} }
_git_commit() {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" add .
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" commit -m "test: helpers/git.bash: _git_commit"
assert_success
}