@spinnaker/amazon 0.8.7 → 0.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/domain/IAmazonServerGroup.d.ts +5 -3
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetMetricFields.d.ts +1 -1
  6. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingAdditionalSettings.d.ts +1 -0
  7. package/dist/serverGroup/details/scalingPolicy/targetTracking/UpsertTargetTrackingModal.d.ts +8 -0
  8. package/dist/serverGroup/details/scalingPolicy/upsert/ScalingPolicyAdditionalSettings.d.ts +1 -0
  9. package/dist/serverGroup/details/scalingPolicy/upsert/UpsertScalingPolicyModal.d.ts +8 -0
  10. package/dist/serverGroup/details/scalingPolicy/upsert/step/StepPolicyAction.d.ts +2 -3
  11. package/dist/serverGroup/details/sections/InstancesDistributionDetailsSection.d.ts +2 -0
  12. package/dist/serverGroup/details/sections/index.d.ts +1 -1
  13. package/package.json +3 -3
  14. package/src/aws.module.ts +2 -2
  15. package/src/domain/IAmazonServerGroup.ts +5 -3
  16. package/src/serverGroup/details/scalingPolicy/CreateScalingPolicyButton.tsx +17 -28
  17. package/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js +45 -49
  18. package/src/serverGroup/details/scalingPolicy/chart/MetricAlarmChart.tsx +3 -2
  19. package/src/serverGroup/details/scalingPolicy/targetTracking/TargetMetricFields.tsx +2 -2
  20. package/src/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingAdditionalSettings.less +11 -0
  21. package/src/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingAdditionalSettings.tsx +18 -16
  22. package/src/serverGroup/details/scalingPolicy/targetTracking/UpsertTargetTrackingModal.tsx +75 -0
  23. package/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts +10 -16
  24. package/src/serverGroup/details/scalingPolicy/upsert/ScalingPolicyAdditionalSettings.less +11 -0
  25. package/src/serverGroup/details/scalingPolicy/upsert/ScalingPolicyAdditionalSettings.tsx +9 -8
  26. package/src/serverGroup/details/scalingPolicy/upsert/UpsertScalingPolicyModal.tsx +211 -0
  27. package/src/serverGroup/details/scalingPolicy/upsert/alarm/AlarmConfigurer.tsx +17 -23
  28. package/src/serverGroup/details/scalingPolicy/upsert/alarm/DimensionsEditor.tsx +2 -2
  29. package/src/serverGroup/details/scalingPolicy/upsert/alarm/MetricSelector.tsx +2 -1
  30. package/src/serverGroup/details/scalingPolicy/upsert/step/StepPolicyAction.tsx +4 -4
  31. package/src/serverGroup/details/sections/{InstancesDiversificationDetailsSection.spec.tsx → InstancesDistributionDetailsSection.spec.tsx} +8 -8
  32. package/src/serverGroup/details/sections/{InstancesDiversificationDetailsSection.tsx → InstancesDistributionDetailsSection.tsx} +10 -10
  33. package/src/serverGroup/details/sections/LaunchTemplateDetailsSection.spec.tsx +1 -1
  34. package/src/serverGroup/details/sections/LaunchTemplateDetailsSection.tsx +1 -1
  35. package/src/serverGroup/details/sections/MultipleInstanceTypesSubSection.tsx +1 -1
  36. package/src/serverGroup/details/sections/index.ts +1 -1
  37. package/dist/serverGroup/details/scalingPolicy/targetTracking/upsertTargetTracking.controller.d.ts +0 -41
  38. package/dist/serverGroup/details/scalingPolicy/upsert/alarm/alarmConfigurer.component.d.ts +0 -2
  39. package/dist/serverGroup/details/scalingPolicy/upsert/alarm/dimensionsEditor.component.d.ts +0 -2
  40. package/dist/serverGroup/details/scalingPolicy/upsert/simple/simplePolicyAction.component.d.ts +0 -2
  41. package/dist/serverGroup/details/scalingPolicy/upsert/upsertScalingPolicy.controller.d.ts +0 -2
  42. package/dist/serverGroup/details/sections/InstancesDiversificationDetailsSection.d.ts +0 -2
  43. package/src/serverGroup/details/scalingPolicy/targetTracking/upsertTargetTracking.controller.ts +0 -129
  44. package/src/serverGroup/details/scalingPolicy/targetTracking/upsertTargetTracking.modal.html +0 -94
  45. package/src/serverGroup/details/scalingPolicy/upsert/simple/simplePolicyAction.component.js +0 -20
  46. package/src/serverGroup/details/scalingPolicy/upsert/upsertScalingPolicy.controller.js +0 -248
  47. package/src/serverGroup/details/scalingPolicy/upsert/upsertScalingPolicy.modal.html +0 -74
  48. package/src/serverGroup/details/scalingPolicy/upsert/upsertScalingPolicy.modal.less +0 -32
