From b3c0b308382e94c4d75e1cd07dd024861c434742 Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Wed, 3 Jan 2024 21:24:44 -0500 Subject: [PATCH] ci: add disable daily DB refresh flag --- .github/workflows/build.yml | 7 ++++++- dev/deploy-to-container/cli.js | 12 +++++++++++- dev/deploy-to-container/refresh.js | 11 +++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b07e3b502..d950c057c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,11 @@ on: default: true required: true type: boolean + sandboxNoDbRefresh: + description: 'Sandbox Disable Daily DB Refresh' + default: false + required: true + type: boolean legacySandbox: description: 'Deploy to Legacy Sandbox' default: false @@ -325,7 +330,7 @@ jobs: npm ci cd ../.. echo "Start Deploy..." - node ./dev/deploy-to-container/cli.js --branch ${{ github.ref_name }} --domain dev.ietf.org --appversion ${{ env.PKG_VERSION }} --commit ${{ github.sha }} --ghrunid ${{ github.run_id }} + node ./dev/deploy-to-container/cli.js --branch ${{ github.ref_name }} --domain dev.ietf.org --appversion ${{ env.PKG_VERSION }} --commit ${{ github.sha }} --ghrunid ${{ github.run_id }} --nodbrefresh ${{ github.event.inputs.sandboxNoDbRefresh }} - name: Cleanup old docker resources env: diff --git a/dev/deploy-to-container/cli.js b/dev/deploy-to-container/cli.js index a22c746ae..3eecd6f75 100644 --- a/dev/deploy-to-container/cli.js +++ b/dev/deploy-to-container/cli.js @@ -175,6 +175,9 @@ async function main () { Image: 'ghcr.io/ietf-tools/datatracker-db:latest', name: `dt-db-${branch}`, Hostname: `dt-db-${branch}`, + Labels: { + ...argv.nodbrefresh ?? { nodbrefresh: '1' } + }, HostConfig: { NetworkMode: 'shared', RestartPolicy: { @@ -194,6 +197,9 @@ async function main () { Env: [ `CELERY_PASSWORD=${mqKey}` ], + Labels: { + ...argv.nodbrefresh ?? { nodbrefresh: '1' } + }, HostConfig: { Memory: 4 * (1024 ** 3), // in bytes NetworkMode: 'shared', @@ -222,6 +228,9 @@ async function main () { `CELERY_ROLE=${conConf.role}`, 'UPDATE_REQUIREMENTS_FROM=requirements.txt' ], + Labels: { + ...argv.nodbrefresh ?? { nodbrefresh: '1' } + }, HostConfig: { Binds: [ 'dt-assets:/assets', @@ -254,7 +263,8 @@ async function main () { appversion: `${argv.appversion}` ?? '0.0.0', commit: `${argv.commit}` ?? 'unknown', ghrunid: `${argv.ghrunid}` ?? '0', - hostname + hostname, + ...argv.nodbrefresh ?? { nodbrefresh: '1' } }, HostConfig: { Binds: [ diff --git a/dev/deploy-to-container/refresh.js b/dev/deploy-to-container/refresh.js index 827d85de6..7ea13c885 100644 --- a/dev/deploy-to-container/refresh.js +++ b/dev/deploy-to-container/refresh.js @@ -24,7 +24,8 @@ async function main () { const containersToRestart = [] for (const container of containers) { if ( - container.Names.some(n => n.startsWith('/dt-db-')) + container.Names.some(n => n.startsWith('/dt-db-')) && + container.Labels?.nodbrefresh !== '1' ) { console.info(`Terminating DB container ${container.Id}...`) dbContainersToCreate.push(container.Names.find(n => n.startsWith('/dt-db-')).substring(1)) @@ -37,9 +38,11 @@ async function main () { v: true }) } else if ( - container.Names.some(n => n.startsWith('/dt-app-')) || - container.Names.some(n => n.startsWith('/dt-celery-')) || - container.Names.some(n => n.startsWith('/dt-beat-')) + ( + container.Names.some(n => n.startsWith('/dt-app-')) || + container.Names.some(n => n.startsWith('/dt-celery-')) || + container.Names.some(n => n.startsWith('/dt-beat-')) + ) && container.Labels?.nodbrefresh !== '1' ) { if (container.State === 'running') { const appContainer = dock.getContainer(container.Id)