From 93f8d57dfa7acae2b2e7304703fd30e53e4ee324 Mon Sep 17 00:00:00 2001 From: Alex Rocha Date: Mon, 15 Jul 2024 13:24:38 -0500 Subject: [PATCH 1/6] add stack check and update pre-start script --- .../templates/pre-start.sh.erb | 7 ++++++ .../templates/stack_check.sh.erb | 24 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 jobs/cloud_controller_ng/templates/stack_check.sh.erb diff --git a/jobs/cloud_controller_ng/templates/pre-start.sh.erb b/jobs/cloud_controller_ng/templates/pre-start.sh.erb index 2473e0d564..fd44981472 100644 --- a/jobs/cloud_controller_ng/templates/pre-start.sh.erb +++ b/jobs/cloud_controller_ng/templates/pre-start.sh.erb @@ -121,6 +121,12 @@ function start_bosh_dns_or_consul { fi } +function stack_check() { + pushd "${CC_PACKAGE_DIR}/cloud_controller_ng" > /dev/null + chpst -u vcap:vcap "${SCRIPT_DIR}/stack_check" + popd > /dev/null +} + function start_consul_agent { # Start the consul agent so we can connect to a database url provided by consul dns if [ -f /var/vcap/jobs/consul_agent/bin/agent_ctl ]; then @@ -138,6 +144,7 @@ function main { <% if spec.bootstrap && p('cc.run_prestart_migrations') %> perform_migration seed_db + stack_check <% if p('cc.database_encryption.skip_validation') %> echo "Skipping DB encryption validation" <% else %> diff --git a/jobs/cloud_controller_ng/templates/stack_check.sh.erb b/jobs/cloud_controller_ng/templates/stack_check.sh.erb new file mode 100644 index 0000000000..4b96c9e93f --- /dev/null +++ b/jobs/cloud_controller_ng/templates/stack_check.sh.erb @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set +e +set -x + +CC_PACKAGE_DIR="/var/vcap/packages/cloud_controller_ng" +export BUNDLE_GEMFILE="${CC_PACKAGE_DIR}/cloud_controller_ng/Gemfile" +export STACKS_YML="/var/vcap/jobs/cloud_controller_ng/config/stacks.yml" +export NRCONFIG=/var/vcap/jobs/cloud_controller_ng/config/newrelic.yml + +function stack_check { + local result=1 + bundle exec rake do:stack_check + $result=$? + exit $result +} + +function main { + stack_check +} + +main + +exit 0 From d3357065e1c13ce1b8fcc54107193ba0106f08ae Mon Sep 17 00:00:00 2001 From: Alex Rocha Date: Fri, 19 Jul 2024 12:13:23 -0500 Subject: [PATCH 2/6] update namespace --- jobs/cloud_controller_ng/templates/pre-start.sh.erb | 2 +- jobs/cloud_controller_ng/templates/stack_check.sh.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jobs/cloud_controller_ng/templates/pre-start.sh.erb b/jobs/cloud_controller_ng/templates/pre-start.sh.erb index fd44981472..9e1c91a2a7 100644 --- a/jobs/cloud_controller_ng/templates/pre-start.sh.erb +++ b/jobs/cloud_controller_ng/templates/pre-start.sh.erb @@ -142,9 +142,9 @@ function main { start_bosh_dns_or_consul setup_directories <% if spec.bootstrap && p('cc.run_prestart_migrations') %> + stack_check perform_migration seed_db - stack_check <% if p('cc.database_encryption.skip_validation') %> echo "Skipping DB encryption validation" <% else %> diff --git a/jobs/cloud_controller_ng/templates/stack_check.sh.erb b/jobs/cloud_controller_ng/templates/stack_check.sh.erb index 4b96c9e93f..bd175c121f 100644 --- a/jobs/cloud_controller_ng/templates/stack_check.sh.erb +++ b/jobs/cloud_controller_ng/templates/stack_check.sh.erb @@ -10,7 +10,7 @@ export NRCONFIG=/var/vcap/jobs/cloud_controller_ng/config/newrelic.yml function stack_check { local result=1 - bundle exec rake do:stack_check + bundle exec rake stacks:stack_check $result=$? exit $result } From c5b8afdbe7852c12c02f424e316c00883cc4f891 Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Mon, 22 Jul 2024 22:04:44 +0000 Subject: [PATCH 3/6] Update spec to render stack_check job; exit correctly when job fails Co-authored-by: Alex Rocha --- jobs/cloud_controller_ng/spec | 6 ++++++ jobs/cloud_controller_ng/templates/stack_check.sh.erb | 4 +--- jobs/cloud_controller_ng/templates/stacks.yml.erb | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/jobs/cloud_controller_ng/spec b/jobs/cloud_controller_ng/spec index 90f3608f07..169a39de3a 100644 --- a/jobs/cloud_controller_ng/spec +++ b/jobs/cloud_controller_ng/spec @@ -55,6 +55,7 @@ templates: shutdown_drain.rb.erb: bin/shutdown_drain ruby_version.sh.erb: bin/ruby_version.sh seed_db.sh.erb: bin/seed_db + stack_check.sh.erb: bin/stack_check setup_local_blobstore.sh.erb: bin/setup_local_blobstore.sh stacks.yml.erb: config/stacks.yml uaa_ca.crt.erb: config/certs/uaa_ca.crt @@ -226,6 +227,7 @@ provides: - cc.experimental.use_puma_webserver - cc.experimental.use_redis - cc.app_log_revision + - cc.deprecated_stacks consumes: - name: database @@ -467,6 +469,10 @@ properties: cc.default_stack: default: "cflinuxfs4" description: "The default stack to use if no custom stack is specified for an app." + cc.deprecated_stacks: + description: | + List of deprecated/unsupported stack names. If a stack name is in this list, Cloud Controller bootstrap VM + will fail to start up if the stack is found in the database but is not explicitly listed in the stacks property. cc.staging_upload_user: description: "User name used to access internal endpoints of Cloud Controller to upload files when staging" diff --git a/jobs/cloud_controller_ng/templates/stack_check.sh.erb b/jobs/cloud_controller_ng/templates/stack_check.sh.erb index bd175c121f..008b86af10 100644 --- a/jobs/cloud_controller_ng/templates/stack_check.sh.erb +++ b/jobs/cloud_controller_ng/templates/stack_check.sh.erb @@ -9,10 +9,8 @@ export STACKS_YML="/var/vcap/jobs/cloud_controller_ng/config/stacks.yml" export NRCONFIG=/var/vcap/jobs/cloud_controller_ng/config/newrelic.yml function stack_check { - local result=1 bundle exec rake stacks:stack_check - $result=$? - exit $result + exit $? } function main { diff --git a/jobs/cloud_controller_ng/templates/stacks.yml.erb b/jobs/cloud_controller_ng/templates/stacks.yml.erb index 3a4bd0f371..b1da64d54c 100644 --- a/jobs/cloud_controller_ng/templates/stacks.yml.erb +++ b/jobs/cloud_controller_ng/templates/stacks.yml.erb @@ -1,2 +1,3 @@ default: <%= p("cc.default_stack") %> stacks: <%= p("cc.stacks", []).to_yaml.gsub("---", "") %> +deprecated_stacks: <%= p("cc.deprecated_stacks", []).to_yaml.gsub("---", "") %> From d997ce33e0b842145dffbdd18caf3caad7bac947 Mon Sep 17 00:00:00 2001 From: Alex Rocha Date: Fri, 26 Jul 2024 10:31:58 -0500 Subject: [PATCH 4/6] Update deprecated_stacks property description --- jobs/cloud_controller_ng/spec | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jobs/cloud_controller_ng/spec b/jobs/cloud_controller_ng/spec index 169a39de3a..7a0f052728 100644 --- a/jobs/cloud_controller_ng/spec +++ b/jobs/cloud_controller_ng/spec @@ -471,8 +471,9 @@ properties: description: "The default stack to use if no custom stack is specified for an app." cc.deprecated_stacks: description: | - List of deprecated/unsupported stack names. If a stack name is in this list, Cloud Controller bootstrap VM - will fail to start up if the stack is found in the database but is not explicitly listed in the stacks property. + List of deprecated/unsupported stack names. + If a stack in this list exists in the database, the Cloud Controller bootstrap VM + will fail to start. The only exception to this behavior occurs when the deprecated stack is explicitly listed in cc.stacks cc.staging_upload_user: description: "User name used to access internal endpoints of Cloud Controller to upload files when staging" From f03b9597a91cdc4add136ac77d637e07678662b8 Mon Sep 17 00:00:00 2001 From: Alex Rocha Date: Fri, 26 Jul 2024 10:35:03 -0500 Subject: [PATCH 5/6] Update deprecated_stacks property description & formatting --- jobs/cloud_controller_ng/spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jobs/cloud_controller_ng/spec b/jobs/cloud_controller_ng/spec index 7a0f052728..d7ca46a4a4 100644 --- a/jobs/cloud_controller_ng/spec +++ b/jobs/cloud_controller_ng/spec @@ -472,8 +472,8 @@ properties: cc.deprecated_stacks: description: | List of deprecated/unsupported stack names. - If a stack in this list exists in the database, the Cloud Controller bootstrap VM - will fail to start. The only exception to this behavior occurs when the deprecated stack is explicitly listed in cc.stacks + If a stack in this list exists in the database, the Cloud Controller bootstrap VM will fail to start. + The only exception to this behavior occurs when the deprecated stack is explicitly listed in cc.stacks. cc.staging_upload_user: description: "User name used to access internal endpoints of Cloud Controller to upload files when staging" From fc6233ebfb23766e29e1df6c7f01595c7a649049 Mon Sep 17 00:00:00 2001 From: Alex Rocha Date: Fri, 2 Aug 2024 10:07:38 -0500 Subject: [PATCH 6/6] fix indentation --- jobs/cloud_controller_ng/templates/stack_check.sh.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jobs/cloud_controller_ng/templates/stack_check.sh.erb b/jobs/cloud_controller_ng/templates/stack_check.sh.erb index 008b86af10..659a692f89 100644 --- a/jobs/cloud_controller_ng/templates/stack_check.sh.erb +++ b/jobs/cloud_controller_ng/templates/stack_check.sh.erb @@ -9,8 +9,8 @@ export STACKS_YML="/var/vcap/jobs/cloud_controller_ng/config/stacks.yml" export NRCONFIG=/var/vcap/jobs/cloud_controller_ng/config/newrelic.yml function stack_check { - bundle exec rake stacks:stack_check - exit $? + bundle exec rake stacks:stack_check + exit $? } function main {