@@ -6,6 +6,7 @@ import { react2angular } from 'react2angular';
6
6
  import { HelpField, NumberInput, withErrorBoundary } from '@spinnaker/core';
7
7
 
8
8
  import { IUpsertScalingPolicyCommand } from '../ScalingPolicyWriter';
9
+ import './ScalingPolicyAdditionalSettings.less';
9
10
 
10
11
  export interface IScalingPolicyAdditionalSettingsProps {
11
12
  command: IUpsertScalingPolicyCommand;
@@ -31,13 +32,13 @@ export const ScalingPolicyAdditionalSettings = ({
31
32
  };
32
33
 
33
34
  return (
34
- <div>
35
+ <div className="ScalingPolicyAdditionalSettings">
35
36
  <h4 className="section-heading">Additional Settings</h4>
36
37
  <div className="section-body section-additional-settings">
37
38
  {!isNew && (
38
39
  <div className="row">
39
40
  <div className="col-md-2 sm-label-right">Policy Name</div>
40
- <div className="col-md-10 content-fields">
41
+ <div className="col-md-10 horizontal middle">
41
42
  <span className="form-control-static select-placeholder">{commandView.name}</span>
42
43
  </div>
43
44
  </div>
@@ -45,14 +46,14 @@ export const ScalingPolicyAdditionalSettings = ({
45
46
  {!isInstanceType && (
46
47
  <div className="row">
47
48
  <div className="col-md-2 sm-label-right">Adjustment Step</div>
48
- <div className="col-md-10 content-fields">
49
+ <div className="col-md-10 horizontal middle">
49
50
  <span className="form-control-static select-placeholder">
50
- {`${operator} instannces in increments of at least `}
51
+ {`${operator} instances in increments of at least `}
51
52
  </span>
52
53
  <NumberInput
53
54
  value={commandView.minAdjustmentMagnitude}
54
55
  onChange={(e) => setCommandField('minAdjustmentMagnitude', Number.parseInt(e.target.value))}
55
- inputClassName="sp-margin-xs-right input-sm number-input-sm"
56
+ inputClassName="sp-margin-xs-xaxis input-sm number-input-sm"
56
57
  />
57
58
  <span className="input-label"> instance(s) </span>
58
59
  </div>
@@ -61,7 +62,7 @@ export const ScalingPolicyAdditionalSettings = ({
61
62
  {Boolean(commandView.simple) && (
62
63
  <div className="row">
63
64
  <div className="col-md-2 sm-label-right">Cooldown</div>
64
- <div className="col-md-10 content-fields">
65
+ <div className="col-md-10 horizontal middle">
65
66
  <span className="form-control-static select-placeholder"> Wait at least </span>
66
67
  <NumberInput
67
68
  value={commandView.simple?.cooldown}
@@ -75,7 +76,7 @@ export const ScalingPolicyAdditionalSettings = ({
75
76
  {Boolean(commandView.step?.estimatedInstanceWarmup) && operator !== 'Remove' && (
76
77
  <div className="row">
77
78
  <div className="col-md-2 sm-label-right">Warmup</div>
78
- <div className="col-md-10 content-fields">
79
+ <div className="col-md-10 horizontal middle">
79
80
  <span className="form-control-static select-placeholder">Instances need</span>
80
81
  <NumberInput
81
82
  value={commandView.step.estimatedInstanceWarmup}
@@ -92,7 +93,7 @@ export const ScalingPolicyAdditionalSettings = ({
92
93
  <span className="sp-margin-xs-right">Cooldown</span>
93
94
  <HelpField id={`${commandView.cloudProvider || commandView.provider}.autoscaling.cooldown`} />
94
95
  </div>
95
- <div className="col-md-10 content-fields">
96
+ <div className="col-md-10 horizontal middle">
96
97
  <NumberInput
97
98
  value={commandView.step?.cooldown}
98
99
  onChange={(e) => setCommandField('step.cooldown', Number.parseInt(e.target.value))}
@@ -0,0 +1,211 @@
1
+ import { cloneDeep } from 'lodash';
2
+ import * as React from 'react';
3
+
4
+ import { Application, IModalComponentProps, TaskMonitorModal } from '@spinnaker/core';
5
+
6
+ import { ScalingPolicyAdditionalSettings } from './ScalingPolicyAdditionalSettings';
7
+ import { ScalingPolicyCommandBuilder } from './ScalingPolicyCommandBuilderService';
8
+ import { IStepPolicyDescription, IUpsertScalingPolicyCommand } from '../ScalingPolicyWriter';
9
+ import { AlarmConfigurer } from './alarm/AlarmConfigurer';
10
+ import { IAmazonServerGroup, IScalingPolicy, IStepAdjustment, ITargetTrackingPolicy } from '../../../../domain';
11
+ import { SimplePolicyAction } from './simple/SimplePolicyAction';
12
+ import { AdjustmentTypeView, Operator, StepPolicyAction } from './step/StepPolicyAction';
13
+
14
+ export interface IUpsertScalingPolicyModalProps extends IModalComponentProps {
15
+ app: Application;
16
+ policy: IScalingPolicy;
17
+ serverGroup: IAmazonServerGroup;
18
+ }
19
+
20
+ export const UpsertScalingPolicyModal = ({
21
+ app,
22
+ closeModal,
23
+ dismissModal,
24
+ policy,
25
+ serverGroup,
26
+ }: IUpsertScalingPolicyModalProps) => {
27
+ const modalProps = { closeModal, dismissModal };
28
+ const [command, setCommand] = React.useState<IUpsertScalingPolicyCommand>({} as IUpsertScalingPolicyCommand);
29
+ React.useEffect(() => {
30
+ const baseCommand = ScalingPolicyCommandBuilder.buildNewCommand(
31
+ 'Step',
32
+ serverGroup,
33
+ policy as ITargetTrackingPolicy,
34
+ );
35
+ setCommand(baseCommand);
36
+ }, []);
37
+
38
+ const adjustmentBasis = policy.stepAdjustments?.length
39
+ ? policy.stepAdjustments[0].scalingAdjustment
40
+ : policy.scalingAdjustment;
41
+ const [action, setAction] = React.useState<Operator>(
42
+ command.adjustmentType === 'ExactCapacity' ? 'Set to' : adjustmentBasis > 0 ? 'Add' : 'Remove',
43
+ );
44
+ const adjustmentTypeView =
45
+ command.adjustmentType === 'ExactCapacity' || command.adjustmentType === 'ChangeInCapacity'
46
+ ? 'instances'
47
+ : 'percent of group';
48
+
49
+ const isStep = command.step;
50
+ const mode = !policy.policyARN ? 'Create' : 'Edit';
51
+ const comparatorBound = command?.alarm?.comparisonOperator?.indexOf('Greater') === 0 ? 'max' : 'min';
52
+
53
+ const boundsChanged = (step: IStepPolicyDescription) => {
54
+ const source = comparatorBound === 'min' ? 'metricIntervalLowerBound' : 'metricIntervalUpperBound';
55
+ const target = source === 'metricIntervalLowerBound' ? 'metricIntervalUpperBound' : 'metricIntervalLowerBound';
56
+
57
+ const adjustments = step.stepAdjustments;
58
+ (adjustments || []).forEach((a, index) => {
59
+ if (adjustments.length > index + 1) {
60
+ adjustments[index + 1][target] = a[source];
61
+ }
62
+ });
63
+ // Remove the source boundary from the last step
64
+ delete adjustments[adjustments.length - 1][source];
65
+ };
66
+
67
+ const scalingAdjustmentChanged = (adjustment: number) => {
68
+ const newCommand = cloneDeep(command);
69
+ newCommand.simplescalingAdjustment = adjustment;
70
+ setCommand(newCommand);
71
+ };
72
+
73
+ const stepsChanged = (newSteps: IStepAdjustment[]) => {
74
+ const newCommand = cloneDeep(command);
75
+ newCommand.step.stepAdjustments = newSteps;
76
+ boundsChanged(newCommand.step);
77
+ setCommand(newCommand);
78
+ };
79
+
80
+ const adjustmentTypeChanged = (action: Operator, type: AdjustmentTypeView) => {
81
+ setAction(action);
82
+
83
+ const newType =
84
+ type !== 'instances' ? 'PercentChangeInCapacity' : action === 'Set to' ? 'ExactCapacity' : 'ChangeInCapacity';
85
+ setCommand({
86
+ ...command,
87
+ adjustmentType: newType,
88
+ });
89
+ };
90
+
91
+ const toggleMode = () => {
92
+ const updatedCommand = cloneDeep(command);
93
+ const cooldownOrWarmup = command.step ? command.step.estimatedInstanceWarmup : command.simple.cooldown;
94
+
95
+ if (command.step) {
96
+ delete updatedCommand.step;
97
+ updatedCommand.simple = ScalingPolicyCommandBuilder.buildSimplePolicy({
98
+ cooldown: cooldownOrWarmup,
99
+ } as IScalingPolicy);
100
+ } else {
101
+ const stepAdjustments = [
102
+ {
103
+ scalingAdjustment: command.simple.scalingAdjustment,
104
+ },
105
+ ] as IStepAdjustment[];
106
+ if (comparatorBound === 'min') {
107
+ stepAdjustments[0].metricIntervalUpperBound = 0;
108
+ } else {
109
+ stepAdjustments[0].metricIntervalLowerBound = 0;
110
+ }
111
+ const stepPolicy = {
112
+ estimatedInstanceWarmup: cooldownOrWarmup,
113
+ stepAdjustments: stepAdjustments,
114
+ };
115
+ delete updatedCommand.simple;
116
+ updatedCommand.step = ScalingPolicyCommandBuilder.buildStepPolicy(
117
+ stepPolicy as IScalingPolicy,
118
+ updatedCommand.alarm.threshold,
119
+ cooldownOrWarmup,
120
+ );
121
+
122
+ boundsChanged(updatedCommand.step);
123
+ }
124
+
125
+ setCommand(updatedCommand);
126
+ };
127
+
128
+ return (
129
+ <TaskMonitorModal<IUpsertScalingPolicyCommand>
130
+ {...modalProps}
131
+ title={`${mode} scaling policy`}
132
+ application={app}
133
+ description={`${mode} scaling policy for ${serverGroup.name}`}
134
+ initialValues={command}
135
+ mapValuesToTask={() => {
136
+ const preppedValues = ScalingPolicyCommandBuilder.prepareCommandForUpsert(command, action === 'Remove');
137
+ return {
138
+ application: app,
139
+ job: [
140
+ {
141
+ type: preppedValues.type || 'upsertScalingPolicy',
142
+ ...preppedValues,
143
+ },
144
+ ],
145
+ };
146
+ }}
147
+ render={() => (
148
+ <div>
149
+ <h4 className="section-heading">Conditions</h4>
150
+ <div className="section-body">
151
+ <AlarmConfigurer
152
+ alarm={command.alarm}
153
+ multipleAlarms={Boolean(policy?.alarms?.length > 1)}
154
+ serverGroup={serverGroup}
155
+ stepAdjustments={command.step.stepAdjustments}
156
+ stepsChanged={stepsChanged}
157
+ updateAlarm={(alarm) => setCommand({ ...command, alarm } as IUpsertScalingPolicyCommand)}
158
+ />
159
+ </div>
160
+ <h4 className="section-heading">Actions</h4>
161
+ <div className="section-body">
162
+ {!command.alarm?.metricName && <h4 className="text-center">Select a metric</h4>}
163
+ {command.alarm?.metricName && !isStep && (
164
+ <div>
165
+ <div className="row">
166
+ <div className="col-md-10 col-md-offset-1">
167
+ <p>
168
+ This is a simple scaling policy. To declare different actions based on the magnitude of the alarm,
169
+ <b>
170
+ switch to a
171
+ <a className="clickable sp-margin-xs-l" onClick={toggleMode}>
172
+ step policy
173
+ </a>
174
+ .
175
+ </b>
176
+ </p>
177
+ </div>
178
+ </div>
179
+ <SimplePolicyAction
180
+ adjustmentType={adjustmentTypeView}
181
+ adjustmentTypeChanged={adjustmentTypeChanged}
182
+ operator={action}
183
+ scalingAdjustment={command.simple?.scalingAdjustment}
184
+ updateScalingAdjustment={scalingAdjustmentChanged}
185
+ />
186
+ </div>
187
+ )}
188
+ {command.alarm?.metricName && isStep && (
189
+ <StepPolicyAction
190
+ adjustmentType={adjustmentTypeView}
191
+ adjustmentTypeChanged={adjustmentTypeChanged}
192
+ alarm={command.alarm}
193
+ isMin={comparatorBound === 'min'}
194
+ operator={action}
195
+ step={command.step}
196
+ stepsChanged={stepsChanged}
197
+ />
198
+ )}
199
+ </div>
200
+ <ScalingPolicyAdditionalSettings
201
+ command={command}
202
+ isInstanceType={adjustmentTypeView === 'instances'}
203
+ isNew={Boolean(!policy.policyARN)}
204
+ operator={action}
205
+ updateCommand={setCommand}
206
+ />
207
+ </div>
208
+ )}
209
+ />
210
+ );
211
+ };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
 
3
- import { ICloudMetricStatistics, NumberInput, ReactSelectInput } from '@spinnaker/core';
3
+ import { ICloudMetricStatistics, NumberInput, ReactSelectInput, usePrevious } from '@spinnaker/core';
4
4
 
5
5
  import { MetricSelector } from './MetricSelector';
6
6
  import { MetricAlarmChart } from '../../chart/MetricAlarmChart';
@@ -46,9 +46,10 @@ export const AlarmConfigurer = ({
46
46
  const comparatorBound = alarm.comparisonOperator?.indexOf('Greater') === 0 ? 'max' : 'min';
47
47
  const [alarmView, setAlarmView] = React.useState<IScalingPolicyAlarm>(alarm);
48
48
  const [unit, setUnit] = React.useState<string>(alarmView?.unit);
49
+ const prevComparator = usePrevious(comparatorBound);
49
50
 
50
51
  React.useEffect(() => {
51
- if (stepAdjustments) {
52
+ if (stepAdjustments && prevComparator !== undefined) {
52
53
  const source = comparatorBound === 'max' ? 'metricIntervalLowerBound' : 'metricIntervalUpperBound';
53
54
  const newStep: IStepAdjustment = {
54
55
  scalingAdjustment: 1,
@@ -58,6 +59,16 @@ export const AlarmConfigurer = ({
58
59
  }
59
60
  }, [comparatorBound]);
60
61
 
62
+ React.useEffect(() => {
63
+ const source = comparatorBound === 'max' ? 'metricIntervalLowerBound' : 'metricIntervalUpperBound';
64
+ if (stepAdjustments?.length) {
65
+ const updatedStepAdjustments = [...stepAdjustments];
66
+ // Always set the first step at the alarm threshold
67
+ updatedStepAdjustments[0][source] = alarmView.threshold;
68
+ stepsChanged(updatedStepAdjustments);
69
+ }
70
+ }, [alarmView.threshold]);
71
+
61
72
  const onChartLoaded = (stats: ICloudMetricStatistics) => setUnit(stats.unit);
62
73
 
63
74
  const onAlarmChange = (key: string, value: any) => {
@@ -69,23 +80,6 @@ export const AlarmConfigurer = ({
69
80
  updateAlarm(newAlarm);
70
81
  };
71
82
 
72
- const onThresholdChange = (bound: number) => {
73
- const newAlarm = {
74
- ...alarmView,
75
- threshold: bound,
76
- };
77
- setAlarmView(newAlarm);
78
- updateAlarm(newAlarm);
79
-
80
- const source = comparatorBound === 'max' ? 'metricIntervalLowerBound' : 'metricIntervalUpperBound';
81
- if (stepAdjustments?.length) {
82
- const updatedStepAdjustments = [...stepAdjustments];
83
- // Always set the first step at the alarm threshold
84
- updatedStepAdjustments[0][source] = bound;
85
- stepsChanged(updatedStepAdjustments);
86
- }
87
- };
88
-
89
83
  const onMetricChange = (newAlarm: IScalingPolicyAlarm) => {
90
84
  setAlarmView(newAlarm);
91
85
  updateAlarm(newAlarm);
@@ -120,7 +114,7 @@ export const AlarmConfigurer = ({
120
114
  )}
121
115
  <div className="row sp-margin-s-yaxis">
122
116
  <div className="col-md-2 sm-label-right">Whenever</div>
123
- <div className="col-md-10 horizontal middle">
117
+ <div className="col-md-10 horizontal">
124
118
  <ReactSelectInput
125
119
  value={alarmView.statistic}
126
120
  onChange={(e) => onAlarmChange('statistic', e.target.value)}
@@ -128,7 +122,7 @@ export const AlarmConfigurer = ({
128
122
  clearable={false}
129
123
  inputClassName="sp-margin-xs-right configurer-field-lg"
130
124
  />
131
- <span className="input-label sp-margin-xs-right"> of </span>
125
+ <span className="input-label sp-margin-xs-right sp-margin-s-top"> of </span>
132
126
  <MetricSelector alarm={alarmView} serverGroup={serverGroup} updateAlarm={onMetricChange} />
133
127
  </div>
134
128
  </div>
@@ -145,7 +139,7 @@ export const AlarmConfigurer = ({
145
139
  <div className="sp-margin-xl-left">
146
140
  <NumberInput
147
141
  value={alarmView.threshold}
148
- onChange={(e) => onThresholdChange(Number.parseInt(e.target.value))}
142
+ onChange={(e) => onAlarmChange('threshold', Number.parseInt(e.target.value))}
149
143
  inputClassName="sp-margin-xs-right configurer-field-lg"
150
144
  />
151
145
  </div>
@@ -170,7 +164,7 @@ export const AlarmConfigurer = ({
170
164
  />
171
165
  </div>
172
166
  </div>
173
- <div className="row sp-margin-s-yaxis" ng-if="$ctrl.alarm.metricName">
167
+ <div className="row sp-margin-s-yaxis">
174
168
  <div className="col-md-10 col-md-offset-1">
175
169
  {alarm && (
176
170
  <div>
@@ -82,8 +82,8 @@ export const DimensionsEditor = ({ alarm, serverGroup, updateAvailableMetrics }:
82
82
  ))}
83
83
  {!alarm.disableEditingDimensions && (
84
84
  <div className="row">
85
- <div className="col-md-10">
86
- <button className="btn btn-block btn-xs add-new" onClick={addDimension}>
85
+ <div>
86
+ <button type="button" className="btn btn-block btn-xs add-new" onClick={addDimension}>
87
87
  <span className="glyphicon glyphicon-plus-sign sp-margin-xs-left"></span>
88
88
  Add dimension
89
89
  </button>
@@ -53,7 +53,8 @@ export const MetricSelector = ({ alarm, updateAlarm, serverGroup }: IMetricSelec
53
53
  const dimensionValuesStr = buildDimensionValues(alarm?.dimensions || []);
54
54
 
55
55
  const fetchCloudMetrics = () => {
56
- return CloudMetricsReader.listMetrics('aws', serverGroup.account, serverGroup.region, dimensionsObject).then(
56
+ const account = serverGroup.cloudProvider === 'aws' ? serverGroup.account : serverGroup?.awsAccount;
57
+ return CloudMetricsReader.listMetrics('aws', account, serverGroup.region, dimensionsObject).then(
57
58
  (metrics: ICloudMetricDescriptor[]) => {
58
59
  const sortedMetrics: IMetricOption[] = metrics
59
60
  .map((m) => ({
@@ -6,8 +6,8 @@ import { IScalingPolicyAlarm, IStepAdjustment } from '../../../../../domain';
6
6
 
7
7
  import './StepPolicyAction.less';
8
8
 
9
- type Operator = 'Add' | 'Remove' | 'Set to';
10
- type AdjustmentTypeView = 'instances' | 'percent of group';
9
+ export type Operator = 'Add' | 'Remove' | 'Set to';
10
+ export type AdjustmentTypeView = 'instances' | 'percent of group';
11
11
 
12
12
  export interface IStepPolicyActionProps {
13
13
  adjustmentType: AdjustmentTypeView;
@@ -97,7 +97,7 @@ export const StepPolicyAction = ({
97
97
  stringOptions={adjustmentTypeOptions}
98
98
  onChange={(e) => onAdjustmentTypeChange(e.target.value)}
99
99
  clearable={false}
100
- inputClassName="adjustment-type-input"
100
+ inputClassName="adjustment-type-input sp-margin-xs-left"
101
101
  />
102
102
  )}
103
103
  <span className="sp-margin-xs-xaxis">
@@ -149,7 +149,7 @@ export const StepPolicyAction = ({
149
149
  ))}
150
150
  <div className="row sp-margin-s">
151
151
  <div className="col-md-10 col-md-offset-1">
152
- <button className="btn btn-block btn-sm add-new" onClick={addStep}>
152
+ <button type="button" className="btn btn-block btn-sm add-new" onClick={addStep}>
153
153
  <span className="glyphicon glyphicon-plus-sign"></span>
154
154
  Add step
155
155
  </button>
@@ -2,10 +2,10 @@ import React from 'react';
2
2
  import { shallow } from 'enzyme';
3
3
  import { mockLaunchTemplate, mockServerGroup } from '@spinnaker/mocks';
4
4
  import { IAmazonMixedInstancesPolicy, IAmazonServerGroupView, IScalingPolicy } from '../../../domain';
5
- import { InstancesDiversificationDetailsSection } from '../../../index';
5
+ import { InstancesDistributionDetailsSection } from '../../../index';
6
6
  import { Application, ApplicationModelBuilder } from '@spinnaker/core';
7
7
 
8
- describe('Instance diversification', () => {
8
+ describe('InstancesDistribution', () => {
9
9
  let app: Application;
10
10
  beforeEach(() => {
11
11
  app = ApplicationModelBuilder.createApplicationForTests('testapp');
@@ -14,7 +14,7 @@ describe('Instance diversification', () => {
14
14
  const serverGroupWithMip = {
15
15
  ...mockServerGroup,
16
16
  mixedInstancesPolicy: {
17
- instancesDiversification: {
17
+ instancesDistribution: {
18
18
  onDemandAllocationStrategy: 'prioritized',
19
19
  onDemandBaseCapacity: 1,
20
20
  onDemandPercentageAboveBaseCapacity: 50,
@@ -31,13 +31,13 @@ describe('Instance diversification', () => {
31
31
  ...mockServerGroup,
32
32
  launchTemplate: mockLaunchTemplate,
33
33
  } as IAmazonServerGroupView;
34
- const wrapper = shallow(<InstancesDiversificationDetailsSection serverGroup={serverGroupWithLt} app={app} />);
34
+ const wrapper = shallow(<InstancesDistributionDetailsSection serverGroup={serverGroupWithLt} app={app} />);
35
35
 
36
36
  expect(wrapper.isEmptyRender()).toEqual(true);
37
37
  });
38
38
 
39
39
  it('should render for server group with mixed instances policy', () => {
40
- const wrapper = shallow(<InstancesDiversificationDetailsSection serverGroup={serverGroupWithMip} app={app} />);
40
+ const wrapper = shallow(<InstancesDistributionDetailsSection serverGroup={serverGroupWithMip} app={app} />);
41
41
  expect(wrapper.isEmptyRender()).toEqual(false);
42
42
 
43
43
  const actualLabeledValues = wrapper.find('LabeledValue');
@@ -60,10 +60,10 @@ describe('Instance diversification', () => {
60
60
  const newServerGroup = {
61
61
  ...serverGroupWithMip,
62
62
  };
63
- newServerGroup.mixedInstancesPolicy.instancesDiversification.spotAllocationStrategy = 'lowest-price';
64
- newServerGroup.mixedInstancesPolicy.instancesDiversification.spotInstancePools = 5;
63
+ newServerGroup.mixedInstancesPolicy.instancesDistribution.spotAllocationStrategy = 'lowest-price';
64
+ newServerGroup.mixedInstancesPolicy.instancesDistribution.spotInstancePools = 5;
65
65
 
66
- const wrapper = shallow(<InstancesDiversificationDetailsSection serverGroup={newServerGroup} app={app} />);
66
+ const wrapper = shallow(<InstancesDistributionDetailsSection serverGroup={newServerGroup} app={app} />);
67
67
  expect(wrapper.isEmptyRender()).toEqual(false);
68
68
 
69
69
  const actualLabeledValues = wrapper.find('LabeledValue');
@@ -3,46 +3,46 @@ import React from 'react';
3
3
  import { CollapsibleSection, LabeledValue, LabeledValueList } from '@spinnaker/core';
4
4
  import { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps';
5
5
 
6
- export const InstancesDiversificationDetailsSection = ({ serverGroup }: IAmazonServerGroupDetailsSectionProps) => {
6
+ export const InstancesDistributionDetailsSection = ({ serverGroup }: IAmazonServerGroupDetailsSectionProps) => {
7
7
  if (!serverGroup.mixedInstancesPolicy) {
8
8
  return null;
9
9
  }
10
10
 
11
- const instancesDiversification = serverGroup.mixedInstancesPolicy.instancesDiversification;
11
+ const instancesDistribution = serverGroup.mixedInstancesPolicy.instancesDistribution;
12
12
  return (
13
- <CollapsibleSection heading="Instance Diversification">
13
+ <CollapsibleSection heading="Instances Distribution">
14
14
  <LabeledValueList className="horizontal-when-filters-collapsed">
15
15
  <LabeledValue
16
16
  label="On-Demand Allocation Strategy"
17
17
  helpFieldId="aws.serverGroup.odAllocationStrategy"
18
- value={instancesDiversification.onDemandAllocationStrategy}
18
+ value={instancesDistribution.onDemandAllocationStrategy}
19
19
  />
20
20
  <LabeledValue
21
21
  label="On-Demand Base Capacity"
22
22
  helpFieldId="aws.serverGroup.odBase"
23
- value={instancesDiversification.onDemandBaseCapacity}
23
+ value={instancesDistribution.onDemandBaseCapacity}
24
24
  />
25
25
  <LabeledValue
26
26
  label="On-Demand Percentage Above Base Capacity"
27
27
  helpFieldId="aws.serverGroup.odPercentAboveBase"
28
- value={instancesDiversification.onDemandPercentageAboveBaseCapacity}
28
+ value={instancesDistribution.onDemandPercentageAboveBaseCapacity}
29
29
  />
30
30
  <LabeledValue
31
31
  label="Spot Allocation Strategy"
32
32
  helpFieldId="aws.serverGroup.spotAllocationStrategy"
33
- value={instancesDiversification.spotAllocationStrategy}
33
+ value={instancesDistribution.spotAllocationStrategy}
34
34
  />
35
- {instancesDiversification.spotInstancePools && (
35
+ {instancesDistribution.spotInstancePools && (
36
36
  <LabeledValue
37
37
  label="Spot Instance Pools"
38
38
  helpFieldId="aws.serverGroup.spotInstancePoolCount"
39
- value={instancesDiversification.spotInstancePools}
39
+ value={instancesDistribution.spotInstancePools}
40
40
  />
41
41
  )}
42
42
  <LabeledValue
43
43
  label="Max Spot Price"
44
44
  helpFieldId="aws.serverGroup.spotMaxPrice"
45
- value={instancesDiversification.spotMaxPrice || 'on-demand price, default'}
45
+ value={instancesDistribution.spotMaxPrice || 'on-demand price, default'}
46
46
  />
47
47
  </LabeledValueList>
48
48
  </CollapsibleSection>
@@ -45,7 +45,7 @@ describe('Launch template details', () => {
45
45
  scalingPolicies: [] as IScalingPolicy[],
46
46
  mixedInstancesPolicy: {
47
47
  allowedInstanceTypes: ['some.type.medium', 'some.type.large'],
48
- instancesDiversification: {
48
+ instancesDistribution: {
49
49
  onDemandAllocationStrategy: 'prioritized',
50
50
  onDemandBaseCapacity: 1,
51
51
  onDemandPercentageAboveBaseCapacity: 50,
@@ -18,7 +18,7 @@ export const LaunchTemplateDetailsSection = ({ serverGroup }: IAmazonServerGroup
18
18
 
19
19
  const { launchTemplateData } = launchTemplate;
20
20
  const maxSpotPrice = isMip
21
- ? serverGroup.mixedInstancesPolicy.instancesDiversification.spotMaxPrice
21
+ ? serverGroup.mixedInstancesPolicy.instancesDistribution.spotMaxPrice
22
22
  : launchTemplateData?.instanceMarketOptions?.spotOptions?.maxPrice;
23
23
  const creditSpecification = launchTemplateData?.creditSpecification?.cpuCredits;
24
24
  const launchTemplateOverrides = isMip
@@ -32,7 +32,7 @@ export function MultipleInstanceTypesSubSection(props: { instanceTypeOverrides:
32
32
  </thead>
33
33
  <tbody>
34
34
  {props.instanceTypeOverrides.map((override) => [
35
- <tr>
35
+ <tr key={override.instanceType}>
36
36
  <td headers="instanceType">{override.instanceType}</td>
37
37
  <td headers="weight">{override.weightedCapacity}</td>
38
38
  </tr>,
@@ -3,7 +3,7 @@ export * from './AmazonInfoDetailsSection';
3
3
  export * from './AmazonCapacityDetailsSection';
4
4
  export * from './HealthDetailsSection';
5
5
  export * from './IAmazonServerGroupDetailsSectionProps';
6
- export * from './InstancesDiversificationDetailsSection';
6
+ export * from './InstancesDistributionDetailsSection';
7
7
  export * from './LaunchConfigDetailsSection';
8
8
  export * from './LaunchTemplateDetailsSection';
9
9
  export * from './LogsDetailsSection';
@@ -1,41 +0,0 @@
1
- import { IComponentController, IScope } from 'angular';
2
- import { IModalServiceInstance } from 'angular-ui-bootstrap';
3
- import { Subject } from 'rxjs';
4
- import { Application, IServerGroup, TaskMonitor } from '@spinnaker/core';
5
- import { IUpsertScalingPolicyCommand } from '../ScalingPolicyWriter';
6
- import { ICustomizedMetricSpecification, ITargetTrackingConfiguration, ITargetTrackingPolicy } from '../../../../domain';
7
- export declare type MetricType = 'custom' | 'predefined';
8
- export interface ITargetTrackingState {
9
- metricType: MetricType;
10
- unit: string;
11
- scaleInChanged: boolean;
12
- }
13
- export interface ITargetTrackingPolicyCommand extends IUpsertScalingPolicyCommand {
14
- estimatedInstanceWarmup: number;
15
- targetTrackingConfiguration: ITargetTrackingConfiguration;
16
- }
17
- export declare class UpsertTargetTrackingController implements IComponentController {
18
- private $uibModalInstance;
19
- policy: ITargetTrackingPolicy;
20
- serverGroup: IServerGroup;
21
- application: Application;
22
- private $scope;
23
- predefinedMetrics: string[];
24
- statistics: string[];
25
- alarmUpdated: Subject<unknown>;
26
- taskMonitor: TaskMonitor;
27
- state: ITargetTrackingState;
28
- command: ITargetTrackingPolicyCommand;
29
- static $inject: string[];
30
- constructor($uibModalInstance: IModalServiceInstance, policy: ITargetTrackingPolicy, serverGroup: IServerGroup, application: Application, $scope: IScope);
31
- $onInit(): void;
32
- metricTypeChanged: (type: MetricType) => void;
33
- toggleMetricType: () => void;
34
- updateUnit: (unit: string) => void;
35
- scaleInChanged(): void;
36
- alarmChanged: (newAlarm: ICustomizedMetricSpecification) => void;
37
- commandChanged: (updatedCommand: ITargetTrackingPolicyCommand) => void;
38
- cancel(): void;
39
- save(): void;
40
- private buildCommand;
41
- }
@@ -1,2 +0,0 @@
1
- export const AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_UPSERT_ALARM_ALARMCONFIGURER_COMPONENT: "spinnaker.amazon.serverGroup.details.scalingPolicy.alarm.configurer";
2
- export const name: "spinnaker.amazon.serverGroup.details.scalingPolicy.alarm.configurer";
@@ -1,2 +0,0 @@
1
- export const AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_UPSERT_ALARM_DIMENSIONSEDITOR_COMPONENT: "spinnaker.amazon.serverGroup.details.scalingPolicy.dimensionEditor";
2
- export const name: "spinnaker.amazon.serverGroup.details.scalingPolicy.dimensionEditor";
@@ -1,2 +0,0 @@
1
- export const AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_UPSERT_SIMPLE_SIMPLEPOLICYACTION_COMPONENT: "spinnaker.amazon.serverGroup.details.scalingPolicy.upsert.actions.simplePolicy";
2
- export const name: "spinnaker.amazon.serverGroup.details.scalingPolicy.upsert.actions.simplePolicy";
@@ -1,2 +0,0 @@
1
- export const AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_UPSERT_UPSERTSCALINGPOLICY_CONTROLLER: "spinnaker.amazon.serverGroup.details.scalingPolicy.upsertScalingPolicy.controller";
2
- export const name: "spinnaker.amazon.serverGroup.details.scalingPolicy.upsertScalingPolicy.controller";
@@ -1,2 +0,0 @@
1
- import { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps';
2
- export declare const InstancesDiversificationDetailsSection: ({ serverGroup }: IAmazonServerGroupDetailsSectionProps) => JSX.Element;