@spinnaker/titus 0.5.4 → 0.5.8
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.
- package/CHANGELOG.md +32 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/serverGroup/details/scalingPolicy/targetTracking/UpsertTargetTrackingModal.d.ts +9 -0
- package/dist/serverGroup/details/scalingPolicy/upsert/TitusScalingPolicyCommandBuilderService.d.ts +3 -2
- package/dist/serverGroup/details/scalingPolicy/upsert/UpsertScalingPolicyModal.d.ts +9 -0
- package/package.json +6 -6
- package/src/serverGroup/details/scalingPolicy/CreateScalingPolicyButton.tsx +17 -43
- package/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js +10 -17
- package/src/serverGroup/details/scalingPolicy/targetTracking/UpsertTargetTrackingModal.tsx +81 -0
- package/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts +10 -18
- package/src/serverGroup/details/scalingPolicy/upsert/TitusScalingPolicyCommandBuilderService.ts +5 -9
- package/src/serverGroup/details/scalingPolicy/upsert/UpsertScalingPolicyModal.tsx +158 -0
- package/dist/serverGroup/details/scalingPolicy/targetTracking/upsertTargetTracking.controller.d.ts +0 -40
- package/dist/serverGroup/details/scalingPolicy/upsert/upsertScalingPolicy.controller.d.ts +0 -2
- package/src/serverGroup/details/scalingPolicy/targetTracking/upsertTargetTracking.controller.ts +0 -98
- package/src/serverGroup/details/scalingPolicy/targetTracking/upsertTargetTracking.modal.html +0 -154
- package/src/serverGroup/details/scalingPolicy/upsert/upsertScalingPolicy.controller.js +0 -188
- package/src/serverGroup/details/scalingPolicy/upsert/upsertScalingPolicy.modal.html +0 -88
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITargetTrackingPolicy } from '@spinnaker/amazon';
|
|
2
|
+
import { Application, IModalComponentProps } from '@spinnaker/core';
|
|
3
|
+
import { ITitusServerGroup } from '../../../../domain';
|
|
4
|
+
export interface IUpsertTargetTrackingModalProps extends IModalComponentProps {
|
|
5
|
+
app: Application;
|
|
6
|
+
policy: ITargetTrackingPolicy;
|
|
7
|
+
serverGroup: ITitusServerGroup;
|
|
8
|
+
}
|
|
9
|
+
export declare const UpsertTargetTrackingModal: ({ app, closeModal, dismissModal, policy, serverGroup, }: IUpsertTargetTrackingModalProps) => JSX.Element;
|
package/dist/serverGroup/details/scalingPolicy/upsert/TitusScalingPolicyCommandBuilderService.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IScalingPolicy, IStepPolicyDescription, ITargetTrackingPolicy, IUpsertAlarmDescription, IUpsertScalingPolicyCommand } from '@spinnaker/amazon';
|
|
2
|
+
import { ITitusServerGroup } from '../../../../domain';
|
|
2
3
|
declare type PolicyType = 'Step' | 'TargetTracking';
|
|
3
4
|
export declare const TitusScalingPolicyCommandBuilder: {
|
|
4
5
|
buildAlarm: (policy: IScalingPolicy, region: string) => IUpsertAlarmDescription;
|
|
5
6
|
buildStepPolicy: (policy: IScalingPolicy, threshold: number, cooldown: number) => IStepPolicyDescription;
|
|
6
|
-
buildNewCommand: (type: PolicyType, serverGroup:
|
|
7
|
+
buildNewCommand: (type: PolicyType, serverGroup: ITitusServerGroup, policy: ITargetTrackingPolicy) => IUpsertScalingPolicyCommand;
|
|
7
8
|
prepareCommandForUpsert: (command: IUpsertScalingPolicyCommand, isRemove: boolean) => IUpsertScalingPolicyCommand;
|
|
8
9
|
};
|
|
9
10
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IScalingPolicy } from '@spinnaker/amazon';
|
|
2
|
+
import { Application, IModalComponentProps } from '@spinnaker/core';
|
|
3
|
+
import { ITitusServerGroup } from '../../../../domain';
|
|
4
|
+
export interface IUpsertScalingPolicyModalProps extends IModalComponentProps {
|
|
5
|
+
app: Application;
|
|
6
|
+
policy: IScalingPolicy;
|
|
7
|
+
serverGroup: ITitusServerGroup;
|
|
8
|
+
}
|
|
9
|
+
export declare const UpsertScalingPolicyModal: ({ app, closeModal, dismissModal, policy, serverGroup, }: IUpsertScalingPolicyModalProps) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spinnaker/titus",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.8",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"lib": "npm run build"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@spinnaker/amazon": "^0.8.
|
|
17
|
-
"@spinnaker/core": "^0.11.
|
|
18
|
-
"@spinnaker/docker": "^0.0.
|
|
16
|
+
"@spinnaker/amazon": "^0.8.14",
|
|
17
|
+
"@spinnaker/core": "^0.11.7",
|
|
18
|
+
"@spinnaker/docker": "^0.0.114",
|
|
19
19
|
"@spinnaker/mocks": "1.0.7",
|
|
20
20
|
"@uirouter/angularjs": "1.0.26",
|
|
21
21
|
"@uirouter/react": "1.0.7",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@spinnaker/eslint-plugin": "^1.1.1",
|
|
37
|
-
"@spinnaker/scripts": "^0.
|
|
37
|
+
"@spinnaker/scripts": "^0.2.0",
|
|
38
38
|
"@types/angular": "1.6.26",
|
|
39
39
|
"@types/angular-ui-bootstrap": "0.13.41",
|
|
40
40
|
"@types/lodash": "4.14.64",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"shx": "0.3.3",
|
|
45
45
|
"typescript": "4.3.5"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "5b8914288d87ce58b67de4720ebc623b18a3be3e"
|
|
48
48
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { PolicyTypeSelectionModal } from '@spinnaker/amazon';
|
|
4
|
-
import { AccountService, Application, IServerGroup,
|
|
4
|
+
import { AccountService, Application, IServerGroup, ReactModal } from '@spinnaker/core';
|
|
5
5
|
|
|
6
6
|
import { TitusReactInjector } from '../../../reactShims';
|
|
7
|
-
import {
|
|
7
|
+
import { IUpsertScalingPolicyModalProps, UpsertScalingPolicyModal } from './upsert/UpsertScalingPolicyModal';
|
|
8
|
+
import { IUpsertTargetTrackingModalProps, UpsertTargetTrackingModal } from './targetTracking/UpsertTargetTrackingModal';
|
|
8
9
|
|
|
9
10
|
export interface ICreateScalingPolicyButtonProps {
|
|
10
11
|
application: Application;
|
|
@@ -42,51 +43,24 @@ export class CreateScalingPolicyButton extends React.Component<
|
|
|
42
43
|
public createStepPolicy(): void {
|
|
43
44
|
const { serverGroup, application } = this.props;
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
policy: () =>
|
|
53
|
-
TitusReactInjector.titusServerGroupTransformer.constructNewStepScalingPolicyTemplate(serverGroup),
|
|
54
|
-
serverGroup: () => serverGroup,
|
|
55
|
-
alarmServerGroup: () => ({
|
|
56
|
-
type: 'aws',
|
|
57
|
-
account: this.state.awsAccount,
|
|
58
|
-
region: serverGroup.region,
|
|
59
|
-
name: serverGroup.name,
|
|
60
|
-
}),
|
|
61
|
-
application: () => application,
|
|
62
|
-
},
|
|
63
|
-
})
|
|
64
|
-
.result.catch(() => {});
|
|
46
|
+
const upsertProps = {
|
|
47
|
+
app: application,
|
|
48
|
+
policy: TitusReactInjector.titusServerGroupTransformer.constructNewStepScalingPolicyTemplate(serverGroup),
|
|
49
|
+
serverGroup,
|
|
50
|
+
} as IUpsertScalingPolicyModalProps;
|
|
51
|
+
const modalProps = { dialogClassName: 'wizard-modal modal-lg' };
|
|
52
|
+
ReactModal.show(UpsertScalingPolicyModal, upsertProps, modalProps);
|
|
65
53
|
}
|
|
66
54
|
|
|
67
55
|
public createTargetTrackingPolicy(): void {
|
|
68
56
|
const { serverGroup, application } = this.props;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
resolve: {
|
|
77
|
-
policy: () =>
|
|
78
|
-
TitusReactInjector.titusServerGroupTransformer.constructNewTargetTrackingPolicyTemplate(serverGroup),
|
|
79
|
-
serverGroup: () => serverGroup,
|
|
80
|
-
alarmServerGroup: () => ({
|
|
81
|
-
type: 'aws',
|
|
82
|
-
account: this.state.awsAccount,
|
|
83
|
-
region: serverGroup.region,
|
|
84
|
-
name: serverGroup.name,
|
|
85
|
-
}),
|
|
86
|
-
application: () => application,
|
|
87
|
-
},
|
|
88
|
-
})
|
|
89
|
-
.result.catch(() => {});
|
|
57
|
+
const upsertProps = {
|
|
58
|
+
app: application,
|
|
59
|
+
policy: TitusReactInjector.titusServerGroupTransformer.constructNewTargetTrackingPolicyTemplate(serverGroup),
|
|
60
|
+
serverGroup,
|
|
61
|
+
} as IUpsertTargetTrackingModalProps;
|
|
62
|
+
const modalProps = { dialogClassName: 'wizard-modal modal-lg' };
|
|
63
|
+
ReactModal.show(UpsertTargetTrackingModal, upsertProps, modalProps);
|
|
90
64
|
}
|
|
91
65
|
|
|
92
66
|
public typeSelected = (typeSelection: string): void => {
|
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import { module } from 'angular';
|
|
4
4
|
|
|
5
|
-
import { AccountService, ConfirmationModalService, TaskExecutor } from '@spinnaker/core';
|
|
5
|
+
import { AccountService, ConfirmationModalService, ReactModal, TaskExecutor } from '@spinnaker/core';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { UpsertScalingPolicyModal } from './upsert/UpsertScalingPolicyModal';
|
|
8
8
|
|
|
9
9
|
import './scalingPolicySummary.component.less';
|
|
10
10
|
|
|
11
11
|
export const TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT =
|
|
12
12
|
'spinnaker.titus.serverGroup.details.scalingPolicy.alarmBasedSummary.component';
|
|
13
13
|
export const name = TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT; // for backwards compatibility
|
|
14
|
-
module(TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT, [
|
|
15
|
-
TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_UPSERT_UPSERTSCALINGPOLICY_CONTROLLER,
|
|
16
|
-
]).component('titusAlarmBasedSummary', {
|
|
14
|
+
module(TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT, []).component('titusAlarmBasedSummary', {
|
|
17
15
|
bindings: {
|
|
18
16
|
policy: '=',
|
|
19
17
|
serverGroup: '=',
|
|
@@ -38,18 +36,13 @@ module(TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT, [
|
|
|
38
36
|
this.popoverTemplate = require('./popover/scalingPolicyDetails.popover.html');
|
|
39
37
|
|
|
40
38
|
this.editPolicy = () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
alarmServerGroup: () => this.alarmServerGroup,
|
|
49
|
-
serverGroup: () => this.serverGroup,
|
|
50
|
-
application: () => this.application,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
39
|
+
const upsertProps = {
|
|
40
|
+
app: this.application,
|
|
41
|
+
policy: this.policy,
|
|
42
|
+
serverGroup: this.serverGroup,
|
|
43
|
+
};
|
|
44
|
+
const modalProps = { dialogClassName: 'wizard-modal modal-lg' };
|
|
45
|
+
ReactModal.show(UpsertScalingPolicyModal, upsertProps, modalProps);
|
|
53
46
|
};
|
|
54
47
|
|
|
55
48
|
this.deletePolicy = () => {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
IAmazonServerGroup,
|
|
5
|
+
ITargetTrackingPolicy,
|
|
6
|
+
ITargetTrackingPolicyCommand,
|
|
7
|
+
IUpsertScalingPolicyCommand,
|
|
8
|
+
TargetMetricFields,
|
|
9
|
+
TargetTrackingAdditionalSettings,
|
|
10
|
+
} from '@spinnaker/amazon';
|
|
11
|
+
import { Application, IModalComponentProps, TaskMonitorModal } from '@spinnaker/core';
|
|
12
|
+
|
|
13
|
+
import { ITitusServerGroup } from '../../../../domain';
|
|
14
|
+
import { TitusScalingPolicyCommandBuilder } from '../upsert/TitusScalingPolicyCommandBuilderService';
|
|
15
|
+
|
|
16
|
+
export interface IUpsertTargetTrackingModalProps extends IModalComponentProps {
|
|
17
|
+
app: Application;
|
|
18
|
+
policy: ITargetTrackingPolicy;
|
|
19
|
+
serverGroup: ITitusServerGroup;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const UpsertTargetTrackingModal = ({
|
|
23
|
+
app,
|
|
24
|
+
closeModal,
|
|
25
|
+
dismissModal,
|
|
26
|
+
policy,
|
|
27
|
+
serverGroup,
|
|
28
|
+
}: IUpsertTargetTrackingModalProps) => {
|
|
29
|
+
const [isCustom, setIsCustom] = React.useState<boolean>(
|
|
30
|
+
Boolean(policy.targetTrackingConfiguration?.customizedMetricSpecification),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const [command, setCommand] = React.useState<IUpsertScalingPolicyCommand>({} as IUpsertScalingPolicyCommand);
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
const baseCommand = TitusScalingPolicyCommandBuilder.buildNewCommand('TargetTracking', serverGroup, policy);
|
|
36
|
+
setCommand(baseCommand);
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
const mode = policy.id ? 'Update' : 'Create';
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<TaskMonitorModal<IUpsertScalingPolicyCommand>
|
|
43
|
+
closeModal={closeModal}
|
|
44
|
+
dismissModal={dismissModal}
|
|
45
|
+
title={`${mode} scaling policy`}
|
|
46
|
+
application={app}
|
|
47
|
+
description={`${mode} scaling policy for ${serverGroup.name}`}
|
|
48
|
+
initialValues={command}
|
|
49
|
+
mapValuesToTask={() => ({
|
|
50
|
+
application: app,
|
|
51
|
+
job: [
|
|
52
|
+
{
|
|
53
|
+
type: 'upsertScalingPolicy',
|
|
54
|
+
...command,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
})}
|
|
58
|
+
render={() => (
|
|
59
|
+
<div className="modal-body">
|
|
60
|
+
<h4 className="section-heading">Target Metric</h4>
|
|
61
|
+
<TargetMetricFields
|
|
62
|
+
allowDualMode={false}
|
|
63
|
+
cloudwatch={true}
|
|
64
|
+
command={command as ITargetTrackingPolicyCommand}
|
|
65
|
+
isCustomMetric={isCustom}
|
|
66
|
+
serverGroup={(serverGroup as unknown) as IAmazonServerGroup}
|
|
67
|
+
toggleMetricType={(t) => setIsCustom(t === 'custom')}
|
|
68
|
+
updateCommand={setCommand}
|
|
69
|
+
/>
|
|
70
|
+
<h4 className="section-heading">Additional Settings</h4>
|
|
71
|
+
<TargetTrackingAdditionalSettings
|
|
72
|
+
command={command}
|
|
73
|
+
cooldowns={true}
|
|
74
|
+
policyName={policy.policyName}
|
|
75
|
+
updateCommand={setCommand}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
};
|
package/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IComponentController, IComponentOptions, module } from 'angular';
|
|
2
|
-
import { IModalService } from 'angular-ui-bootstrap';
|
|
3
2
|
|
|
4
3
|
import { ITargetTrackingConfiguration, ITargetTrackingPolicy } from '@spinnaker/amazon';
|
|
5
4
|
import {
|
|
@@ -8,10 +7,11 @@ import {
|
|
|
8
7
|
ConfirmationModalService,
|
|
9
8
|
IServerGroup,
|
|
10
9
|
ITaskMonitorConfig,
|
|
10
|
+
ReactModal,
|
|
11
11
|
TaskExecutor,
|
|
12
12
|
} from '@spinnaker/core';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { IUpsertTargetTrackingModalProps, UpsertTargetTrackingModal } from './UpsertTargetTrackingModal';
|
|
15
15
|
|
|
16
16
|
export interface IAlarmRenderingServerGroup {
|
|
17
17
|
type: string;
|
|
@@ -32,8 +32,7 @@ class TargetTrackingSummaryController implements IComponentController {
|
|
|
32
32
|
public config: ITargetTrackingConfiguration;
|
|
33
33
|
public popoverTemplate = require('./targetTrackingPopover.html');
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
constructor(private $uibModal: IModalService) {}
|
|
35
|
+
constructor() {}
|
|
37
36
|
|
|
38
37
|
public $onInit() {
|
|
39
38
|
this.config = this.policy.targetTrackingConfiguration;
|
|
@@ -49,20 +48,13 @@ class TargetTrackingSummaryController implements IComponentController {
|
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
public editPolicy(): void {
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
policy: () => this.policy,
|
|
60
|
-
alarmServerGroup: () => this.alarmServerGroup,
|
|
61
|
-
serverGroup: () => this.serverGroup,
|
|
62
|
-
application: () => this.application,
|
|
63
|
-
},
|
|
64
|
-
})
|
|
65
|
-
.result.catch(() => {});
|
|
51
|
+
const upsertProps = {
|
|
52
|
+
app: this.application,
|
|
53
|
+
policy: this.policy,
|
|
54
|
+
serverGroup: this.serverGroup,
|
|
55
|
+
} as IUpsertTargetTrackingModalProps;
|
|
56
|
+
const modalProps = { dialogClassName: 'wizard-modal modal-lg' };
|
|
57
|
+
ReactModal.show(UpsertTargetTrackingModal, upsertProps, modalProps);
|
|
66
58
|
}
|
|
67
59
|
|
|
68
60
|
public deletePolicy(): void {
|
package/src/serverGroup/details/scalingPolicy/upsert/TitusScalingPolicyCommandBuilderService.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { cloneDeep } from 'lodash';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
IAmazonServerGroup,
|
|
5
4
|
IScalingPolicy,
|
|
6
5
|
IScalingPolicyAlarmView,
|
|
7
6
|
IStepAdjustment,
|
|
@@ -10,6 +9,7 @@ import {
|
|
|
10
9
|
IUpsertAlarmDescription,
|
|
11
10
|
IUpsertScalingPolicyCommand,
|
|
12
11
|
} from '@spinnaker/amazon';
|
|
12
|
+
import { ITitusServerGroup } from '../../../../domain';
|
|
13
13
|
|
|
14
14
|
type PolicyType = 'Step' | 'TargetTracking';
|
|
15
15
|
|
|
@@ -49,7 +49,7 @@ export const TitusScalingPolicyCommandBuilder = {
|
|
|
49
49
|
|
|
50
50
|
return {
|
|
51
51
|
cooldown: cooldown || 600,
|
|
52
|
-
estimatedInstanceWarmup:
|
|
52
|
+
estimatedInstanceWarmup: null,
|
|
53
53
|
metricAggregationType: 'Average',
|
|
54
54
|
stepAdjustments,
|
|
55
55
|
};
|
|
@@ -57,14 +57,14 @@ export const TitusScalingPolicyCommandBuilder = {
|
|
|
57
57
|
|
|
58
58
|
buildNewCommand: (
|
|
59
59
|
type: PolicyType,
|
|
60
|
-
serverGroup:
|
|
60
|
+
serverGroup: ITitusServerGroup,
|
|
61
61
|
policy: ITargetTrackingPolicy,
|
|
62
62
|
): IUpsertScalingPolicyCommand => {
|
|
63
63
|
const command = {
|
|
64
64
|
adjustmentType: type === 'Step' ? policy.adjustmentType : null,
|
|
65
65
|
cloudProvider: serverGroup.cloudProvider,
|
|
66
66
|
credentials: serverGroup.account,
|
|
67
|
-
jobId: serverGroup.
|
|
67
|
+
jobId: serverGroup.id,
|
|
68
68
|
name: policy.id,
|
|
69
69
|
region: serverGroup.region,
|
|
70
70
|
scalingPolicyID: policy.id,
|
|
@@ -74,11 +74,7 @@ export const TitusScalingPolicyCommandBuilder = {
|
|
|
74
74
|
if (type === 'Step') {
|
|
75
75
|
command.alarm = TitusScalingPolicyCommandBuilder.buildAlarm(policy, serverGroup.region);
|
|
76
76
|
command.minAdjustmentMagnitude = policy.minAdjustmentMagnitude || 1;
|
|
77
|
-
command.step = TitusScalingPolicyCommandBuilder.buildStepPolicy(
|
|
78
|
-
policy,
|
|
79
|
-
command.alarm.threshold,
|
|
80
|
-
command.cooldown,
|
|
81
|
-
);
|
|
77
|
+
command.step = TitusScalingPolicyCommandBuilder.buildStepPolicy(policy, command.alarm.threshold, policy.cooldown);
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
if (type === 'TargetTracking') {
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { cloneDeep } from 'lodash';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AlarmConfigurer,
|
|
6
|
+
IScalingPolicy,
|
|
7
|
+
IStepAdjustment,
|
|
8
|
+
IStepPolicyDescription,
|
|
9
|
+
ITargetTrackingPolicy,
|
|
10
|
+
IUpsertScalingPolicyCommand,
|
|
11
|
+
ScalingPolicyAdditionalSettings,
|
|
12
|
+
StepPolicyAction,
|
|
13
|
+
} from '@spinnaker/amazon';
|
|
14
|
+
import { IAmazonServerGroup, IScalingPolicyAlarm } from '@spinnaker/amazon/src/domain';
|
|
15
|
+
import { Application, IModalComponentProps, TaskMonitorModal } from '@spinnaker/core';
|
|
16
|
+
|
|
17
|
+
import { TitusScalingPolicyCommandBuilder } from './TitusScalingPolicyCommandBuilderService';
|
|
18
|
+
import { ITitusServerGroup } from '../../../../domain';
|
|
19
|
+
|
|
20
|
+
type Operator = 'Add' | 'Remove' | 'Set to';
|
|
21
|
+
type AdjustmentTypeView = 'instances' | 'percent of group';
|
|
22
|
+
|
|
23
|
+
export interface IUpsertScalingPolicyModalProps extends IModalComponentProps {
|
|
24
|
+
app: Application;
|
|
25
|
+
policy: IScalingPolicy;
|
|
26
|
+
serverGroup: ITitusServerGroup;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const UpsertScalingPolicyModal = ({
|
|
30
|
+
app,
|
|
31
|
+
closeModal,
|
|
32
|
+
dismissModal,
|
|
33
|
+
policy,
|
|
34
|
+
serverGroup,
|
|
35
|
+
}: IUpsertScalingPolicyModalProps) => {
|
|
36
|
+
const [command, setCommand] = React.useState<IUpsertScalingPolicyCommand>({} as IUpsertScalingPolicyCommand);
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
const baseCommand = TitusScalingPolicyCommandBuilder.buildNewCommand(
|
|
39
|
+
'Step',
|
|
40
|
+
serverGroup,
|
|
41
|
+
policy as ITargetTrackingPolicy,
|
|
42
|
+
);
|
|
43
|
+
setCommand(baseCommand);
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
const adjustmentBasis = policy.stepAdjustments?.length
|
|
47
|
+
? policy.stepAdjustments[0].scalingAdjustment
|
|
48
|
+
: policy.scalingAdjustment;
|
|
49
|
+
const [action, setAction] = React.useState<Operator>(
|
|
50
|
+
command.adjustmentType === 'ExactCapacity' ? 'Set to' : adjustmentBasis > 0 ? 'Add' : 'Remove',
|
|
51
|
+
);
|
|
52
|
+
const adjustmentTypeView =
|
|
53
|
+
command.adjustmentType === 'ExactCapacity' || command.adjustmentType === 'ChangeInCapacity'
|
|
54
|
+
? 'instances'
|
|
55
|
+
: 'percent of group';
|
|
56
|
+
|
|
57
|
+
const mode = !policy.id ? 'Create' : 'Edit';
|
|
58
|
+
const comparatorBound = command?.alarm?.comparisonOperator?.indexOf('Greater') === 0 ? 'max' : 'min';
|
|
59
|
+
|
|
60
|
+
const boundsChanged = (step: IStepPolicyDescription) => {
|
|
61
|
+
const source = comparatorBound === 'min' ? 'metricIntervalLowerBound' : 'metricIntervalUpperBound';
|
|
62
|
+
const target = source === 'metricIntervalLowerBound' ? 'metricIntervalUpperBound' : 'metricIntervalLowerBound';
|
|
63
|
+
|
|
64
|
+
const adjustments = step.stepAdjustments;
|
|
65
|
+
(adjustments || []).forEach((a, index) => {
|
|
66
|
+
if (adjustments.length > index + 1) {
|
|
67
|
+
adjustments[index + 1][target] = a[source];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
// Remove the source boundary from the last step
|
|
71
|
+
delete adjustments[adjustments.length - 1][source];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const stepsChanged = (newSteps: IStepAdjustment[]) => {
|
|
75
|
+
const newCommand = cloneDeep(command);
|
|
76
|
+
newCommand.step.stepAdjustments = newSteps;
|
|
77
|
+
boundsChanged(newCommand.step);
|
|
78
|
+
setCommand(newCommand);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const adjustmentTypeChanged = (action: Operator, type: AdjustmentTypeView) => {
|
|
82
|
+
setAction(action);
|
|
83
|
+
|
|
84
|
+
const newType =
|
|
85
|
+
type !== 'instances' ? 'PercentChangeInCapacity' : action === 'Set to' ? 'ExactCapacity' : 'ChangeInCapacity';
|
|
86
|
+
setCommand({
|
|
87
|
+
...command,
|
|
88
|
+
adjustmentType: newType,
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<TaskMonitorModal<IUpsertScalingPolicyCommand>
|
|
94
|
+
closeModal={closeModal}
|
|
95
|
+
dismissModal={dismissModal}
|
|
96
|
+
title={`${mode} scaling policy`}
|
|
97
|
+
application={app}
|
|
98
|
+
description={`${mode} scaling policy for ${serverGroup.name}`}
|
|
99
|
+
initialValues={command}
|
|
100
|
+
mapValuesToTask={() => {
|
|
101
|
+
const preppedValues = TitusScalingPolicyCommandBuilder.prepareCommandForUpsert(command, action === 'Remove');
|
|
102
|
+
return {
|
|
103
|
+
application: app,
|
|
104
|
+
job: [
|
|
105
|
+
{
|
|
106
|
+
type: preppedValues.type || 'upsertScalingPolicy',
|
|
107
|
+
...preppedValues,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
}}
|
|
112
|
+
render={() => (
|
|
113
|
+
<div>
|
|
114
|
+
<h4 className="section-heading">Conditions</h4>
|
|
115
|
+
<div className="section-body">
|
|
116
|
+
<p>
|
|
117
|
+
<b>Note:</b> metrics must be sent to Amazon CloudWatch before they can be used in auto scaling. If you do
|
|
118
|
+
not see a metric below, click "Configure available metrics" in the server group details to set up
|
|
119
|
+
forwarding from Atlas to CloudWatch.
|
|
120
|
+
</p>
|
|
121
|
+
<AlarmConfigurer
|
|
122
|
+
alarm={command.alarm}
|
|
123
|
+
multipleAlarms={Boolean(policy?.alarms?.length > 1)}
|
|
124
|
+
serverGroup={(serverGroup as unknown) as IAmazonServerGroup}
|
|
125
|
+
stepAdjustments={command.step.stepAdjustments}
|
|
126
|
+
stepsChanged={stepsChanged}
|
|
127
|
+
updateAlarm={(alarm: IScalingPolicyAlarm) =>
|
|
128
|
+
setCommand({ ...command, alarm } as IUpsertScalingPolicyCommand)
|
|
129
|
+
}
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
<h4 className="section-heading">Actions</h4>
|
|
133
|
+
<div className="section-body">
|
|
134
|
+
{!command.alarm?.metricName && <h4 className="text-center">Select a metric</h4>}
|
|
135
|
+
{command.alarm?.metricName && (
|
|
136
|
+
<StepPolicyAction
|
|
137
|
+
adjustmentType={adjustmentTypeView}
|
|
138
|
+
adjustmentTypeChanged={adjustmentTypeChanged}
|
|
139
|
+
alarm={command.alarm}
|
|
140
|
+
isMin={comparatorBound === 'min'}
|
|
141
|
+
operator={action}
|
|
142
|
+
step={command.step}
|
|
143
|
+
stepsChanged={stepsChanged}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
</div>
|
|
147
|
+
<ScalingPolicyAdditionalSettings
|
|
148
|
+
command={command}
|
|
149
|
+
isInstanceType={adjustmentTypeView === 'instances'}
|
|
150
|
+
isNew={Boolean(!policy.policyARN)}
|
|
151
|
+
operator={action}
|
|
152
|
+
updateCommand={setCommand}
|
|
153
|
+
/>
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
};
|
package/dist/serverGroup/details/scalingPolicy/targetTracking/upsertTargetTracking.controller.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IComponentController } from 'angular';
|
|
2
|
-
import { IModalServiceInstance } from 'angular-ui-bootstrap';
|
|
3
|
-
import { Subject } from 'rxjs';
|
|
4
|
-
import { ITargetTrackingConfiguration, ITargetTrackingPolicy, IUpsertScalingPolicyCommand } from '@spinnaker/amazon';
|
|
5
|
-
import { Application, IServerGroup, TaskMonitor } from '@spinnaker/core';
|
|
6
|
-
import { IAlarmRenderingServerGroup } from './targetTrackingSummary.component';
|
|
7
|
-
export interface ITargetTrackingState {
|
|
8
|
-
unit: string;
|
|
9
|
-
scaleInChanged: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface ITargetTrackingPolicyCommand extends IUpsertScalingPolicyCommand {
|
|
12
|
-
jobId: string;
|
|
13
|
-
targetTrackingConfiguration: ITargetTrackingConfiguration;
|
|
14
|
-
}
|
|
15
|
-
export interface ITitusServerGroup extends IServerGroup {
|
|
16
|
-
id: string;
|
|
17
|
-
}
|
|
18
|
-
export interface ITitusTargetTrackingPolicy extends ITargetTrackingPolicy {
|
|
19
|
-
id?: string;
|
|
20
|
-
}
|
|
21
|
-
export declare class UpsertTargetTrackingController implements IComponentController {
|
|
22
|
-
private $uibModalInstance;
|
|
23
|
-
policy: ITitusTargetTrackingPolicy;
|
|
24
|
-
serverGroup: ITitusServerGroup;
|
|
25
|
-
alarmServerGroup: IAlarmRenderingServerGroup;
|
|
26
|
-
application: Application;
|
|
27
|
-
statistics: string[];
|
|
28
|
-
alarmUpdated: Subject<unknown>;
|
|
29
|
-
taskMonitor: TaskMonitor;
|
|
30
|
-
state: ITargetTrackingState;
|
|
31
|
-
command: ITargetTrackingPolicyCommand;
|
|
32
|
-
static $inject: string[];
|
|
33
|
-
constructor($uibModalInstance: IModalServiceInstance, policy: ITitusTargetTrackingPolicy, serverGroup: ITitusServerGroup, alarmServerGroup: IAlarmRenderingServerGroup, application: Application);
|
|
34
|
-
$onInit(): void;
|
|
35
|
-
scaleInChanged(): void;
|
|
36
|
-
updateUnit: (unit: string) => void;
|
|
37
|
-
cancel(): void;
|
|
38
|
-
save(): void;
|
|
39
|
-
private buildCommand;
|
|
40
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export const TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_UPSERT_UPSERTSCALINGPOLICY_CONTROLLER: "spinnaker.titus.serverGroup.details.scalingPolicy.upsertScalingPolicy.controller";
|
|
2
|
-
export const name: "spinnaker.titus.serverGroup.details.scalingPolicy.upsertScalingPolicy.controller";
|