Skip to content

Commit

Permalink
feat(gce): Add support for target shape on regional migs. (#8089)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Duftler committed Mar 26, 2020
1 parent 81d56e9 commit 528198a
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_LOCATION_BASICSETTINGS_CONTROLLER }
import { GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_SECURITYGROUPS_SECURITYGROUPSREMOVED_DIRECTIVE } from './wizard/securityGroups/securityGroupsRemoved.directive';
import { GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_SECURITYGROUPS_SECURITYGROUPSELECTOR_DIRECTIVE } from './wizard/securityGroups/securityGroupSelector.directive';
import { GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ZONES_REGIONALSELECTOR_DIRECTIVE } from './wizard/zones/regionalSelector.directive';
import { GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ZONES_TARGETSHAPESELECTOR_DIRECTIVE } from './wizard/zones/targetShapeSelector.directive';
import { GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ZONES_ZONESELECTOR_DIRECTIVE } from './wizard/zones/zoneSelector.directive';

export const GOOGLE_SERVERGROUP_CONFIGURE_SERVERGROUP_CONFIGURE_GCE_MODULE = 'spinnaker.serverGroup.configure.gce';
Expand All @@ -47,5 +48,6 @@ module(GOOGLE_SERVERGROUP_CONFIGURE_SERVERGROUP_CONFIGURE_GCE_MODULE, [
GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_SECURITYGROUPS_SECURITYGROUPSREMOVED_DIRECTIVE,
GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_SECURITYGROUPS_SECURITYGROUPSELECTOR_DIRECTIVE,
GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ZONES_REGIONALSELECTOR_DIRECTIVE,
GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ZONES_TARGETSHAPESELECTOR_DIRECTIVE,
GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ZONES_ZONESELECTOR_DIRECTIVE,
]);
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,10 @@ angular
enableTraffic: true,
cloudProvider: 'gce',
selectedProvider: 'gce',
distributionPolicy: serverGroup.distributionPolicy,
distributionPolicy: {
zones: serverGroup.distributionPolicy ? serverGroup.distributionPolicy.zones : [],
targetShape: serverGroup.distributionPolicy ? serverGroup.distributionPolicy.targetShape : null,
},
selectZones: serverGroup.selectZones,
source: {
account: serverGroup.account,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ angular
let networkReloader = $q.when(null);
let healthCheckReloader = $q.when(null);
backingData.filtered = {};
backingData.distributionPolicyTargetShapes = getDistributionPolicyTargetShapes();
command.backingData = backingData;
configureImages(command);

Expand Down Expand Up @@ -148,6 +149,17 @@ angular
});
}

function getDistributionPolicyTargetShapes() {
return ['ANY', 'EVEN'];
}

function configureDistributionPolicyTargetShape(command) {
const accountDetails = command.backingData.credentialsKeyedByAccount[command.credentials];
if (accountDetails.computeVersion === 'ALPHA' && !command.distributionPolicy.targetShape) {
command.distributionPolicy.targetShape = 'EVEN';
}
}

function loadAllImages(account) {
return GceImageReader.findImages({
account: account,
Expand Down Expand Up @@ -598,6 +610,7 @@ angular
const defaults = GCEProviderSettings.defaults;
if (command.regional) {
command.zone = null;
configureDistributionPolicyTargetShape(command);
} else if (!command.zone) {
if (command.region === defaults.region) {
command.zone = defaults.zone;
Expand Down Expand Up @@ -661,6 +674,8 @@ angular

angular.extend(result.dirty, configureHealthChecks(command).dirty);
angular.extend(result.dirty, configureInstanceTypes(command).dirty);

configureDistributionPolicyTargetShape(command);
} else {
command.region = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface IZoneToAcceleratorTypesMap {
export interface IGceAcceleratorCommand {
backingData: any;
credentials: string;
distributionPolicy: { zones: string[] };
distributionPolicy: { zones: string[]; targetShape?: string };
regional: boolean;
selectZones: boolean;
zone: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<div class="container-fluid form-horizontal">
<gce-regional-selector command="command"></gce-regional-selector>
<gce-zone-selector command="command"></gce-zone-selector>
<gce-target-shape-selector command="command"></gce-target-shape-selector>
</div>
</ng-form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div
class="form-group"
ng-if="vm.command.regional && vm.command.backingData.credentialsKeyedByAccount[vm.command.credentials].computeVersion === 'ALPHA'"
>
<div class="col-md-3 sm-label-right"><b>Target Shape</b></div>
<div class="col-md-3">
<ui-select ng-model="vm.command.distributionPolicy.targetShape" class="form-control input-sm" required>
<ui-select-match placeholder="Select...">{{$select.selected}}</ui-select-match>
<ui-select-choices
repeat="targetShape in vm.command.backingData.distributionPolicyTargetShapes | filter: $select.search"
>
<span ng-bind-html="targetShape | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { module, noop } from 'angular';

export const GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ZONES_TARGETSHAPESELECTOR_DIRECTIVE =
'spinnaker.google.serverGroup.configure.wizard.capacity.targetShape.directive';

module(GOOGLE_SERVERGROUP_CONFIGURE_WIZARD_ZONES_TARGETSHAPESELECTOR_DIRECTIVE, []).directive(
'gceTargetShapeSelector',
function() {
return {
restrict: 'E',
templateUrl: require('./targetShapeSelector.directive.html'),
scope: {},
bindToController: {
command: '=',
},
controllerAs: 'vm',
controller: noop,
};
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as angular from 'angular';
import _ from 'lodash';

import {
AccountService,
ConfirmationModalService,
ClusterTargetBuilder,
FirewallLabels,
Expand Down Expand Up @@ -156,6 +157,7 @@ angular
augmentTagsWithHelp();
configureEntityTagTargets();
processLabels();
retrieveComputeVersion(details.account);
} else {
autoClose();
}
Expand Down Expand Up @@ -273,6 +275,12 @@ angular
}
};

const retrieveComputeVersion = accountId => {
AccountService.getAccountDetails(accountId).then(accountDetails => {
this.serverGroup.computeVersion = accountDetails.computeVersion;
});
};

const processLabels = () => {
if (!_.size(this.serverGroup.instanceTemplateLabels)) {
delete this.serverGroup.instanceTemplateLabels;
Expand Down Expand Up @@ -503,6 +511,10 @@ angular
return null;
};

this.isAlphaListed = () => {
return this.serverGroup.computeVersion === 'ALPHA';
};

const configureEntityTagTargets = () => {
this.entityTagTargets = ClusterTargetBuilder.buildClusterTargets(this.serverGroup);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ <h4 class="text-center" ng-if="ctrl.serverGroup.isDisabled">[SERVER GROUP IS DIS
<li ng-repeat="zone in ctrl.serverGroup.zones">{{zone}}</li>
</ul>
</dd>
<dt ng-if="ctrl.serverGroup.regional && ctrl.isAlphaListed()">Target Shape</dt>
<dd ng-if="ctrl.serverGroup.regional && ctrl.isAlphaListed()">
{{ctrl.serverGroup.distributionPolicy.targetShape}}
</dd>
</dl>
</collapsible-section>
<collapsible-section heading="Size" expanded="true">
Expand Down

0 comments on commit 528198a

Please sign in to comment.