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

BugFix: Bad Deployments Bandaid #1390

Merged
merged 4 commits into from
Oct 4, 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
2 changes: 1 addition & 1 deletion api/.pipeline/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -152,25 +153,27 @@ 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: {
// 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',
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) {
Expand Down
2 changes: 1 addition & 1 deletion app/.pipeline/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ 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',
cpuRequest: '50m',
cpuLimit: '1000m',
memoryRequest: '100Mi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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 {
Expand Down Expand Up @@ -68,16 +69,28 @@
pr: 2,
overflow: 'hidden'
}}>
<Checkbox
edge="start"
checked={isChecked}
sx={{ py: 0 }}
onClick={(event) => {
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 */}
<FeatureFlagGuard
featureFlags={['APP_FF_DISABLE_BAD_DEPLOYMENT_DELETE']}
fallback={
<Checkbox
edge="start"
checked={isChecked}
sx={{ py: 0, visibility: 'hidden' }}
inputProps={{ 'aria-label': 'controlled' }}
/>
}>
<Checkbox
edge="start"
checked={isChecked}
sx={{ py: 0 }}
onClick={(event) => {
event.stopPropagation();
handleCheckboxChange(data.data.sims_deployment_id);

Check warning on line 89 in app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx#L88-L89

Added lines #L88 - L89 were not covered by tests
}}
inputProps={{ 'aria-label': 'controlled' }}
/>
</FeatureFlagGuard>
<Box>
<Stack gap={1} direction="row">
<Typography
Expand All @@ -100,13 +113,16 @@
</Box>
</Stack>
</AccordionSummary>
<IconButton
sx={{ position: 'absolute', right: '24px' }}
edge="end"
onClick={() => handleDelete(data.data.sims_deployment_id as number)}
aria-label="deployment-settings">
<Icon path={mdiTrashCanOutline} size={1}></Icon>
</IconButton>
{/* TODO: This delete is commented out as a temporary bug fix to prevent deployment data from being deleted */}
<FeatureFlagGuard featureFlags={['APP_FF_DISABLE_BAD_DEPLOYMENT_DELETE']}>
<IconButton
sx={{ position: 'absolute', right: '24px' }}
edge="end"
onClick={() => handleDelete(data.data.sims_deployment_id as number)}

Check warning on line 121 in app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/features/surveys/telemetry/list/SurveyBadDeploymentListItem.tsx#L121

Added line #L121 was not covered by tests
aria-label="deployment-settings">
<Icon path={mdiTrashCanOutline} size={1}></Icon>
</IconButton>
</FeatureFlagGuard>
</Box>
<AccordionDetails sx={{ mt: 0, pt: 0 }}>
<List
Expand Down
16 changes: 12 additions & 4 deletions app/src/features/surveys/telemetry/list/SurveyDeploymentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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';
Expand Down Expand Up @@ -391,10 +392,11 @@

// 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]);

Check warning on line 399 in app/src/features/surveys/telemetry/list/SurveyDeploymentList.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/features/surveys/telemetry/list/SurveyDeploymentList.tsx#L399

Added line #L399 was not covered by tests
}}
inputProps={{ 'aria-label': 'controlled' }}
/>
Expand All @@ -408,6 +410,12 @@
sx={{
background: grey[100]
}}>
<AlertBar
severity="error"
text="We're fixing a bug preventing deployments from loading. Please check back later."
title="There's a Bug!"
variant="standard"
/>
{badDeployments.map((badDeployment) => {
return (
<SurveyBadDeploymentListItem
Expand Down