[pve-devel] applied: [PATCH manager 2/2] api: ceph/metadata: add structured node versions

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Nov 15 19:10:17 CET 2019


include the version as string and as parts, as we do the split
already. Also include the build commit, so if we re-release a ceph
version, we can differ here too.

Use node as key, to make the new entry a bit more general, could be
easily expanded with other infos, if required.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/API2/Cluster/Ceph.pm |  9 +++++++++
 PVE/Service/pvestatd.pm  | 16 +++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Cluster/Ceph.pm b/PVE/API2/Cluster/Ceph.pm
index fa79d077..b7a53368 100644
--- a/PVE/API2/Cluster/Ceph.pm
+++ b/PVE/API2/Cluster/Ceph.pm
@@ -3,6 +3,8 @@ package PVE::API2::Cluster::Ceph;
 use strict;
 use warnings;
 
+use JSON;
+
 use PVE::Ceph::Services;
 use PVE::Ceph::Tools;
 use PVE::Cluster;
@@ -68,9 +70,16 @@ __PACKAGE__->register_method ({
 	my $rados = PVE::RADOS->new();
 
 	my $res = {
+	    # FIXME: remove with 7.0 depreacated by structured 'versions'
 	    version => PVE::Cluster::get_node_kv("ceph-version"),
 	};
 
+	if (defined(my $vers = PVE::Cluster::get_node_kv("ceph-versions"))) {
+	    $res->{node} = {
+		map { eval { $_ => decode_json($vers->{$_}) } } keys %$vers
+	    };
+	}
+
 	for my $type ( qw(mon mgr mds) ) {
 	    my $typedata = PVE::Ceph::Services::get_cluster_service($type);
 	    my $data = {};
diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index 3beca29f..f3e86a5b 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -416,9 +416,23 @@ sub update_ceph_metadata {
 
     PVE::Ceph::Services::broadcast_ceph_services();
 
-    my ($version) = PVE::Ceph::Tools::get_local_version(1);
+    my ($version, $buildcommit, $vers_parts) = PVE::Ceph::Tools::get_local_version(1);
+
+
+    my $local_last_version = PVE::Cluster::get_node_kv('ceph-versions');
+
     if ($version) {
+	# FIXME: remove with 7.0 - for backward compat only
 	PVE::Cluster::broadcast_node_kv("ceph-version", $version);
+
+	my $node_versions = {
+	    version => {
+		str => $version,
+		parts => $vers_parts,
+	    },
+	    buildcommit => $buildcommit,
+	};
+	PVE::Cluster::broadcast_node_kv("ceph-versions", encode_json($node_versions));
     }
 }
 
-- 
2.20.1





More information about the pve-devel mailing list