Skip to content

Commit

Permalink
fix(monitored deploy): fix the rollback config to match what orca exp…
Browse files Browse the repository at this point in the history
…ects (#7532)

Note: `Manual` type is not yet implemented in orca, hence it's not used in deck, other then the enum definition
  • Loading branch information
marchello2000 committed Oct 17, 2019
1 parent 2b2100f commit 7e8cb7e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import {

export interface IMonitoredDeployCommand extends IServerGroupCommand {
delayBeforeScaleDownSec: string;
rollback: {
onFailure: boolean;
failureActions: {
destroyInstances: boolean;
rollback: string;
};
maxRemainingAsgs: number;
scaleDown: boolean;
Expand All @@ -25,6 +26,12 @@ export interface IMonitoredDeployCommand extends IServerGroupCommand {
};
}

export enum RollbackType {
None = 'None',
Automatic = 'Automatic',
Manual = 'Manual',
}

export interface IMonitoredDeployStrategyAdditionalFieldsProps extends IDeploymentStrategyAdditionalFieldsProps {
command: IMonitoredDeployCommand;
}
Expand Down Expand Up @@ -58,7 +65,16 @@ export class AdditionalFields extends React.Component<
};

private rollbackOnFailureChange = (e: React.ChangeEvent<HTMLInputElement>) => {
this.props.command.rollback.onFailure = e.target.checked;
this.props.command.failureActions.rollback = e.target.checked ? RollbackType.Automatic : RollbackType.None;

if (this.props.command.failureActions.rollback === RollbackType.None) {
this.props.command.failureActions.destroyInstances = false;
}
this.forceUpdate();
};

private destroyFailedAsgChange = (e: React.ChangeEvent<HTMLInputElement>) => {
this.props.command.failureActions.destroyInstances = e.target.checked;
this.forceUpdate();
};

Expand All @@ -80,7 +96,8 @@ export class AdditionalFields extends React.Component<
public render() {
const { NumberList } = NgReact;
const { command } = this.props;
const rollbackOnFailure = command.rollback && command.rollback.onFailure;
const rollbackOnFailure = command.failureActions && command.failureActions.rollback === RollbackType.Automatic;
const destroyFailedAsg = command.failureActions && command.failureActions.destroyInstances;

return (
<div className="form-group">
Expand Down Expand Up @@ -119,6 +136,17 @@ export class AdditionalFields extends React.Component<
Rollback to previous server group if deployment fails <HelpField id="strategy.monitored.rollback" />
</label>
</div>
<div className="col-md-12 checkbox" style={{ marginTop: 0 }}>
<label>
<input
type="checkbox"
checked={destroyFailedAsg}
disabled={!rollbackOnFailure}
onChange={this.destroyFailedAsgChange}
/>
Destroy the failed server group after rollback <HelpField id="strategy.monitored.destroyFailedAsg" />
</label>
</div>
<div className="col-md-12 checkbox">
<label>
<input type="checkbox" checked={command.scaleDown} onChange={this.scaleDownChange} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isEmpty, defaultsDeep } from 'lodash';
import { DeploymentStrategyRegistry } from 'core/deploymentStrategy/deploymentStrategy.registry';

import { AdditionalFields } from './AdditionalFields';
import { AdditionalFields, RollbackType } from './AdditionalFields';

DeploymentStrategyRegistry.registerStrategy({
label: 'Monitored Deploy',
Expand All @@ -12,7 +12,10 @@ DeploymentStrategyRegistry.registerStrategy({
AdditionalFieldsComponent: AdditionalFields,
initializationMethod: command => {
defaultsDeep(command, {
rollback: { onFailure: true },
failureActions: {
destroyInstances: false,
rollback: RollbackType.Automatic,
},
deploymentMonitor: { id: '' },
maxRemainingAsgs: 2,
});
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/modules/core/src/help/help.contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ const helpContents: { [key: string]: string } = {
'<p>Monitored Deploy will scale up the new server group as specified by these per cent steps. After each step, the health of the new server group will be evaluated by the specified deployment monitor.</p>',
'strategy.monitored.rollback':
'<p>If deploy fails, disable the new server group and ensure that the previous server group is active and restored to its original capacity.</p>',
'strategy.monitored.destroyFailedAsg':
'<p>If deploy fails and rollback succeeds destroys the server group that failed the deploy instead of just disabling it.</p>',
'loadBalancers.filter.serverGroups': `
<p>Displays all server groups configured to use the load balancer.</p>
<p>If the server group is configured to <em>not</em> add new instances to the load balancer, it will be grayed out.</p>`,
Expand Down

0 comments on commit 7e8cb7e

Please sign in to comment.