From 229f31dee9c09bb8aa3bae15074d760f6f3f1053 Mon Sep 17 00:00:00 2001 From: Nick Phura Date: Fri, 4 Oct 2024 14:03:30 -0700 Subject: [PATCH 1/4] Fix missing commit in delete deployment endpoint. Wrap multiple deployments (bad deployment) in feature flag. --- .../survey/{surveyId}/deployments/delete.ts | 2 ++ .../survey/{surveyId}/deployments/index.ts | 36 ++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/delete.ts b/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/delete.ts index b03200296c..95f363c957 100644 --- a/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/delete.ts +++ b/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/delete.ts @@ -133,6 +133,8 @@ export function deleteDeploymentsInSurvey(): RequestHandler { await Promise.all(deletePromises); + await connection.commit(); + return res.status(200).send(); } catch (error) { defaultLog.error({ label: 'deleteDeploymentsInSurvey', message: 'error', error }); diff --git a/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/index.ts b/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/index.ts index afccc5b679..40518ddeab 100644 --- a/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/index.ts +++ b/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/index.ts @@ -9,6 +9,7 @@ import { authorizeRequestHandler } from '../../../../../../request-handlers/secu import { BctwDeploymentService } from '../../../../../../services/bctw-service/bctw-deployment-service'; import { ICritterbaseUser } from '../../../../../../services/critterbase-service'; import { DeploymentService } from '../../../../../../services/deployment-service'; +import { isFeatureFlagPresent } from '../../../../../../utils/feature-flag-utils'; import { getLogger } from '../../../../../../utils/logger'; const defaultLog = getLogger('paths/project/{projectId}/survey/{surveyId}/deployments/index'); @@ -152,25 +153,26 @@ export function getDeploymentsInSurvey(): RequestHandler { (deployment) => deployment.deployment_id === surveyDeployment.bctw_deployment_id ); - if (matchingBctwDeployments.length > 1) { - defaultLog.warn({ - label: 'getDeploymentById', - message: 'Multiple active deployments found for the same deployment ID, when only one should exist.', - sims_deployment_id: surveyDeployment.deployment_id, - bctw_deployment_id: surveyDeployment.bctw_deployment_id - }); - - badDeployments.push({ - name: 'BCTW Data Error', - message: 'Multiple active deployments found for the same deployment ID, when only one should exist.', - data: { + // If the feature flag exists: we allow multiple active deployments to exist for the same deployment ID. + if (!isFeatureFlagPresent(['API_FF_DISABLE_MULTIPLE_ACTIVE_DEPLOYMENTS'])) { + if (matchingBctwDeployments.length > 1) { + defaultLog.warn({ + label: 'getDeploymentById', + message: 'Multiple active deployments found for the same deployment ID, when only one should exist.', sims_deployment_id: surveyDeployment.deployment_id, bctw_deployment_id: surveyDeployment.bctw_deployment_id - } - }); - - // Don't continue processing this deployment - continue; + }); + badDeployments.push({ + name: 'BCTW Data Error', + message: 'Multiple active deployments found for the same deployment ID, when only one should exist.', + data: { + sims_deployment_id: surveyDeployment.deployment_id, + bctw_deployment_id: surveyDeployment.bctw_deployment_id + } + }); + // Don't continue processing this deployment + continue; + } } if (matchingBctwDeployments.length === 0) { From 2ef9a353987c6606c6bfbc03aaaf52454bcc8fed Mon Sep 17 00:00:00 2001 From: Macgregor Aubertin-Young Date: Fri, 4 Oct 2024 14:19:22 -0700 Subject: [PATCH 2/4] disable delete from bad deployments --- .../list/SurveyBadDeploymentListItem.tsx | 16 +++++++++++----- .../telemetry/list/SurveyDeploymentList.tsx | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx b/app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx index 6fd7adc17d..37c9ad61e0 100644 --- a/app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx +++ b/app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx @@ -71,11 +71,13 @@ export const SurveyBadDeploymentListItem = (props: ISurveyBadDeploymentListItemP { - event.stopPropagation(); - handleCheckboxChange(data.data.sims_deployment_id); - }} + // onClick={(event) => { + // event.stopPropagation(); + // handleCheckboxChange(data.data.sims_deployment_id); + // }} inputProps={{ 'aria-label': 'controlled' }} /> @@ -103,7 +105,11 @@ export const SurveyBadDeploymentListItem = (props: ISurveyBadDeploymentListItemP handleDelete(data.data.sims_deployment_id as number)} + // TODO: This delete is commented out as a temporary bug fix to prevent deployment data from being deleted + // onClick={ + // () => { + // handleDelete(data.data.sims_deployment_id as number)} + // } aria-label="deployment-settings"> diff --git a/app/src/features/surveys/telemetry/list/SurveyDeploymentList.tsx b/app/src/features/surveys/telemetry/list/SurveyDeploymentList.tsx index dc4b979405..0ab2c6003e 100644 --- a/app/src/features/surveys/telemetry/list/SurveyDeploymentList.tsx +++ b/app/src/features/surveys/telemetry/list/SurveyDeploymentList.tsx @@ -15,6 +15,7 @@ import Paper from '@mui/material/Paper'; import Stack from '@mui/material/Stack'; import Toolbar from '@mui/material/Toolbar'; import Typography from '@mui/material/Typography'; +import AlertBar from 'components/alert/AlertBar'; import { LoadingGuard } from 'components/loading/LoadingGuard'; import { SkeletonList } from 'components/loading/SkeletonLoaders'; import { SurveyBadDeploymentListItem } from 'features/surveys/telemetry/list/SurveyBadDeploymentListItem'; @@ -391,10 +392,11 @@ export const SurveyDeploymentList = (props: ISurveyDeploymentListProps) => { // Select all const deploymentIds = deployments.map((deployment) => deployment.deployment_id); - const badDeploymentIds = badDeployments.map( - (deployment) => deployment.data.sims_deployment_id - ); - setCheckboxSelectedIds([...badDeploymentIds, ...deploymentIds]); + // const badDeploymentIds = badDeployments.map( + // (deployment) => deployment.data.sims_deployment_id + // ); + // TODO: Temporary bug fix - prevent bad deployment ids from being selected and deleted + setCheckboxSelectedIds([...deploymentIds]); }} inputProps={{ 'aria-label': 'controlled' }} /> @@ -408,6 +410,12 @@ export const SurveyDeploymentList = (props: ISurveyDeploymentListProps) => { sx={{ background: grey[100] }}> + {badDeployments.map((badDeployment) => { return ( Date: Fri, 4 Oct 2024 14:56:13 -0700 Subject: [PATCH 3/4] Wrap bad deployment actions in feature flag --- .../survey/{surveyId}/deployments/index.ts | 5 +- app/.pipeline/config.js | 3 +- .../list/SurveyBadDeploymentListItem.tsx | 56 +++++++++++-------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/index.ts b/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/index.ts index 40518ddeab..89739a04ae 100644 --- a/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/index.ts +++ b/api/src/paths/project/{projectId}/survey/{surveyId}/deployments/index.ts @@ -153,8 +153,9 @@ export function getDeploymentsInSurvey(): RequestHandler { (deployment) => deployment.deployment_id === surveyDeployment.bctw_deployment_id ); - // If the feature flag exists: we allow multiple active deployments to exist for the same deployment ID. - if (!isFeatureFlagPresent(['API_FF_DISABLE_MULTIPLE_ACTIVE_DEPLOYMENTS'])) { + // TODO: If the feature flag exists, then we allow multiple active deployments to exist for the same deployment + // ID (when normally we would return a bad deployment). + if (!isFeatureFlagPresent(['API_FF_DISABLE_MULTIPLE_ACTIVE_DEPLOYMENTS_CHECK'])) { if (matchingBctwDeployments.length > 1) { defaultLog.warn({ label: 'getDeploymentById', diff --git a/app/.pipeline/config.js b/app/.pipeline/config.js index df25c0403c..4925793c7c 100644 --- a/app/.pipeline/config.js +++ b/app/.pipeline/config.js @@ -164,7 +164,8 @@ const phases = { maxUploadFileSize, nodeEnv: 'production', sso: config.sso.prod, - featureFlags: 'APP_FF_SUBMIT_BIOHUB', + featureFlags: + 'APP_FF_SUBMIT_BIOHUB,APP_FF_DISABLE_BAD_DEPLOYMENT_DELETE,API_FF_DISABLE_MULTIPLE_ACTIVE_DEPLOYMENTS_CHECK', cpuRequest: '50m', cpuLimit: '1000m', memoryRequest: '100Mi', diff --git a/app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx b/app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx index 37c9ad61e0..47b0f21dda 100644 --- a/app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx +++ b/app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx @@ -10,6 +10,7 @@ import IconButton from '@mui/material/IconButton'; import List from '@mui/material/List'; import Stack from '@mui/material/Stack'; import Typography from '@mui/material/Typography'; +import { FeatureFlagGuard } from 'components/security/Guards'; import { WarningSchema } from 'interfaces/useBioHubApi.interface'; export interface ISurveyBadDeploymentListItemProps { @@ -68,18 +69,28 @@ export const SurveyBadDeploymentListItem = (props: ISurveyBadDeploymentListItemP pr: 2, overflow: 'hidden' }}> - { - // event.stopPropagation(); - // handleCheckboxChange(data.data.sims_deployment_id); - // }} - inputProps={{ 'aria-label': 'controlled' }} - /> + {/* TODO: This delete is commented out as a temporary bug fix to prevent deployment data from being deleted */} + + }> + { + event.stopPropagation(); + handleCheckboxChange(data.data.sims_deployment_id); + }} + inputProps={{ 'aria-label': 'controlled' }} + /> + - { - // handleDelete(data.data.sims_deployment_id as number)} - // } - aria-label="deployment-settings"> - - + {/* TODO: This delete is commented out as a temporary bug fix to prevent deployment data from being deleted */} + + handleDelete(data.data.sims_deployment_id as number)} + aria-label="deployment-settings"> + + + Date: Fri, 4 Oct 2024 14:59:02 -0700 Subject: [PATCH 4/4] Fix pipeline config feature flags --- api/.pipeline/config.js | 2 +- app/.pipeline/config.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/api/.pipeline/config.js b/api/.pipeline/config.js index 7d6556d3f1..ac506c9645 100644 --- a/api/.pipeline/config.js +++ b/api/.pipeline/config.js @@ -218,7 +218,7 @@ const phases = { s3KeyPrefix: 'sims', tz: config.timezone.api, sso: config.sso.prod, - featureFlags: 'API_FF_SUBMIT_BIOHUB', + featureFlags: 'API_FF_SUBMIT_BIOHUB,API_FF_DISABLE_MULTIPLE_ACTIVE_DEPLOYMENTS_CHECK', logLevel: 'silent', logLevelFile: 'debug', logFileDir: 'data/logs', diff --git a/app/.pipeline/config.js b/app/.pipeline/config.js index 4925793c7c..9feb686da4 100644 --- a/app/.pipeline/config.js +++ b/app/.pipeline/config.js @@ -164,8 +164,7 @@ const phases = { maxUploadFileSize, nodeEnv: 'production', sso: config.sso.prod, - featureFlags: - 'APP_FF_SUBMIT_BIOHUB,APP_FF_DISABLE_BAD_DEPLOYMENT_DELETE,API_FF_DISABLE_MULTIPLE_ACTIVE_DEPLOYMENTS_CHECK', + featureFlags: 'APP_FF_SUBMIT_BIOHUB,APP_FF_DISABLE_BAD_DEPLOYMENT_DELETE', cpuRequest: '50m', cpuLimit: '1000m', memoryRequest: '100Mi',