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 84958F64F for ; Fri, 29 Sep 2023 15:02:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 68A8016D3 for ; Fri, 29 Sep 2023 15:02:05 +0200 (CEST) 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 for ; Fri, 29 Sep 2023 15:02:04 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 557F248E64 for ; Fri, 29 Sep 2023 15:02:04 +0200 (CEST) From: Aaron Lauterer To: pve-devel@lists.proxmox.com Date: Fri, 29 Sep 2023 15:02:02 +0200 Message-Id: <20230929130203.3902108-3-a.lauterer@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929130203.3902108-1-a.lauterer@proxmox.com> References: <20230929130203.3902108-1-a.lauterer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.078 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 Subject: [pve-devel] [PATCH manager v4 2/3] fix #2515: ui: ceph pool create: use configured defaults for size and min_size 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, 29 Sep 2023 13:02:05 -0000 Instead of hard coded defaults for the size and min_size parameter, check if we have defaults configured in the ceph.conf or config db and use those. There are clusters where different defaults are needed. For example if the cluster spans two rooms and needs to survive the loss of one. A size/min_size of 4/2 are common defaults in such a situation. Signed-off-by: Aaron Lauterer --- changes since v3: * rebased v2: * default 3/2 values for size/min_size are now set right when we get the API response. The component expects to get a value set via cbind. This avoids setting default values in multiple places within the component. v1: * set defaultSize and defaultMinSize to undefined in CephPoolInputPanel * set them in cbindData in PoolEdit (needed when editing existing pool) * waitMsgTarget when opening pool create window * guard returned values for config keys in case they are empty www/manager6/ceph/Pool.js | 62 +++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js index 8de23ecf..0ad59baf 100644 --- a/www/manager6/ceph/Pool.js +++ b/www/manager6/ceph/Pool.js @@ -7,6 +7,10 @@ Ext.define('PVE.CephPoolInputPanel', { onlineHelp: 'pve_ceph_pools', subject: 'Ceph Pool', + + defaultSize: undefined, + defaultMinSize: undefined, + column1: [ { xtype: 'pmxDisplayEditField', @@ -27,7 +31,9 @@ Ext.define('PVE.CephPoolInputPanel', { name: 'size', editConfig: { xtype: 'proxmoxintegerfield', - value: 3, + cbind: { + value: (get) => get('defaultSize'), + }, minValue: 2, maxValue: 7, allowBlank: false, @@ -40,7 +46,6 @@ Ext.define('PVE.CephPoolInputPanel', { }, }, }, - }, ], column2: [ @@ -78,9 +83,15 @@ Ext.define('PVE.CephPoolInputPanel', { xtype: 'proxmoxintegerfield', fieldLabel: gettext('Min. Size'), name: 'min_size', - value: 2, cbind: { - minValue: (get) => get('isCreate') ? 2 : 1, + value: (get) => get('defaultMinSize'), + minValue: (get) => { + if (Number(get('defaultMinSize')) === 1) { + return 1; + } else { + return get('isCreate') ? 2 : 1; + } + }, }, maxValue: 7, allowBlank: false, @@ -195,6 +206,8 @@ Ext.define('PVE.Ceph.PoolEdit', { cbindData: { pool_name: '', isCreate: (cfg) => !cfg.pool_name, + defaultSize: undefined, + defaultMinSize: undefined, }, cbind: { @@ -217,6 +230,8 @@ Ext.define('PVE.Ceph.PoolEdit', { pool_name: '{pool_name}', isErasure: '{isErasure}', isCreate: '{isCreate}', + defaultSize: '{defaultSize}', + defaultMinSize: '{defaultMinSize}', }, }], }); @@ -397,14 +412,37 @@ Ext.define('PVE.node.Ceph.PoolList', { { text: gettext('Create'), handler: function() { - Ext.create('PVE.Ceph.PoolEdit', { - title: gettext('Create') + ': Ceph Pool', - isCreate: true, - isErasure: false, - nodename: nodename, - autoShow: true, - listeners: { - destroy: () => rstore.load(), + let keys = [ + 'global:osd-pool-default-min-size', + 'global:osd-pool-default-size', + ]; + let params = { + 'config-keys': keys.join(';'), + }; + + Proxmox.Utils.API2Request({ + url: '/nodes/localhost/ceph/cfg/value', + method: 'GET', + params, + waitMsgTarget: me.getView(), + failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), + success: function({ result: { data } }) { + let global = data.global; + let defaultSize = global?.['osd-pool-default-size'] ?? 3; + let defaultMinSize = global?.['osd-pool-default-min-size'] ?? 2; + + Ext.create('PVE.Ceph.PoolEdit', { + title: gettext('Create') + ': Ceph Pool', + isCreate: true, + isErasure: false, + defaultSize, + defaultMinSize, + nodename: nodename, + autoShow: true, + listeners: { + destroy: () => rstore.load(), + }, + }); }, }); }, -- 2.39.2