all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Max Carrara" <m.carrara@proxmox.com>
To: "Lukas Wagner" <l.wagner@proxmox.com>,
	"Proxmox VE development discussion" <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH v1 pve-manager 6/8] ui: ceph: services: parse and display build commit
Date: Thu, 06 Jun 2024 10:04:20 +0200	[thread overview]
Message-ID: <D1SS11T7DIW1.3HJ9O7DESPLR0@proxmox.com> (raw)
In-Reply-To: <780f729b-faed-45e3-826a-a2192a50f63a@proxmox.com>

On Wed Jun 5, 2024 at 4:48 PM CEST, Lukas Wagner wrote:
>
>
> On  2024-04-30 17:28, Max Carrara wrote:
> > This commit adds `PVE.Utils.parse_ceph_buildcommit`, which can be used
> > to get the full hash "eccf199d..." in parentheses from a string like
> > the following:
> > 
> >   ceph version 17.2.7 (eccf199d63457659c09677399928203b7903c888) quincy (stable)
> > 
> > This hash is displayed and taken into account when comparing monitor
> > and manager versions in the client. Specifically, the shortened build
> > commit is now displayed in parentheses next to the version for both
> > monitors and managers like so:
> > 
> >   18.2.2 (abcd1234)
> > 
> > Should the build commit of the running service differ from the one
> > that's installed on the host, the newer build commit will also be
> > shown in parentheses:
> > 
> >   18.2.2 (abcd1234 -> 5678fedc)
> > 
> > The icon displayed for running a service with an outdated build is the
> > same as for running an outdated version. The conditional display of
> > cluster health-related icons remains the same otherwise.
> > 
> > The Ceph summary view also displays the hash and will show a warning
> > if a service is running with a build commit that doesn't match the one
> > that's advertised by the host.
> > 
> > Signed-off-by: Max Carrara <m.carrara@proxmox.com>
> > ---
> >  www/manager6/Utils.js            | 14 ++++++++++++++
> >  www/manager6/ceph/ServiceList.js | 28 ++++++++++++++++++++++------
> >  www/manager6/ceph/Services.js    | 14 +++++++++++++-
> >  3 files changed, 49 insertions(+), 7 deletions(-)
> > 
> > diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
> > index 74e46694..435c79d7 100644
> > --- a/www/manager6/Utils.js
> > +++ b/www/manager6/Utils.js
> > @@ -128,6 +128,20 @@ Ext.define('PVE.Utils', {
> >  	return undefined;
> >      },
> >  
> > +    parse_ceph_buildcommit: function(service) {
> > +	if (service.ceph_version) {
> > +	    // See PVE/Ceph/Tools.pm - get_local_version
> > +	    const match = service.ceph_version.match(
> > +		/^ceph.*\sv?(?:\d+(?:\.\d+)+)\s+(?:\(([a-zA-Z0-9]+)\))/,
> > +	    );
> > +	    if (match) {
> > +		return match[1];
> > +	    }
> > +	}
> > +
> > +	return undefined;
> > +    },
> > +
> >      compare_ceph_versions: function(a, b) {
>
> style nit: new functions/vars should use camelCase, see our JS styleguide [1]

Oh woops, thanks for pointing this out!

>
> >  	let avers = [];
> >  	let bvers = [];
> > diff --git a/www/manager6/ceph/ServiceList.js b/www/manager6/ceph/ServiceList.js
> > index 76710146..30f455ed 100644
> > --- a/www/manager6/ceph/ServiceList.js
> > +++ b/www/manager6/ceph/ServiceList.js
> > @@ -102,21 +102,37 @@ Ext.define('PVE.node.CephServiceController', {
> >  	if (value === undefined) {
> >  	    return '';
> >  	}
> > +
> > +	const bc = PVE.Utils.parse_ceph_buildcommit(rec.data) ?? '';
>
> I'd prefer a longer variable name here, e.g. buildCommit - bc is a bit too terse for my
> taste :)

Fair ;)

>
> > +
> >  	let view = this.getView();
> > -	let host = rec.data.host, nodev = [0];
> > +	const host = rec.data.host;
>
> style nit: we only really use `const` for proper constants, see our JS guidelines

Again thanks for pointing this out!

>
> > +
> > +	let versionNode = [0];
> > +	let bcNode = '';
> >  	if (view.nodeversions[host] !== undefined) {
> > -	    nodev = view.nodeversions[host].version.parts;
> > +	    versionNode = view.nodeversions[host].version.parts;
> > +	    bcNode = view.nodeversions[host].buildcommit;
> >  	}
> >  
> > +	let bcChanged = bc !== '' && bcNode !== '' && bc !== bcNode;
> >  	let icon = '';
> > -	if (PVE.Utils.compare_ceph_versions(view.maxversion, nodev) > 0) {
> > +	if (PVE.Utils.compare_ceph_versions(view.maxversion, versionNode) > 0) {
> >  	    icon = PVE.Utils.get_ceph_icon_html('HEALTH_UPGRADE');
> > -	} else if (PVE.Utils.compare_ceph_versions(nodev, value) > 0) {
> > +	} else if (PVE.Utils.compare_ceph_versions(versionNode, value) > 0) {
> >  	    icon = PVE.Utils.get_ceph_icon_html('HEALTH_OLD');
> > -	} else if (view.mixedversions) {
> > +	} else if (view.mixedversions && !bcChanged) {
> >  	    icon = PVE.Utils.get_ceph_icon_html('HEALTH_OK');
> >  	}
> > -	return icon + value;
> > +
> > +	let bcPart = bc.substring(0, 9);
> > +	if (bcChanged) {
> > +	    const arrow = '<i class="fa fa-fw fa-long-arrow-right"></i>';
> > +	    icon ||= PVE.Utils.get_ceph_icon_html('HEALTH_OLD');
> > +	    bcPart = `${bc.substring(0, 9)}${arrow}${bcNode.substring(0, 9)}`;
> > +	}
> > +
> > +	return `${icon}${value} (${bcPart})`;
> >      },
> >  
> >      getMaxVersions: function(store, records, success) {
> > diff --git a/www/manager6/ceph/Services.js b/www/manager6/ceph/Services.js
> > index b9fc52c8..410b28bf 100644
> > --- a/www/manager6/ceph/Services.js
> > +++ b/www/manager6/ceph/Services.js
> > @@ -155,6 +155,7 @@ Ext.define('PVE.ceph.Services', {
> >  		    title: metadata[type][id].name || name,
> >  		    host: host,
> >  		    version: PVE.Utils.parse_ceph_version(metadata[type][id]),
> > +		    buildcommit: PVE.Utils.parse_ceph_buildcommit(metadata[type][id]),
> >  		    service: metadata[type][id].service,
> >  		    addr: metadata[type][id].addr || metadata[type][id].addrs || Proxmox.Utils.unknownText,
> >  		};
> > @@ -181,7 +182,10 @@ Ext.define('PVE.ceph.Services', {
> >  		}
> >  
> >  		if (result.version) {
> > -		    result.statuses.push(gettext('Version') + ": " + result.version);
> > +		    const host_buildcommit = metadata.node[host]?.buildcommit || "";
> > +
> > +		    const buildcommit_short = result.buildcommit.substring(0, 9);
> > +		    result.statuses.push(gettext('Version') + `: ${result.version} (${buildcommit_short})`);
> >  
> >  		    if (PVE.Utils.compare_ceph_versions(result.version, maxversion) !== 0) {
> >  			let host_version = metadata.node[host]?.version?.parts || metadata.version?.[host] || "";
> > @@ -202,6 +206,14 @@ Ext.define('PVE.ceph.Services', {
> >  				gettext('Other cluster members use a newer version of this service, please upgrade and restart'),
> >  			    );
> >  			}
> > +		    } else if (host_buildcommit !== "" && result.buildcommit !== host_buildcommit) {
> > +			if (result.health > healthstates.HEALTH_OLD) {
> > +			    result.health = healthstates.HEALTH_OLD;
> > +			}
> > +			result.messages.push(
> > +			    PVE.Utils.get_ceph_icon_html('HEALTH_OLD', true) +
> > +			    gettext('A newer version was installed but old version still running, please restart'),
> > +			);
> >  		    }
> >  		}
> >  
>
> [1] https://pve.proxmox.com/wiki/Javascript_Style_Guide#Casing



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


  reply	other threads:[~2024-06-06  8:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 15:28 [pve-devel] [PATCH v1 pve-manager 0/8] Ceph Build Commit in UI Max Carrara
2024-04-30 15:28 ` [pve-devel] [PATCH v1 pve-manager 1/8] ceph: tools: refactor installation check as guard clause Max Carrara
2024-04-30 15:28 ` [pve-devel] [PATCH v1 pve-manager 2/8] ceph: tools: update Ceph version regex Max Carrara
2024-06-05 14:48   ` Lukas Wagner
2024-04-30 15:28 ` [pve-devel] [PATCH v1 pve-manager 3/8] ceph: services: remove old cluster broadcast Max Carrara
2024-04-30 15:28 ` [pve-devel] [PATCH v1 pve-manager 4/8] ceph: services: refactor version existence check as guard clause Max Carrara
2024-04-30 15:28 ` [pve-devel] [PATCH v1 pve-manager 5/8] utils: align regex of parse_ceph_version with Perl equivalent Max Carrara
2024-04-30 15:28 ` [pve-devel] [PATCH v1 pve-manager 6/8] ui: ceph: services: parse and display build commit Max Carrara
2024-06-05 14:48   ` Lukas Wagner
2024-06-06  8:04     ` Max Carrara [this message]
2024-04-30 15:28 ` [pve-devel] [PATCH v1 pve-manager 7/8] api: ceph: add build commit of host to Ceph osd index endpoint data Max Carrara
2024-04-30 15:28 ` [pve-devel] [PATCH v1 pve-manager 8/8] ui: ceph: osd: rework rendering of version field & show build commit Max Carrara
2024-06-05 14:48   ` Lukas Wagner
2024-06-06  8:04     ` Max Carrara
2024-06-05  9:16 ` [pve-devel] [PATCH v1 pve-manager 0/8] Ceph Build Commit in UI Max Carrara
2024-06-05 14:48 ` Lukas Wagner
2024-06-06  8:06   ` 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=D1SS11T7DIW1.3HJ9O7DESPLR0@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=l.wagner@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal