public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Max Carrara <m.carrara@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v3 pve-manager 3/5] fix #5366: ui: ceph: osd: rework version field rendering
Date: Wed, 24 Jul 2024 17:05:09 +0200	[thread overview]
Message-ID: <20240724150511.474844-4-m.carrara@proxmox.com> (raw)
In-Reply-To: <20240724150511.474844-1-m.carrara@proxmox.com>

.. and show the build commit next to the OSD version.

The logic of the `render_version` function is split up in order to
handle how the version is displayed depending on the type of the row.

If the parsed version is `undefined` or the row marks the beginning of
the tree, an empty string is now returned. This behaviour is
equivalent to before, it just makes the overall logic easier.

If the row belongs to a node, the build commit is now additionally
displayed in parentheses next to the installed Ceph version:

  18.2.2 (build: abcd1234)

If the row belongs to an OSD, the build commit is also additionally
displayed in parentheses next to the installed Ceph version.
Furthermore, should the build commit of the running OSD differ from
the one that's installed on the host, the new hash will also be shown
in parentheses:

  18.2.2 (build: abcd1234 -> 5678fedc)

Additionally, the icon displayed for running an OSD with an outdated
build is now the same as for running an outdated version. The
conditional display of cluster health-related icons remains the same
otherwise.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=5366
---
Changes v2 --> v3:
  * use camelCase instead of nocaseatall for certain variables
  * use less ambiguous variable names (thanks Thomas!)
  * use new `renderCephBuildCommit` helper instead of duplicating logic
    (thanks Thomas!)
  * put 'build: ' in front of build commit when rendering (thanks Thomas!)
  * reword commit title
  * add 'Fixes' trailer
  * remove outdated R-b and T-b trailers

Changes v1 --> v2:
  * use camelCase instead of snake_case (thanks Lukas!)
  * use more descriptive variable names (thanks Lukas!)
  * use `let` instead of `const` for variables where applicable (thanks Lukas!)

 www/manager6/ceph/OSD.js | 53 +++++++++++++++++++++++++++++++---------
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/www/manager6/ceph/OSD.js b/www/manager6/ceph/OSD.js
index d2caafa4..11ec7670 100644
--- a/www/manager6/ceph/OSD.js
+++ b/www/manager6/ceph/OSD.js
@@ -642,23 +642,52 @@ Ext.define('PVE.node.CephOsdTree', {
 	},
 
 	render_version: function(value, metadata, rec) {
+	    if (value === undefined || rec.data.type === 'root') {
+		return '';
+	    }
+
 	    let vm = this.getViewModel();
-	    let versions = vm.get('versions');
-	    let icon = "";
-	    let version = value || "";
-	    let maxversion = vm.get('maxversion');
-	    if (value && PVE.Utils.compare_ceph_versions(value, maxversion) !== 0) {
-		let host_version = rec.parentNode?.data?.version || versions[rec.data.host] || "";
-		if (rec.data.type === 'host' || PVE.Utils.compare_ceph_versions(host_version, maxversion) !== 0) {
+	    let maxVersion = vm.get('maxversion');
+	    let hasMixedVersions = vm.get('mixedversions');
+
+	    if (rec.data.type === 'host') {
+		let icon = "";
+		let installedBuildCommit = rec.data.buildcommit ?? '';
+
+		if (PVE.Utils.compare_ceph_versions(maxVersion, value) > 0) {
 		    icon = PVE.Utils.get_ceph_icon_html('HEALTH_UPGRADE');
-		} else {
-		    icon = PVE.Utils.get_ceph_icon_html('HEALTH_OLD');
+		} else if (hasMixedVersions) {
+		    icon = PVE.Utils.get_ceph_icon_html('HEALTH_OK');
+		}
+
+		if (installedBuildCommit === '') {
+		    return `${icon}${value}`;
 		}
-	    } else if (value && vm.get('mixedversions')) {
-		icon = PVE.Utils.get_ceph_icon_html('HEALTH_OK');
+
+		return `${icon}${value} (build: ${installedBuildCommit.substring(0, 9)})`;
+	    }
+
+	    let installedVersion = rec.parentNode?.data?.version ?? '';
+
+	    let runningBuildCommit = PVE.Utils.parseCephBuildCommit(rec.data) ?? '';
+	    let installedBuildCommit = rec.parentNode?.data?.buildcommit ?? '';
+
+	    let versionInfo = {
+		runningVersion: value,
+		installedVersion: installedVersion,
+		runningBuildCommit: runningBuildCommit,
+		installedBuildCommit: installedBuildCommit,
+		maxVersion: maxVersion,
+		hasMixedVersions: hasMixedVersions,
+	    };
+
+	    let { icon, renderedBuildCommit } = PVE.Utils.renderCephBuildCommit(versionInfo, 9);
+
+	    if (renderedBuildCommit) {
+		return `${icon}${value} (build: ${renderedBuildCommit})`;
 	    }
 
-	    return icon + version;
+	    return `${icon}${value}`;
 	},
 
 	render_osd_val: function(value, metaData, rec) {
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2024-07-24 15:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24 15:05 [pve-devel] [PATCH v3 pve-manager 0/5] Fix #5366: Ceph Build Commit in UI Max Carrara
2024-07-24 15:05 ` [pve-devel] [PATCH v3 pve-manager 1/5] fix #5366: ui: ceph: services: parse and display build commit Max Carrara
2024-07-24 15:05 ` [pve-devel] [PATCH v3 pve-manager 2/5] fix #5366: api: ceph: add host build commit to Ceph OSD index data Max Carrara
2024-07-24 15:05 ` Max Carrara [this message]
2024-07-24 15:05 ` [pve-devel] [PATCH v3 pve-manager 4/5] ui: ceph: osd: increase width of version column Max Carrara
2024-07-24 15:05 ` [pve-devel] [PATCH v3 pve-manager 5/5] fix #5366: api: ceph: change version format in OSD metadata endpoint Max Carrara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240724150511.474844-4-m.carrara@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal