-
Notifications
You must be signed in to change notification settings - Fork 35
Release: Fix widget modal button initialization and other improvements #1925
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
Changes from 9 commits
2f0c4ae
decad73
446fc3c
2a919af
39a848c
f376cab
2b1fb3a
bbcb0ac
35b2d51
b07fa59
f6b5555
92d4e38
edc19e4
08faf20
d5a596b
c653d1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -63,7 +63,7 @@ release_deploy_lock() { | |||||
| # Wait for any in-progress deployments to complete before starting | ||||||
| wait_for_deployment() { | ||||||
| local app_name="$1" | ||||||
| local max_wait=600 # 10 minutes max | ||||||
| local max_wait=800 # 13 minutes and 20 seconds max | ||||||
| local wait_interval=15 | ||||||
| local waited=0 | ||||||
|
|
||||||
|
|
@@ -87,12 +87,87 @@ wait_for_deployment() { | |||||
| return 0 | ||||||
| } | ||||||
|
|
||||||
| # Run migrations as a CF task and wait for completion | ||||||
| run_migrations() { | ||||||
| local app_name="$1" | ||||||
| local max_wait=1800 # 30 minutes max for migrations | ||||||
| local wait_interval=10 | ||||||
| local waited=0 | ||||||
|
|
||||||
| echo "Running database migrations for $app_name..." | ||||||
|
|
||||||
| # Start migration task | ||||||
| local task_output=$(cf run-task "$app_name" --command "bundle exec rails db:migrate" --name "pre-deploy-migrations" 2>&1) | ||||||
| echo "$task_output" | ||||||
|
|
||||||
| # Extract task ID from output | ||||||
| local task_id=$(echo "$task_output" | grep -oE 'task id:[[:space:]]+[0-9]+' | grep -oE '[0-9]+' || echo "") | ||||||
|
|
||||||
| if [ -z "$task_id" ]; then | ||||||
| echo "Warning: Could not determine task ID, checking tasks list..." | ||||||
| sleep 5 | ||||||
| task_id=$(cf tasks "$app_name" | grep "pre-deploy-migrations" | grep "RUNNING" | head -1 | awk '{print $1}') | ||||||
| fi | ||||||
|
|
||||||
| if [ -z "$task_id" ]; then | ||||||
| echo "Error: Failed to start migration task" | ||||||
| return 1 | ||||||
| fi | ||||||
|
|
||||||
| echo "Migration task started with ID: $task_id" | ||||||
| echo "Waiting for migrations to complete..." | ||||||
|
|
||||||
| # Wait for task to complete | ||||||
| while [ $waited -lt $max_wait ]; do | ||||||
| local task_state=$(cf tasks "$app_name" | grep "^$task_id " | awk '{print $3}') | ||||||
|
|
||||||
| if [ "$task_state" == "SUCCEEDED" ]; then | ||||||
| echo "✓ Migrations completed successfully" | ||||||
| return 0 | ||||||
| elif [ "$task_state" == "FAILED" ]; then | ||||||
| echo "✗ Migration task failed. Checking logs..." | ||||||
| cf logs "$app_name" --recent | grep "pre-deploy-migrations" | tail -50 | ||||||
| return 1 | ||||||
| fi | ||||||
|
|
||||||
| if [ $((waited % 30)) -eq 0 ]; then | ||||||
| echo "Migration task still running (state: $task_state, waited ${waited}s)..." | ||||||
| fi | ||||||
|
|
||||||
| sleep $wait_interval | ||||||
| waited=$((waited + wait_interval)) | ||||||
| done | ||||||
|
|
||||||
| echo "Error: Migration task did not complete within ${max_wait}s" | ||||||
| cf logs "$app_name" --recent | grep "pre-deploy-migrations" | tail -50 | ||||||
| return 1 | ||||||
| } | ||||||
|
|
||||||
| # Retry function to handle staging and deployment conflicts | ||||||
| cf_push_with_retry() { | ||||||
| local app_name="$1" | ||||||
| local manifest_path="${2:-}" | ||||||
| local run_migrations="${3:-false}" | ||||||
| local max_retries=5 | ||||||
| local retry_delay=90 | ||||||
|
|
||||||
| # Run migrations first if requested | ||||||
| if [ "$run_migrations" == "true" ]; then | ||||||
| if ! run_migrations "$app_name"; then | ||||||
| echo "Error: Migrations failed, aborting deployment" | ||||||
| return 1 | ||||||
| fi | ||||||
| fi | ||||||
|
|
||||||
| # Ensure CircleCI-built Rust library is present | ||||||
| if [ -f "ext/widget_renderer/target/release/libwidget_renderer.so" ]; then | ||||||
| echo "CircleCI-built Rust library found, will be included in deployment" | ||||||
| file ext/widget_renderer/target/release/libwidget_renderer.so | ||||||
| readelf -n ext/widget_renderer/target/release/libwidget_renderer.so | grep "Build ID" || true | ||||||
| else | ||||||
| echo "WARNING: No CircleCI-built Rust library found at ext/widget_renderer/target/release/libwidget_renderer.so" | ||||||
| fi | ||||||
|
|
||||||
| # Acquire lock first | ||||||
| acquire_deploy_lock "$app_name" | ||||||
|
|
||||||
|
|
@@ -104,19 +179,30 @@ cf_push_with_retry() { | |||||
|
|
||||||
| for i in $(seq 1 $max_retries); do | ||||||
| echo "Attempt $i of $max_retries to push $app_name..." | ||||||
| if cf push "$app_name" --strategy rolling; then | ||||||
| local exit_code=0 | ||||||
|
|
||||||
| set +e | ||||||
| if [ -n "$manifest_path" ]; then | ||||||
| echo "Using manifest: $manifest_path" | ||||||
| cf push "$app_name" -f "$manifest_path" --strategy rolling -t 180 | ||||||
| else | ||||||
| cf push "$app_name" --strategy rolling -t 180 | ||||||
| fi | ||||||
| exit_code=$? | ||||||
| set -e | ||||||
|
|
||||||
| if [ $exit_code -eq 0 ]; then | ||||||
| echo "Successfully pushed $app_name" | ||||||
| release_deploy_lock "$app_name" | ||||||
| trap - EXIT # Clear the trap | ||||||
| return 0 | ||||||
| else | ||||||
| local exit_code=$? | ||||||
| if [ $i -lt $max_retries ]; then | ||||||
| echo "Push failed (exit code: $exit_code), waiting ${retry_delay}s before retry..." | ||||||
| sleep $retry_delay | ||||||
| # Re-check for in-progress deployments before retrying | ||||||
| wait_for_deployment "$app_name" | ||||||
| fi | ||||||
| fi | ||||||
|
|
||||||
| if [ $i -lt $max_retries ]; then | ||||||
| echo "Push failed (exit code: $exit_code), waiting ${retry_delay}s before retry..." | ||||||
| sleep $retry_delay | ||||||
| # Re-check for in-progress deployments before retrying | ||||||
| wait_for_deployment "$app_name" | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
|
|
@@ -132,7 +218,9 @@ then | |||||
| # Log into CF and push | ||||||
| cf login -a $CF_API_ENDPOINT -u $CF_PRODUCTION_SPACE_DEPLOYER_USERNAME -p $CF_PRODUCTION_SPACE_DEPLOYER_PASSWORD -o $CF_ORG -s prod | ||||||
| echo "PUSHING web servers to Production..." | ||||||
| cf_push_with_retry touchpoints | ||||||
| echo "Syncing Login.gov environment variables..." | ||||||
| ./.circleci/sync-login-gov-env.sh touchpoints | ||||||
| cf_push_with_retry touchpoints touchpoints.yml false | ||||||
|
||||||
| cf_push_with_retry touchpoints touchpoints.yml false | |
| cf_push_with_retry touchpoints touchpoints.yml true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| require_env() { | ||
| local var_name="$1" | ||
| if [ -z "${!var_name:-}" ]; then | ||
| echo "Missing required env var: ${var_name}" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| escape_private_key() { | ||
| ruby -e 'print STDIN.read.gsub("\r\n", "\n").gsub("\n", "\\n")' | ||
| } | ||
|
|
||
| sync_login_gov_env() { | ||
| local app_name="$1" | ||
|
|
||
| require_env LOGIN_GOV_CLIENT_ID | ||
| require_env LOGIN_GOV_IDP_BASE_URL | ||
| require_env LOGIN_GOV_REDIRECT_URI | ||
| require_env LOGIN_GOV_PRIVATE_KEY | ||
|
|
||
| local private_key_escaped | ||
| private_key_escaped="$(printf "%s" "${LOGIN_GOV_PRIVATE_KEY}" | escape_private_key)" | ||
|
|
||
| cf set-env "$app_name" LOGIN_GOV_CLIENT_ID "$LOGIN_GOV_CLIENT_ID" >/dev/null | ||
| cf set-env "$app_name" LOGIN_GOV_IDP_BASE_URL "$LOGIN_GOV_IDP_BASE_URL" >/dev/null | ||
| cf set-env "$app_name" LOGIN_GOV_REDIRECT_URI "$LOGIN_GOV_REDIRECT_URI" >/dev/null | ||
| cf set-env "$app_name" LOGIN_GOV_PRIVATE_KEY "$private_key_escaped" >/dev/null | ||
|
|
||
| echo "Synced Login.gov env to ${app_name}" | ||
| } | ||
|
|
||
| if [ "${1:-}" == "" ]; then | ||
| echo "Usage: $0 <app-name>" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| sync_login_gov_env "$1" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deploy script stops the Sidekiq app (line 126) before pushing, which causes downtime for background job processing. This means jobs will not be processed during the deployment window. For a worker process like Sidekiq, a better approach would be to allow the old instance to finish current jobs gracefully before replacing it, or ensure the deployment window is communicated to users.