import React, { useEffect, useState } from 'react'; import type { IAccount, IStageConfigProps } from '@spinnaker/core'; import { AccountRegionClusterSelector, AccountService, PlatformHealthOverride, Registry, SETTINGS, StageConfigField, } from '@spinnaker/core'; export function AwsRollbackClusterStageConfig(props: IStageConfigProps) { const { application, pipeline, stage, stageFieldUpdated, updateStageField } = props; const [accounts, setAccounts] = useState([]); useEffect(() => { const changes: Record = {}; if (stage.cloudProvider !== 'aws') { changes.cloudProvider = 'aws'; } if (!stage.credentials && application.defaultCredentials?.aws) { changes.credentials = application.defaultCredentials.aws; } if (!stage.targetHealthyRollbackPercentage) { changes.targetHealthyRollbackPercentage = 100; } if ( stage.isNew && application.attributes.platformHealthOnlyShowOverride && application.attributes.platformHealthOnly && stage.interestingHealthProviderNames === undefined ) { changes.interestingHealthProviderNames = ['Amazon']; } if (Object.keys(changes).length) { updateStageField(changes); } }, []); useEffect(() => { let active = true; AccountService.listAccounts('aws').then((loadedAccounts) => active && setAccounts(loadedAccounts)); return () => { active = false; }; }, []); return (
{!pipeline.strategy && ( )} {application.attributes.platformHealthOnlyShowOverride && ( updateStageField({ interestingHealthProviderNames })} platformHealthType="Amazon" /> )}
{(stage.regions || []).length > 1 && (
Wait{' '} updateStageField({ waitTimeBetweenRegions: Number(event.target.value) })} type="number" value={stage.waitTimeBetweenRegions ?? ''} />{' '} seconds between regional rollbacks.
)}
Consider rollback successful when{' '} updateStageField({ targetHealthyRollbackPercentage: Number(event.target.value) })} type="number" value={stage.targetHealthyRollbackPercentage ?? ''} />{' '} percent of instances are healthy.
{SETTINGS.feature.dynamicRollbackTimeout && (
Rollback Timeout is{' '} updateStageField({ rollbackTimeout: Number(event.target.value) })} type="number" value={stage.rollbackTimeout ?? ''} />{' '} minutes.
)}
); } export const awsRollbackClusterStage = { key: 'rollbackCluster', provides: 'rollbackCluster', cloudProvider: 'aws', component: AwsRollbackClusterStageConfig, validators: [ { type: 'requiredField', fieldName: 'cluster' }, { type: 'requiredField', fieldName: 'regions' }, { type: 'requiredField', fieldName: 'credentials', fieldLabel: 'account' }, ], }; export function registerAwsRollbackClusterStage() { Registry.pipeline.registerStage(awsRollbackClusterStage); } registerAwsRollbackClusterStage();