Skip to content

Bug 1462067 - Give option to delete pod without grace period #1727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/scripts/directives/deleteLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ angular.module("openshiftConsole")

// Checkbox value
scope.options = {
deleteHPAs: true
deleteHPAs: true,
deleteImmediately: false
};

var showAlert = function(alert) {
Expand Down Expand Up @@ -141,11 +142,16 @@ angular.module("openshiftConsole")
var formattedResource = typeDisplayName + ' ' + "\'" + (scope.displayName ? scope.displayName : resourceName) + "\'";
var context = (scope.kind === 'Project') ? {} : {namespace: scope.projectName};

var deleteOptions = {};
if (scope.options.deleteImmediately) {
deleteOptions.gracePeriodSeconds = 0;
}

DataService.delete({
resource: APIService.kindToResource(kind),
// group or undefined
group: scope.group
}, resourceName, context)
}, resourceName, context, deleteOptions)
.then(function() {
NotificationsService.addNotification({
type: "success",
Expand Down
2 changes: 1 addition & 1 deletion app/styles/_core.less
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ a.disabled-link {
.word-break();
}
p {
font-size: @font-size-large + 1;
font-size: @font-size-large;
}
.help-block {
margin-top: 0px;
Expand Down
33 changes: 23 additions & 10 deletions app/views/modals/delete-resource.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ <h1>Are you sure you want to delete the {{typeDisplayName || (kind | humanizeKin
</p>
</div>

<!--
If this is a pod, give the user the option of deleting it immediately with no grace period.
-->
<div ng-if="kind === 'Pod'" class="checkbox">
<label>
<input type="checkbox" ng-model="options.deleteImmediately">
Delete pod immediately without waiting for the processes to terminate gracefully
</label>
</div>

<!--
If this is a deployment config or replication controller with associated HPAs, prompt to
delete the HPAs as well.
Expand All @@ -61,17 +71,20 @@ <h1>Are you sure you want to delete the {{typeDisplayName || (kind | humanizeKin
It is recommended you delete the autoscalers with the resource they scale.
</span>
</p>
<label>
<input type="checkbox" ng-model="options.deleteHPAs">
Delete
<span ng-if="hpaList.length === 1">
Horizontal Pod Autoscaler '<strong>{{hpaList[0].metadata.name}}</strong>'
</span>
<span ng-if="hpaList.length > 1">
{{hpaList.length}} associated Horizontal Pod Autoscalers
</span>
</label>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="options.deleteHPAs">
Delete
<span ng-if="hpaList.length === 1">
Horizontal Pod Autoscaler '<strong>{{hpaList[0].metadata.name}}</strong>'
</span>
<span ng-if="hpaList.length > 1">
{{hpaList.length}} associated Horizontal Pod Autoscalers
</span>
</label>
</div>
</div>

</div>
<div class="modal-footer">
<button ng-disabled="typeNameToConfirm && confirmName !== resourceName && confirmName !== displayName" class="btn btn-lg btn-danger" type="submit" ng-click="delete();">Delete</button>
Expand Down
9 changes: 5 additions & 4 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8786,7 +8786,8 @@ return angular.isDefined(b.buttonOnly) ? "views/directives/delete-button.html" :
replace:!0,
link:function(d, e, k) {
"Project" === k.kind && (d.isProject = !0), d.options = {
deleteHPAs:!0
deleteHPAs:!0,
deleteImmediately:!1
};
var l = function(a) {
d.stayOnCurrentPage ? d.alerts[a.name] = a.data :i.addNotification(a.data);
Expand Down Expand Up @@ -8830,11 +8831,11 @@ scope:d
b.result.then(function() {
var a = d.kind, b = d.resourceName, e = d.typeDisplayName || c("humanizeKind")(a), h = e + " '" + (d.displayName ? d.displayName :b) + "'", k = "Project" === d.kind ? {} :{
namespace:d.projectName
};
g["delete"]({
}, l = {};
d.options.deleteImmediately && (l.gracePeriodSeconds = 0), g["delete"]({
resource:f.kindToResource(a),
group:d.group
}, b, k).then(function() {
}, b, k, l).then(function() {
i.addNotification({
type:"success",
message:_.capitalize(h) + " was marked for deletion."
Expand Down
9 changes: 9 additions & 0 deletions dist/scripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -10701,6 +10701,13 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"</p>\n" +
"</div>\n" +
"\n" +
"<div ng-if=\"kind === 'Pod'\" class=\"checkbox\">\n" +
"<label>\n" +
"<input type=\"checkbox\" ng-model=\"options.deleteImmediately\">\n" +
"Delete pod immediately without waiting for the processes to terminate gracefully\n" +
"</label>\n" +
"</div>\n" +
"\n" +
"<div ng-if=\"hpaList.length > 0\">\n" +
"<p>\n" +
"<span ng-if=\"hpaList.length === 1\">\n" +
Expand All @@ -10710,6 +10717,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"This resource has autoscalers associated with it. It is recommended you delete the autoscalers with the resource they scale.\n" +
"</span>\n" +
"</p>\n" +
"<div class=\"checkbox\">\n" +
"<label>\n" +
"<input type=\"checkbox\" ng-model=\"options.deleteHPAs\">\n" +
"Delete\n" +
Expand All @@ -10722,6 +10730,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"</label>\n" +
"</div>\n" +
"</div>\n" +
"</div>\n" +
"<div class=\"modal-footer\">\n" +
"<button ng-disabled=\"typeNameToConfirm && confirmName !== resourceName && confirmName !== displayName\" class=\"btn btn-lg btn-danger\" type=\"submit\" ng-click=\"delete();\">Delete</button>\n" +
"<button class=\"btn btn-lg btn-default\" type=\"button\" ng-click=\"cancel();\">Cancel</button>\n" +
Expand Down
2 changes: 1 addition & 1 deletion dist/styles/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.