From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B79D369C42 for ; Fri, 25 Mar 2022 11:55:21 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AF1B29D3 for ; Fri, 25 Mar 2022 11:55:21 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id EB53A84A for ; Fri, 25 Mar 2022 11:55:18 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 505FC46FBE for ; Fri, 25 Mar 2022 11:55:17 +0100 (CET) From: Aaron Lauterer To: pve-devel@lists.proxmox.com Date: Fri, 25 Mar 2022 11:55:10 +0100 Message-Id: <20220325105510.3262101-8-a.lauterer@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220325105510.3262101-1-a.lauterer@proxmox.com> References: <20220325105510.3262101-1-a.lauterer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.024 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v2 manager 7/7] ui: osd: mon: mds: warn if stop/destroy actions are problematic X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2022 10:55:21 -0000 Check if stopping of a service (OSD, MON, MDS) will be problematic for Ceph. The warning still allows the user to proceed. Ceph also has a check if the destruction of a MON is okay, so let's use it. Instead of the common OK button, label it with `Stop OSD` and so forth to hopefully reduce the "click OK by habit" incidents. This will not catch it every time as Ceph can need a few moments after a change to establish its current status. For example, stopping one of 3 MONs and then right away destroying one of the last two running MONs will most likely not trigger the warning. Doing so after a few seconds should show the warning though. Signed-off-by: Aaron Lauterer --- changes: * adapted to changed API endpoint www/manager6/ceph/OSD.js | 71 ++++++++++++++++----- www/manager6/ceph/ServiceList.js | 104 +++++++++++++++++++++++++++---- 2 files changed, 145 insertions(+), 30 deletions(-) diff --git a/www/manager6/ceph/OSD.js b/www/manager6/ceph/OSD.js index b36787f5..6f7e2159 100644 --- a/www/manager6/ceph/OSD.js +++ b/www/manager6/ceph/OSD.js @@ -527,23 +527,60 @@ Ext.define('PVE.node.CephOsdTree', { let me = this; let vm = this.getViewModel(); let cmd = comp.cmd || comp; - Proxmox.Utils.API2Request({ - url: "/nodes/" + vm.get('osdhost') + "/ceph/" + cmd, - params: { service: "osd." + vm.get('osdid') }, - waitMsgTarget: me.getView(), - method: 'POST', - success: function(response, options) { - let upid = response.result.data; - let win = Ext.create('Proxmox.window.TaskProgress', { - upid: upid, - taskDone: () => { me.reload(); }, - }); - win.show(); - }, - failure: function(response, opts) { - Ext.Msg.alert(gettext('Error'), response.htmlStatus); - }, - }); + + let doRequest = function() { + Proxmox.Utils.API2Request({ + url: `/nodes/${vm.get('osdhost')}/ceph/${cmd}`, + params: { service: "osd." + vm.get('osdid') }, + waitMsgTarget: me.getView(), + method: 'POST', + success: function(response, options) { + let upid = response.result.data; + let win = Ext.create('Proxmox.window.TaskProgress', { + upid: upid, + taskDone: () => { me.reload(); }, + }); + win.show(); + }, + failure: function(response, opts) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + }, + }); + }; + + if (cmd === "stop") { + Proxmox.Utils.API2Request({ + url: `/nodes/${vm.get('osdhost')}/ceph/cmd-safety`, + params: { + service: 'osd', + id: vm.get('osdid'), + action: 'stop', + }, + waitMsgTarget: me.getView(), + method: 'GET', + success: function({ result: { data } }) { + if (!data.safe) { + Ext.Msg.show({ + title: gettext('Warning'), + message: data.status, + icon: Ext.Msg.WARNING, + buttons: Ext.Msg.OKCANCEL, + buttonText: { ok: gettext('Stop OSD') }, + fn: function(selection) { + if (selection === 'ok') { + doRequest(); + } + }, + }); + } else { + doRequest(); + } + }, + failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), + }); + } else { + doRequest(); + } }, set_selection_status: function(tp, selection) { diff --git a/www/manager6/ceph/ServiceList.js b/www/manager6/ceph/ServiceList.js index 9298974e..8b51fe6a 100644 --- a/www/manager6/ceph/ServiceList.js +++ b/www/manager6/ceph/ServiceList.js @@ -148,19 +148,57 @@ Ext.define('PVE.node.CephServiceController', { Ext.Msg.alert(gettext('Error'), "entry has no host"); return; } - Proxmox.Utils.API2Request({ - url: `/nodes/${rec.data.host}/ceph/${cmd}`, - method: 'POST', - params: { service: view.type + '.' + rec.data.name }, - success: function(response, options) { - Ext.create('Proxmox.window.TaskProgress', { - autoShow: true, - upid: response.result.data, - taskDone: () => view.rstore.load(), - }); - }, - failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus), - }); + let doRequest = function() { + Proxmox.Utils.API2Request({ + url: `/nodes/${rec.data.host}/ceph/${cmd}`, + method: 'POST', + params: { service: view.type + '.' + rec.data.name }, + success: function(response, options) { + Ext.create('Proxmox.window.TaskProgress', { + autoShow: true, + upid: response.result.data, + taskDone: () => view.rstore.load(), + }); + }, + failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus), + }); + }; + if (cmd === "stop" && ['mon', 'mds'].includes(view.type)) { + Proxmox.Utils.API2Request({ + url: `/nodes/${rec.data.host}/ceph/cmd-safety`, + params: { + service: view.type, + id: rec.data.name, + action: 'stop', + }, + method: 'GET', + success: function({ result: { data } }) { + let stopText = { + mon: gettext('Stop MON'), + mds: gettext('Stop MDS'), + }; + if (!data.safe) { + Ext.Msg.show({ + title: gettext('Warning'), + message: data.status, + icon: Ext.Msg.WARNING, + buttons: Ext.Msg.OKCANCEL, + buttonText: { ok: stopText[view.type] }, + fn: function(selection) { + if (selection === 'ok') { + doRequest(); + } + }, + }); + } else { + doRequest(); + } + }, + failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus), + }); + } else { + doRequest(); + } }, onChangeService: function(button) { let me = this; @@ -273,6 +311,46 @@ Ext.define('PVE.node.CephServiceList', { taskDone: () => view.rstore.load(), }); }, + handler: function(btn, event, rec) { + let me = this; + let view = me.up('grid'); + let doRequest = function() { + Proxmox.button.StdRemoveButton.prototype.handler.call(me, btn, event, rec); + }; + if (view.type === 'mon') { + Proxmox.Utils.API2Request({ + url: `/nodes/${rec.data.host}/ceph/cmd-safety`, + params: { + service: view.type, + id: rec.data.name, + action: 'destroy', + }, + method: 'GET', + success: function({ result: { data } }) { + if (!data.safe) { + Ext.Msg.show({ + title: gettext('Warning'), + message: data.status, + icon: Ext.Msg.WARNING, + buttons: Ext.Msg.OKCANCEL, + buttonText: { ok: gettext('Destroy MON') }, + fn: function(selection) { + if (selection === 'ok') { + doRequest(); + } + }, + }); + } else { + doRequest(); + } + }, + failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus), + }); + } else { + doRequest(); + } + }, + }, '-', { -- 2.30.2