Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to check for deprecated stacks in pre-start rake task #444

Merged
merged 7 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions jobs/cloud_controller_ng/spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -226,6 +227,7 @@ provides:
- cc.experimental.use_puma_webserver
- cc.experimental.use_redis
- cc.app_log_revision
- cc.deprecated_stacks

consumes:
- name: database
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions jobs/cloud_controller_ng/templates/pre-start.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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') %>
Expand Down
22 changes: 22 additions & 0 deletions jobs/cloud_controller_ng/templates/stack_check.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set +e
Samze marked this conversation as resolved.
Show resolved Hide resolved
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
1 change: 1 addition & 0 deletions jobs/cloud_controller_ng/templates/stacks.yml.erb
Original file line number Diff line number Diff line change
@@ -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("---", "") %>