@spinnaker/google 0.1.13 → 0.2.1

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 (29) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/autoscalingPolicy/IGceAutoscalingPolicy.d.ts +1 -1
  3. package/dist/autoscalingPolicy/components/scalingSchedules/scalingSchedules.component.d.ts +2 -0
  4. package/dist/autoscalingPolicy/components/scalingSchedules/timeZoneSelect.d.ts +13 -0
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/serverGroup/configure/wizard/autoScalingPolicy/autoScalingPolicySelector.component.d.ts +1 -0
  8. package/package.json +4 -4
  9. package/src/autoscalingPolicy/IGceAutoscalingPolicy.ts +1 -1
  10. package/src/autoscalingPolicy/components/metricSettings/metricSettings.component.html +85 -28
  11. package/src/autoscalingPolicy/components/metricSettings/metricSettings.component.js +18 -0
  12. package/src/autoscalingPolicy/components/scalingSchedules/scalingSchedules.component.html +84 -0
  13. package/src/autoscalingPolicy/components/scalingSchedules/scalingSchedules.component.js +59 -0
  14. package/src/autoscalingPolicy/components/scalingSchedules/standardTimezone.json +596 -0
  15. package/src/autoscalingPolicy/components/scalingSchedules/timeZoneSelect.tsx +63 -0
  16. package/src/help/gce.help.ts +8 -0
  17. package/src/serverGroup/configure/serverGroup.configure.gce.module.js +6 -0
  18. package/src/serverGroup/configure/serverGroupConfiguration.service.js +6 -0
  19. package/src/serverGroup/configure/wizard/autoScalingPolicy/autoScalingPolicy.html +20 -0
  20. package/src/serverGroup/configure/wizard/autoScalingPolicy/autoScalingPolicySelector.component.html +21 -0
  21. package/src/serverGroup/configure/wizard/autoScalingPolicy/autoScalingPolicySelector.component.js +47 -0
  22. package/src/serverGroup/configure/wizard/autoScalingPolicy/autoScalingPolicySelector.less +15 -0
  23. package/src/serverGroup/configure/wizard/cloneServerGroup.gce.controller.js +21 -3
  24. package/src/serverGroup/configure/wizard/serverGroupWizard.html +3 -0
  25. package/src/serverGroup/details/autoscalingPolicy/autoscalingPolicy.directive.js +88 -83
  26. package/src/serverGroup/details/autoscalingPolicy/modal/GceScaleInControls.tsx +13 -4
  27. package/src/serverGroup/details/autoscalingPolicy/modal/upsertAutoscalingPolicy.modal.controller.js +4 -0
  28. package/src/serverGroup/details/autoscalingPolicy/modal/upsertAutoscalingPolicy.modal.html +7 -0
  29. package/src/serverGroup/details/autoscalingPolicy/modal/upsertAutoscalingPolicy.modal.less +2 -1
@@ -4,6 +4,8 @@ import { module } from 'angular';
4
4
 
5
5
  import { GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_BASICSETTINGS_BASICSETTINGS_COMPONENT } from '../../autoscalingPolicy/components/basicSettings/basicSettings.component';
6
6
  import { GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_METRICSETTINGS_METRICSETTINGS_COMPONENT } from '../../autoscalingPolicy/components/metricSettings/metricSettings.component';
7
+ import { GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_SCALINGSCHEDULES_SCALINGSCHEDULES_COMPONENT } from '../../autoscalingPolicy/components/scalingSchedules/scalingSchedules.component';
8
+ import { GCE_TIMEZONE_SELECT } from '../../autoscalingPolicy/components/scalingSchedules/timeZoneSelect';
7
9
  import { GCE_CACHE_REFRESH } from '../../cache/cacheRefresh.component';
8
10
  import { GCE_IMAGE_SELECT } from '../../image/ImageSelect';
9
11
  import { GOOGLE_INSTANCE_CUSTOM_CUSTOMINSTANCEBUILDER_GCE_SERVICE } from './../../instance/custom/customInstanceBuilder.gce.service';
