Skip to content

Commit

Permalink
Merge pull request #1773 from duftler/google-avail-policies
Browse files Browse the repository at this point in the history
Add support for preemptibility, automaticRestart and onHostMaintenanc…
  • Loading branch information
Matt Duftler committed Dec 3, 2015
2 parents 5232452 + c6abd5f commit 28d861d
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 20 deletions.
3 changes: 3 additions & 0 deletions app/scripts/modules/core/help/helpContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ module.exports = angular.module('spinnaker.core.help.contents', [])
'gce.serverGroup.capacity': 'The number of instances that the instance group manager will attempt to maintain. Deleting or abandoning instances will affect this number, as will resizing the group.',
'gce.serverGroup.customMetadata.load-balancer-names': 'This field is used to "remember" what load balancers this server group is associated with, even if the instances are deregistered.',
'gce.serverGroup.customMetadata.startup-script': 'This script will run automatically on every boot.',
'gce.serverGroup.preemptibility': 'A preemptible VM costs much less, but lasts only 24 hours. It can be terminated sooner due to system demands.',
'gce.serverGroup.automaticRestart': 'Compute Engine can automatically restart VM instances if they are terminated for non-user-initiated reasons (maintenance event, hardware failure, software failure, etc.).',
'gce.serverGroup.onHostMaintenance': 'When Compute Engine performs periodic infrastructure maintenance it can migrate your VM instances to other hardware without downtime.',
'gce.serverGroup.securityGroups.implicit': 'Firewall rules with no target tags defined will permit incoming connections that match the ingress rules to all instances in the network.',
'pipeline.config.checkPreconditions.failPipeline': '' +
'<p><strong>Checked</strong> - the overall pipeline will fail whenever this precondition is false.</p>' +
Expand Down
18 changes: 9 additions & 9 deletions app/scripts/modules/google/instance/details/instanceDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,6 @@ <h3 select-on-dbl-click>
</li>
</ul>
</collapsible-section>
<collapsible-section heading="Tags">
<div ng-if="!instance.tags.items.length">No tags associated with this instance</div>
<dl ng-if="instance.tags.items.length">
<dd ng-repeat="tag in instance.tags.items">
{{tag}}
<help-field content="{{instance.tags.helpMap[tag]}}"></help-field>
</dd>
</dl>
</collapsible-section>
<collapsible-section heading="Custom Metadata">
<div ng-if="!instance.metadata.items.length">No custom metadata associated with this instance</div>
<dl ng-if="instance.metadata.items.length">
Expand All @@ -170,6 +161,15 @@ <h3 select-on-dbl-click>
<dd ng-repeat-end>{{metadata.value.length > 90 ? metadata.value.substring(0, 90) + "..." : metadata.value}}</dd>
</dl>
</collapsible-section>
<collapsible-section heading="Tags">
<div ng-if="!instance.tags.items.length">No tags associated with this instance</div>
<dl ng-if="instance.tags.items.length">
<dd ng-repeat="tag in instance.tags.items">
{{tag}}
<help-field content="{{instance.tags.helpMap[tag]}}"></help-field>
</dd>
</dl>
</collapsible-section>
<collapsible-section heading="SSH" ng-if="!instance.notFound">
<dl>
<dt ng-if="instance.sshLink">SSH into this instance:</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ module.exports = angular.module('spinnaker.gce.serverGroupCommandBuilder.service
}
}

function populateAvailabilityPolicies(scheduling, command) {
if (scheduling) {
command.preemptible = scheduling.preemptible;
command.automaticRestart = scheduling.automaticRestart;
command.onHostMaintenance = scheduling.onHostMaintenance;
} else {
command.preemptible = false;
command.automaticRestart = true;
command.onHostMaintenance = 'MIGRATE';
}
}

function populateCustomMetadata(metadataItems, command) {
if (metadataItems) {
if (angular.isArray(metadataItems)) {
Expand Down Expand Up @@ -180,6 +192,9 @@ module.exports = angular.module('spinnaker.gce.serverGroupCommandBuilder.service
localSSDCount: 1,
instanceMetadata: [],
tags: [],
preemptible: false,
automaticRestart: true,
onHostMaintenance: 'MIGRATE',
authScopes: [
'cloud.useraccounts.readonly',
'devstorage.read_only',
Expand Down Expand Up @@ -271,6 +286,7 @@ module.exports = angular.module('spinnaker.gce.serverGroupCommandBuilder.service
});
command.viewState.imageId = serverGroup.launchConfig.imageId;
return determineInstanceCategoryFromInstanceType(command).then(function() {
populateAvailabilityPolicies(serverGroup.launchConfig.instanceTemplate.properties.scheduling, command);
populateCustomMetadata(serverGroup.launchConfig.instanceTemplate.properties.metadata.items, command);
populateTags(serverGroup.launchConfig.instanceTemplate.properties.tags, command);
populateAuthScopes(serverGroup.launchConfig.instanceTemplate.properties.serviceAccounts, command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
</tr>
</tfoot>
</table>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<table class="table table-condensed packed tags">
<b>Tags</b>
<tbody>
Expand All @@ -83,6 +87,60 @@
</table>
</div>
</div>
<div class="form-group">
<div class="col-md-5 sm-label-left">
<b>Preemptibility</b>
<help-field key="gce.serverGroup.preemptibility"></help-field>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.preemptible" ng-value="false" id="preemptibleFalse"/>
Off
</label>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.preemptible" ng-value="true" id="preemptibleTrue" ng-change="advancedSettingsCtrl.setPreemptible()"/>
On
</label>
</div>
</div>
<div class="form-group">
<div class="col-md-5 sm-label-left">
<b>Automatic Restart</b>
<help-field key="gce.serverGroup.automaticRestart"></help-field>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.automaticRestart" ng-value="false" id="automaticRestartFalse"/>
Off
</label>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.automaticRestart" ng-value="true" id="automaticRestartTrue"/>
On
</label>
</div>
</div>
<div class="form-group">
<div class="col-md-5 sm-label-left">
<b>On Host Maintenance</b>
<help-field key="gce.serverGroup.onHostMaintenance"></help-field>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.onHostMaintenance" ng-value="'MIGRATE'" id="onHostMaintenanceMigrate"/>
Migrate
</label>
</div>
<div class="col-md-2 radio">
<label>
<input type="radio" ng-model="command.onHostMaintenance" ng-value="'TERMINATE'" id="onHostMaintenanceTerminate"/>
Terminate
</label>
</div>
</div>
<div class="form-group">
<div class="col-md-5 sm-label-left">
<b>Service Account Auth Scopes</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ module.exports = angular
$scope.command.tags.splice(index, 1);
};

this.setPreemptible = function() {
$scope.command.automaticRestart = false;
$scope.command.onHostMaintenance = 'TERMINATE';
};
}).name;
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<form name="form" class="container-fluid form-horizontal" ng-controller="gceServerGroupAdvancedSettingsCtrl as settingsCtrl" novalidate>
<div class="modal-body">
<gce-server-group-advanced-settings-selector command="command"></gce-server-group-advanced-settings-selector>
<div class="form-group">
<div class="form-group" ng-if="application.attributes.platformHealthOnlyShowOverride">
<div class="col-md-5 sm-label-left"><b>Task Completion</b></div>
<div class="col-md-6">
<platform-health-override ng-if="application.attributes.platformHealthOnlyShowOverride"
command="command"
<platform-health-override command="command"
platform-health-type="'Google'">
</platform-health-override>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module.exports = angular.module('spinnaker.serverGroup.details.gce.controller',

findStartupScript();
prepareDiskDescriptions();
prepareAvailabilityPolicies();
prepareAuthScopes();
augmentTagsWithHelp();
} else {
Expand Down Expand Up @@ -139,6 +140,18 @@ module.exports = angular.module('spinnaker.serverGroup.details.gce.controller',
}
}

function prepareAvailabilityPolicies() {
if (_.has($scope.serverGroup, 'launchConfig.instanceTemplate.properties.scheduling')) {
let scheduling = $scope.serverGroup.launchConfig.instanceTemplate.properties.scheduling;

$scope.serverGroup.availabilityPolicies = {
preemptibility: scheduling.preemptible ? "On" : "Off",
automaticRestart: scheduling.automaticRestart ? "On" : "Off",
onHostMaintenance: scheduling.onHostMaintenance === "MIGRATE" ? "Migrate" : "Terminate",
};
}
}

function prepareAuthScopes() {
if (_.has($scope.serverGroup, 'launchConfig.instanceTemplate.properties.serviceAccounts')) {
let serviceAccounts = $scope.serverGroup.launchConfig.instanceTemplate.properties.serviceAccounts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ <h4 class="text-center" ng-if="serverGroup.isDisabled">[SERVER GROUP IS DISABLED
</li>
</ul>
</collapsible-section>
<collapsible-section heading="Custom Metadata">
<div ng-if="!serverGroup.launchConfig.instanceTemplate.properties.metadata.items.length">No custom metadata associated with this server group</div>
<dl ng-if="serverGroup.launchConfig.instanceTemplate.properties.metadata.items.length">
<dt ng-repeat-start="metadata in serverGroup.launchConfig.instanceTemplate.properties.metadata.items">
{{metadata.key}}
<help-field key="gce.serverGroup.customMetadata.{{metadata.key}}"></help-field>
</dt>
<dd ng-repeat-end>{{metadata.value.length > 90 ? metadata.value.substring(0, 90) + "..." : metadata.value}}</dd>
</dl>
</collapsible-section>
<collapsible-section heading="Tags">
<div ng-if="!serverGroup.launchConfig.instanceTemplate.properties.tags.items.length">No tags associated with this server group</div>
<dl ng-if="serverGroup.launchConfig.instanceTemplate.properties.tags.items.length">
Expand All @@ -185,15 +195,25 @@ <h4 class="text-center" ng-if="serverGroup.isDisabled">[SERVER GROUP IS DISABLED
</dd>
</dl>
</collapsible-section>
<collapsible-section heading="Custom Metadata">
<div ng-if="!serverGroup.launchConfig.instanceTemplate.properties.metadata.items.length">No custom metadata associated with this server group</div>
<dl ng-if="serverGroup.launchConfig.instanceTemplate.properties.metadata.items.length">
<dt ng-repeat-start="metadata in serverGroup.launchConfig.instanceTemplate.properties.metadata.items">
{{metadata.key}}
<help-field key="gce.serverGroup.customMetadata.{{metadata.key}}"></help-field>
<collapsible-section heading="Availability Policies">
<div ng-if="!serverGroup.availabilityPolicies">No availability policies associated with this server group</div>
<div ng-if="serverGroup.availabilityPolicies">
<dt>
Preemptibility
<help-field key="gce.serverGroup.preemptibility"></help-field>
</dt>
<dd ng-repeat-end>{{metadata.value.length > 90 ? metadata.value.substring(0, 90) + "..." : metadata.value}}</dd>
</dl>
<dd>{{serverGroup.availabilityPolicies.preemptibility}}</dd>
<dt>
Automatic Restart
<help-field key="gce.serverGroup.automaticRestart"></help-field>
</dt>
<dd>{{serverGroup.availabilityPolicies.automaticRestart}}</dd>
<dt>
On Host Maintenance
<help-field key="gce.serverGroup.onHostMaintenance"></help-field>
</dt>
<dd>{{serverGroup.availabilityPolicies.onHostMaintenance}}</dd>
</div>
</collapsible-section>
<collapsible-section heading="Package">
<dl ng-class="InsightFilterStateModel.filtersExpanded ? '' : 'dl-horizontal dl-wide'"
Expand Down

0 comments on commit 28d861d

Please sign in to comment.