diff --git a/jobs/cloud_controller_ng/spec b/jobs/cloud_controller_ng/spec index 90f3608f07..d7ca46a4a4 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,11 @@ 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 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" diff --git a/jobs/cloud_controller_ng/templates/pre-start.sh.erb b/jobs/cloud_controller_ng/templates/pre-start.sh.erb index 2473e0d564..9e1c91a2a7 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 @@ -136,6 +142,7 @@ function main { start_bosh_dns_or_consul setup_directories <% if spec.bootstrap && p('cc.run_prestart_migrations') %> + stack_check perform_migration seed_db <% if p('cc.database_encryption.skip_validation') %> 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..659a692f89 --- /dev/null +++ b/jobs/cloud_controller_ng/templates/stack_check.sh.erb @@ -0,0 +1,22 @@ +#!/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 { + bundle exec rake stacks:stack_check + exit $? +} + +function main { + stack_check +} + +main + +exit 0 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("---", "") %>