@@ -13,6 +15,7 @@ import { GCE_ACCELERATOR_CONFIGURER } from './wizard/advancedSettings/GceAcceler
13
15
  import { GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ADVANCEDSETTINGS_ADVANCEDSETTINGSSELECTOR_DIRECTIVE } from './wizard/advancedSettings/advancedSettingsSelector.directive';
14
16
  import { GCE_DISK_CONFIGURER } from './wizard/advancedSettings/diskConfigurer.component';
15
17
  import { GCE_AUTOHEALING_POLICY_SELECTOR } from './wizard/autoHealingPolicy/autoHealingPolicySelector.component';
18
+ import { GCE_AUTOSCALING_POLICY_SELECTOR_COMPONENT } from './wizard/autoScalingPolicy/autoScalingPolicySelector.component';
16
19
  import { GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_CAPACITY_ADVANCEDCAPACITYSELECTOR_COMPONENT } from './wizard/capacity/advancedCapacitySelector.component';
17
20
  import { GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_CAPACITY_SIMPLECAPACITYSELECTOR_COMPONENT } from './wizard/capacity/simpleCapacitySelector.component';
18
21
  import { GCE_CUSTOM_INSTANCE_CONFIGURER } from './wizard/customInstance/customInstanceConfigurer.component';
@@ -30,7 +33,9 @@ export const name = GOOGLE_SERVERGROUP_CONFIGURE_SERVERGROUP_CONFIGURE_GCE_MODUL
30
33
  module(GOOGLE_SERVERGROUP_CONFIGURE_SERVERGROUP_CONFIGURE_GCE_MODULE, [
31
34
  GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_BASICSETTINGS_BASICSETTINGS_COMPONENT,
32
35
  GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_METRICSETTINGS_METRICSETTINGS_COMPONENT,
36
+ GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_SCALINGSCHEDULES_SCALINGSCHEDULES_COMPONENT,
33
37
  GCE_LOAD_BALANCING_POLICY_SELECTOR,
38
+ GCE_AUTOSCALING_POLICY_SELECTOR_COMPONENT,
34
39
  GCE_AUTOHEALING_POLICY_SELECTOR,
35
40
  GOOGLE_INSTANCE_CUSTOM_CUSTOMINSTANCEBUILDER_GCE_SERVICE,
36
41
  GCE_CACHE_REFRESH,
@@ -38,6 +43,7 @@ module(GOOGLE_SERVERGROUP_CONFIGURE_SERVERGROUP_CONFIGURE_GCE_MODULE, [
38
43
  GCE_DISK_CONFIGURER,
39
44
  GCE_ACCELERATOR_CONFIGURER,
40
45
  GCE_IMAGE_SELECT,
46
+ GCE_TIMEZONE_SELECT,
41
47
  GOOGLE_SERVERGROUP_SERVERGROUP_TRANSFORMER,
42
48
  GOOGLE_SERVERGROUP_CONFIGURE_SERVERGROUPCONFIGURATION_SERVICE,
43
49
  GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ADVANCEDSETTINGS_ADVANCEDSETTINGSSELECTOR_DIRECTIVE,
@@ -151,6 +151,12 @@ angular
151
151
  networkReloader = refreshNetworks(command);
152
152
  }
153
153
  }
154
+
155
+ // eslint-disable-next-line no-console
156
+ if (command.autoScalingPolicy) {
157
+ command.enableAutoScaling = true;
158
+ }
159
+
154
160
  if (command.autoHealingPolicy) {
155
161
  command.enableAutoHealing = true;
156
162
  }
@@ -0,0 +1,20 @@
1
+ <ng-form name="autoScalingPolicySubForm">
2
+ <div class="form-group">
3
+ <div class="col-md-3 sm-label-right">
4
+ <b>Enable Autoscaling</b>
5
+ </div>
6
+ <div class="col-md-6 checkbox">
7
+ <label>
8
+ <input type="checkbox" ng-model="command.enableAutoScaling" ng-change="ctrl.onEnableAutoScalingChange()" />
9
+ </label>
10
+ </div>
11
+ </div>
12
+ <div>
13
+ <gce-auto-scaling-policy-Selector-Component
14
+ ng-if="command.enableAutoScaling"
15
+ enabled="command.enableAutoScaling"
16
+ auto-scaling-policy="command.autoscalingPolicy"
17
+ set-auto-scaling-policy="ctrl.setAutoScalingPolicy(autoscalingPolicy)"
18
+ ></gce-auto-scaling-policy-Selector-Component>
19
+ </div>
20
+ </ng-form>
@@ -0,0 +1,21 @@
1
+ <div class="gce-scaling-policy-wizard">
2
+ <h5 class="section-heading">Basic Settings</h5>
3
+ <div class="section-body">
4
+ <gce-autoscaling-policy-basic-settings policy="$ctrl.policy" update-policy="$ctrl.updatePolicy">
5
+ </gce-autoscaling-policy-basic-settings>
6
+ </div>
7
+ <h5 class="section-heading">Metric Types</h5>
8
+ <gce-autoscaling-policy-metric-settings
9
+ show-no-metrics-warning="$ctrl.showNoMetricsWarning"
10
+ policy="$ctrl.policy"
11
+ update-policy="$ctrl.updatePolicy"
12
+ >
13
+ </gce-autoscaling-policy-metric-settings>
14
+ <h5 class="section-heading">Scaling Schedules</h5>
15
+ <div class="section-body">
16
+ <gce-autoscaling-policy-scaling-schedules
17
+ policy="$ctrl.policy"
18
+ update-policy="$ctrl.updatePolicy"
19
+ ></gce-autoscaling-policy-scaling-schedules>
20
+ </div>
21
+ </div>
@@ -0,0 +1,47 @@
1
+ /* eslint-disable no-debugger */
2
+ import { IComponentOptions, module } from 'angular';
3
+ import { cloneDeep } from 'lodash';
4
+
5
+ import { TaskMonitor } from '@spinnaker/core';
6
+
7
+ import { GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_BASICSETTINGS_BASICSETTINGS_COMPONENT } from '../../../../autoscalingPolicy/components/basicSettings/basicSettings.component';
8
+ import { GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_METRICSETTINGS_METRICSETTINGS_COMPONENT } from '../../../../autoscalingPolicy/components/metricSettings/metricSettings.component';
9
+ import { GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_SCALINGSCHEDULES_SCALINGSCHEDULES_COMPONENT } from '../../../../autoscalingPolicy/components/scalingSchedules/scalingSchedules.component';
10
+
11
+ import './autoScalingPolicySelector.less';
12
+
13
+ const gceAutoScalingPolicySelectorComponent = {
14
+ bindings: {
15
+ policy: '<',
16
+ enabled: '<',
17
+ setAutoScalingPolicy: '&',
18
+ autoscalingPolicy: '<',
19
+ },
20
+ templateUrl: require('./autoScalingPolicySelector.component.html'),
21
+ controller: 'gceUpsertAutoscalingPolicyCtrl',
22
+ };
23
+
24
+ export const GCE_AUTOSCALING_POLICY_SELECTOR_COMPONENT = 'spinnaker.gce.autoScalingPolicy.selector.component';
25
+ module(GCE_AUTOSCALING_POLICY_SELECTOR_COMPONENT, [
26
+ GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_BASICSETTINGS_BASICSETTINGS_COMPONENT,
27
+ GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_METRICSETTINGS_METRICSETTINGS_COMPONENT,
28
+ GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_SCALINGSCHEDULES_SCALINGSCHEDULES_COMPONENT,
29
+ ])
30
+ .controller('gceUpsertAutoscalingPolicyCtrl', [
31
+ '$scope',
32
+ function ($scope) {
33
+ var vm = this;
34
+ this.$onInit = function () {
35
+ this.policy = cloneDeep({});
36
+ this.setAutoScalingPolicy({ autoscalingPolicy: this.policy });
37
+
38
+ this.updatePolicy = (updatedPolicy) => {
39
+ $scope.$applyAsync(() => {
40
+ this.policy = updatedPolicy;
41
+ this.setAutoScalingPolicy({ autoscalingPolicy: this.policy });
42
+ });
43
+ };
44
+ };
45
+ },
46
+ ])
47
+ .component('gceAutoScalingPolicySelectorComponent', gceAutoScalingPolicySelectorComponent);
@@ -0,0 +1,15 @@
1
+ .gce-scaling-policy-wizard {
2
+ .error-message {
3
+ margin-top: 4px;
4
+ }
5
+
6
+ input.form-control,
7
+ select.form-control {
8
+ margin-bottom: 2px;
9
+ width: 100%;
10
+ }
11
+
12
+ .schedule-container {
13
+ overflow: hidden;
14
+ }
15
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  import UIROUTER_ANGULARJS from '@uirouter/angularjs';
4
4
  import * as angular from 'angular';
5
- import _ from 'lodash';
5
+ import _, { isEmpty } from 'lodash';
6
6
 
7
7
  import { FirewallLabels, INSTANCE_TYPE_SERVICE, ModalWizard, TaskMonitor } from '@spinnaker/core';
8
8
 
@@ -61,8 +61,9 @@ angular
61
61
  securityGroups: require('./securityGroups/securityGroups.html'),
62
62
  instanceType: require('./instanceType/instanceType.html'),
63
63
  capacity: require('./capacity/capacity.html'),
64
- zones: require('./capacity/zones.html'),
65
64
  autoHealingPolicy: require('./autoHealingPolicy/autoHealingPolicy.html'),
65
+ autoScalingPolicy: require('./autoScalingPolicy/autoScalingPolicy.html'),
66
+ zones: require('./capacity/zones.html'),
66
67
  advancedSettings: require('./advancedSettings/advancedSettings.html'),
67
68
  };
68
69
 
@@ -155,7 +156,8 @@ angular
155
156
  .register({ page: 'capacity', subForm: 'capacitySubForm' })
156
157
  .register({ page: 'zones', subForm: 'zonesSubForm' })
157
158
  .register({ page: 'load-balancers', subForm: 'loadBalancerSubForm' })
158
- .register({ page: 'autohealing-policy', subForm: 'autoHealingPolicySubForm' });
159
+ .register({ page: 'autohealing-policy', subForm: 'autoHealingPolicySubForm' })
160
+ .register({ page: 'autoscaling-policy', subForm: 'autoScalingPolicySubForm' });
159
161
  })
160
162
  .catch((e) => {
161
163
  $log.error('Error generating server group command: ', e);
@@ -261,6 +263,7 @@ angular
261
263
  this.isValid = function () {
262
264
  const selectedZones =
263
265
  $scope.command.selectZones && _.get($scope, 'command.distributionPolicy.zones.length') >= 1;
266
+ const autoScalingPolicy = $scope.command.autoscalingPolicy;
264
267
  return (
265
268
  $scope.command &&
266
269
  ($scope.command.viewState.disableImageSelection || $scope.command.image) &&
@@ -272,6 +275,11 @@ angular
272
275
  $scope.command.capacity.desired !== null &&
273
276
  (!$scope.command.selectZones || selectedZones) &&
274
277
  $scope.form.$valid &&
278
+ (!autoScalingPolicy ||
279
+ (autoScalingPolicy &&
280
+ (!isEmpty(autoScalingPolicy.cpuUtilization) ||
281
+ !isEmpty(autoScalingPolicy.customMetricUtilizations) ||
282
+ !isEmpty(autoScalingPolicy.loadBalancingUtilization)))) &&
275
283
  ModalWizard.isComplete()
276
284
  );
277
285
  };
@@ -431,6 +439,16 @@ angular
431
439
  $scope.command.autoHealingPolicy = autoHealingPolicy;
432
440
  };
433
441
 
442
+ this.onEnableAutoScalingChange = function () {
443
+ // Prevent empty auto-scaling policies from being overwritten by those of their ancestors
444
+ $scope.command.overwriteAncestorAutoScalingPolicy =
445
+ $scope.command.autoscalingPolicy != null && $scope.command.enableAutoScaling === false;
446
+ };
447
+
448
+ this.setAutoScalingPolicy = function (autoScalingPolicy) {
449
+ $scope.command.autoscalingPolicy = autoScalingPolicy;
450
+ };
451
+
434
452
  this.cancel = function () {
435
453
  $uibModalInstance.dismiss();
436
454
  };
@@ -22,6 +22,9 @@
22
22
  <v2-wizard-page key="capacity" label="Capacity" mark-complete-on-view="false">
23
23
  <ng-include src="pages.capacity"></ng-include>
24
24
  </v2-wizard-page>
25
+ <v2-wizard-page key="autoscaling-policy" label="Autoscaling Policy" mark-complete-on-view="false">
26
+ <ng-include src="pages.autoScalingPolicy"></ng-include>
27
+ </v2-wizard-page>
25
28
  <v2-wizard-page key="autohealing-policy" label="Autohealing Policy" mark-complete-on-view="false">
26
29
  <ng-include src="pages.autoHealingPolicy"></ng-include>
27
30
  </v2-wizard-page>
@@ -6,9 +6,9 @@ import ANGULAR_UI_BOOTSTRAP from 'angular-ui-bootstrap';
6
6
  import { ConfirmationModalService, SETTINGS } from '@spinnaker/core';
7
7
 
8
8
  import { GOOGLE_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_WRITE_SERVICE } from './../../../autoscalingPolicy/autoscalingPolicy.write.service';
9
+ import { GCE_AUTOSCALING_POLICY_SELECTOR_COMPONENT } from '../../configure/wizard/autoScalingPolicy/autoScalingPolicySelector.component';
9
10
  import { GCEProviderSettings } from '../../../gce.settings';
10
11
  import { GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_MODAL_UPSERTAUTOSCALINGPOLICY_MODAL_CONTROLLER } from './modal/upsertAutoscalingPolicy.modal.controller';
11
-
12
12
  export const GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_DIRECTIVE =
13
13
  'spinnaker.gce.instance.details.scalingPolicy.directive';
14
14
  export const name = GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_DIRECTIVE; // for backwards compatibility
@@ -16,6 +16,7 @@ module(GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_DIRECTIVE,
16
16
  ANGULAR_UI_BOOTSTRAP,
17
17
  GOOGLE_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_WRITE_SERVICE,
18
18
  GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_MODAL_UPSERTAUTOSCALINGPOLICY_MODAL_CONTROLLER,
19
+ GCE_AUTOSCALING_POLICY_SELECTOR_COMPONENT,
19
20
  ]).component('gceAutoscalingPolicy', {
20
21
  bindings: {
21
22
  policy: '=',
@@ -27,106 +28,110 @@ module(GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_DIRECTIVE,
27
28
  '$uibModal',
28
29
  'gceAutoscalingPolicyWriter',
29
30
  function ($uibModal, gceAutoscalingPolicyWriter) {
30
- const policy = this.policy;
31
+ var scope = this;
32
+ scope.$onInit = function () {
33
+ const policy = scope.policy;
31
34
 
32
- policy.bases = [];
35
+ policy.bases = [];
33
36
 
34
- if (policy.cpuUtilization) {
35
- const basis = {
36
- description: 'CPU Usage',
37
- helpKey: 'gce.serverGroup.autoscaling.targetCPUUsage',
38
- };
37
+ if (policy.cpuUtilization) {
38
+ const basis = {
39
+ description: 'CPU Usage',
40
+ helpKey: 'gce.serverGroup.autoscaling.targetCPUUsage',
41
+ };
39
42
 
40
- if (policy.cpuUtilization.utilizationTarget) {
41
- basis.targets = [Math.round(policy.cpuUtilization.utilizationTarget * 100) + '%'];
43
+ if (policy.cpuUtilization.utilizationTarget) {
44
+ basis.targets = [Math.round(policy.cpuUtilization.utilizationTarget * 100) + '%'];
45
+ }
46
+
47
+ policy.bases.push(basis);
42
48
  }
43
49
 
44
- policy.bases.push(basis);
45
- }
50
+ if (policy.loadBalancingUtilization) {
51
+ const basis = {
52
+ description: 'HTTP Load Balancing Usage',
53
+ helpKey: 'gce.serverGroup.autoscaling.targetHTTPLoadBalancingUsage',
54
+ };
46
55
 
47
- if (policy.loadBalancingUtilization) {
48
- const basis = {
49
- description: 'HTTP Load Balancing Usage',
50
- helpKey: 'gce.serverGroup.autoscaling.targetHTTPLoadBalancingUsage',
51
- };
56
+ if (policy.loadBalancingUtilization.utilizationTarget) {
57
+ basis.targets = [Math.round(policy.loadBalancingUtilization.utilizationTarget * 100) + '%'];
58
+ }
52
59
 
53
- if (policy.loadBalancingUtilization.utilizationTarget) {
54
- basis.targets = [Math.round(policy.loadBalancingUtilization.utilizationTarget * 100) + '%'];
60
+ policy.bases.push(basis);
55
61
  }
56
62
 
57
- policy.bases.push(basis);
58
- }
63
+ if (policy.customMetricUtilizations) {
64
+ const basis = {
65
+ description: policy.customMetricUtilizations.length > 1 ? 'Monitoring Metrics' : 'Monitoring Metric',
66
+ helpKey: 'gce.serverGroup.autoscaling.targetMetric',
67
+ };
59
68
 
60
- if (policy.customMetricUtilizations) {
61
- const basis = {
62
- description: policy.customMetricUtilizations.length > 1 ? 'Monitoring Metrics' : 'Monitoring Metric',
63
- helpKey: 'gce.serverGroup.autoscaling.targetMetric',
64
- };
69
+ if (policy.customMetricUtilizations.length > 0) {
70
+ basis.targets = [];
71
+ policy.customMetricUtilizations.forEach((metric) => {
72
+ let target = metric.metric + ': ' + metric.utilizationTarget;
65
73
 
66
- if (policy.customMetricUtilizations.length > 0) {
67
- basis.targets = [];
68
- policy.customMetricUtilizations.forEach((metric) => {
69
- let target = metric.metric + ': ' + metric.utilizationTarget;
74
+ if (metric.utilizationTargetType === 'DELTA_PER_SECOND') {
75
+ target += '/sec';
76
+ } else if (metric.utilizationTargetType === 'DELTA_PER_MINUTE') {
77
+ target += '/min';
78
+ }
70
79
 
71
- if (metric.utilizationTargetType === 'DELTA_PER_SECOND') {
72
- target += '/sec';
73
- } else if (metric.utilizationTargetType === 'DELTA_PER_MINUTE') {
74
- target += '/min';
75
- }
80
+ basis.targets.push(target);
81
+ });
82
+ }
76
83
 
77
- basis.targets.push(target);
78
- });
84
+ policy.bases.push(basis);
79
85
  }
80
86
 
81
- policy.bases.push(basis);
82
- }
83
-
84
- this.scaleInControlsConfigured =
85
- policy.scaleInControl &&
86
- policy.scaleInControl.timeWindowSec &&
87
- policy.scaleInControl.maxScaledInReplicas &&
88
- (policy.scaleInControl.maxScaledInReplicas.percent || policy.scaleInControl.maxScaledInReplicas.fixed);
89
-
90
- if (this.scaleInControlsConfigured) {
91
- this.maxScaledInReplicasMessage = policy.scaleInControl.maxScaledInReplicas.percent
92
- ? `${policy.scaleInControl.maxScaledInReplicas.percent}%`
93
- : `${policy.scaleInControl.maxScaledInReplicas.fixed}`;
94
-
95
- this.timeWindowSecMessage = `${policy.scaleInControl.timeWindowSec} seconds`;
96
- }
97
-
98
- this.predictiveAutoscalingEnabled =
99
- GCEProviderSettings.feature.predictiveAutoscaling &&
100
- policy.cpuUtilization &&
101
- policy.cpuUtilization.predictiveMethod;
102
-
103
- this.editPolicy = () => {
104
- $uibModal.open({
105
- templateUrl: require('./modal/upsertAutoscalingPolicy.modal.html'),
106
- controller: 'gceUpsertAutoscalingPolicyModalCtrl',
107
- controllerAs: 'ctrl',
108
- size: 'lg',
109
- resolve: {
110
- policy: () => this.policy,
111
- application: () => this.application,
112
- serverGroup: () => this.serverGroup,
113
- },
114
- });
115
- };
87
+ scope.scaleInControlsConfigured =
88
+ policy.scaleInControl &&
89
+ policy.scaleInControl.timeWindowSec &&
90
+ policy.scaleInControl.maxScaledInReplicas &&
91
+ (policy.scaleInControl.maxScaledInReplicas.percent || policy.scaleInControl.maxScaledInReplicas.fixed);
116
92
 
117
- this.deletePolicy = () => {
118
- const taskMonitor = {
119
- application: this.application,
120
- title: `Deleting autoscaler for ${this.serverGroup.name}`,
93
+ if (scope.scaleInControlsConfigured) {
94
+ scope.maxScaledInReplicasMessage = policy.scaleInControl.maxScaledInReplicas.percent
95
+ ? `${policy.scaleInControl.maxScaledInReplicas.percent}%`
96
+ : `${policy.scaleInControl.maxScaledInReplicas.fixed}`;
97
+
98
+ scope.timeWindowSecMessage = `${policy.scaleInControl.timeWindowSec} seconds`;
99
+ }
100
+
101
+ scope.predictiveAutoscalingEnabled =
102
+ GCEProviderSettings.feature.predictiveAutoscaling &&
103
+ policy.cpuUtilization &&
104
+ policy.cpuUtilization.predictiveMethod;
105
+
106
+ scope.editPolicy = () => {
107
+ $uibModal.open({
108
+ templateUrl: require('./modal/upsertAutoscalingPolicy.modal.html'),
109
+ controller: 'gceUpsertAutoscalingPolicyModalCtrl',
110
+ controllerAs: 'ctrl',
111
+ size: 'lg',
112
+ resolve: {
113
+ policy: () => scope.policy,
114
+ application: () => scope.application,
115
+ serverGroup: () => scope.serverGroup,
116
+ },
117
+ });
121
118
  };
122
119
 
123
- ConfirmationModalService.confirm({
124
- header: `Really delete autoscaler for ${this.serverGroup.name}?`,
125
- buttonText: 'Delete autoscaler',
126
- account: this.serverGroup.account,
127
- taskMonitorConfig: taskMonitor,
128
- submitMethod: () => gceAutoscalingPolicyWriter.deleteAutoscalingPolicy(this.application, this.serverGroup),
129
- });
120
+ scope.deletePolicy = () => {
121
+ const taskMonitor = {
122
+ application: scope.application,
123
+ title: `Deleting autoscaler for ${scope.serverGroup.name}`,
124
+ };
125
+
126
+ ConfirmationModalService.confirm({
127
+ header: `Really delete autoscaler for ${scope.serverGroup.name}?`,
128
+ buttonText: 'Delete autoscaler',
129
+ account: scope.serverGroup.account,
130
+ taskMonitorConfig: taskMonitor,
131
+ submitMethod: () =>
132
+ gceAutoscalingPolicyWriter.deleteAutoscalingPolicy(scope.application, scope.serverGroup),
133
+ });
134
+ };
130
135
  };
131
136
  },
132
137
  ],
@@ -35,10 +35,19 @@ const defaultScaleInControl: IGceScaleInControl = {
35
35
 
36
36
  function GceScaleInControls({ policy, updatePolicy }: IGceScaleInControlsProps) {
37
37
  function updateScaleInControl(scaleInControl: IGceScaleInControl) {
38
- updatePolicy({
39
- ...policy,
40
- scaleInControl,
41
- });
38
+ const scaleInControlExist = Object.keys(scaleInControl).length;
39
+ if (scaleInControlExist) {
40
+ updatePolicy({
41
+ ...policy,
42
+ scaleInControl,
43
+ });
44
+ } else {
45
+ const updatedPolicy: any = policy;
46
+ delete updatedPolicy['scaleInControl'];
47
+ updatePolicy({
48
+ ...updatedPolicy,
49
+ });
50
+ }
42
51
  }
43
52
 
44
53
  function getMaxReplicasUnit(): maxReplicasUnit {
@@ -4,9 +4,12 @@ import { module } from 'angular';
4
4
  import { cloneDeep } from 'lodash';
5
5
 
6
6
  import { TaskMonitor } from '@spinnaker/core';
7
+
7
8
  import { GOOGLE_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_WRITE_SERVICE } from '../../../../autoscalingPolicy/autoscalingPolicy.write.service';
8
9
  import { GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_BASICSETTINGS_BASICSETTINGS_COMPONENT } from '../../../../autoscalingPolicy/components/basicSettings/basicSettings.component';
9
10
  import { GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_METRICSETTINGS_METRICSETTINGS_COMPONENT } from '../../../../autoscalingPolicy/components/metricSettings/metricSettings.component';
11
+ import { GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_SCALINGSCHEDULES_SCALINGSCHEDULES_COMPONENT } from '../../../../autoscalingPolicy/components/scalingSchedules/scalingSchedules.component';
12
+ import { GOOGLE_SERVERGROUP_CONFIGURE_SERVERGROUP_CONFIGURE_GCE_MODULE } from '../../../configure/serverGroup.configure.gce.module';
10
13
 
11
14
  import './upsertAutoscalingPolicy.modal.less';
12
15
 
@@ -17,6 +20,7 @@ module(GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_MODAL_UPSERTAUTOSCALINGPOLIC
17
20
  GOOGLE_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_WRITE_SERVICE,
18
21
  GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_BASICSETTINGS_BASICSETTINGS_COMPONENT,
19
22
  GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_METRICSETTINGS_METRICSETTINGS_COMPONENT,
23
+ GOOGLE_AUTOSCALINGPOLICY_COMPONENTS_SCALINGSCHEDULES_SCALINGSCHEDULES_COMPONENT,
20
24
  ]).controller('gceUpsertAutoscalingPolicyModalCtrl', [
21
25
  'policy',
22
26
  'application',
@@ -17,6 +17,13 @@
17
17
  update-policy="ctrl.updatePolicy"
18
18
  >
19
19
  </gce-autoscaling-policy-metric-settings>
20
+ <h4 class="section-heading">Scaling Schedules</h4>
21
+ <div class="section-body">
22
+ <gce-autoscaling-policy-scaling-schedules
23
+ policy="ctrl.policy"
24
+ update-policy="ctrl.updatePolicy"
25
+ ></gce-autoscaling-policy-scaling-schedules>
26
+ </div>
20
27
  </div>
21
28
  </ng-form>
22
29
  <div class="modal-footer">
@@ -3,7 +3,8 @@
3
3
  margin-top: 4px;
4
4
  }
5
5
 
6
- input.form-control {
6
+ input.form-control,
7
+ select.form-control {
7
8
  margin-bottom: 2px;
8
9
  width: 100%;
9
10
  }