public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] ceph: services: broadcast versions: improve requesting old version
@ 2021-11-30 10:38 Fabian Ebner
  2022-03-10  7:50 ` Fabian Ebner
  2022-04-26  6:30 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Fabian Ebner @ 2021-11-30 10:38 UTC (permalink / raw)
  To: pve-devel

to avoid a "malformed JSON string" warning when there is no old
version present (e.g. after starting a cluster).

get_node_kv will always return something that evaluates to true, so
instead, test if the result has an entry for the current node. Also,
it's enough to request the kv for the current node only.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/Ceph/Services.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/PVE/Ceph/Services.pm b/PVE/Ceph/Services.pm
index cda13c6a..e0f31e8e 100644
--- a/PVE/Ceph/Services.pm
+++ b/PVE/Ceph/Services.pm
@@ -51,8 +51,9 @@ sub broadcast_ceph_versions {
     my ($version, $buildcommit, $vers_parts) = PVE::Ceph::Tools::get_local_version(1);
 
     if ($version) {
-	if (my $old = PVE::Cluster::get_node_kv("ceph-versions")) {
-	    my $nodename = PVE::INotify::nodename();
+	my $nodename = PVE::INotify::nodename();
+	my $old = PVE::Cluster::get_node_kv("ceph-versions", $nodename);
+	if (defined($old->{$nodename})) {
 	    $old = eval { decode_json($old->{$nodename}) };
 	    warn $@ if $@; # should not happen
 	    if (defined($old) && $old->{buildcommit} eq $buildcommit && $old->{version}->{str} eq $version) {
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH manager] ceph: services: broadcast versions: improve requesting old version
  2021-11-30 10:38 [pve-devel] [PATCH manager] ceph: services: broadcast versions: improve requesting old version Fabian Ebner
@ 2022-03-10  7:50 ` Fabian Ebner
  2022-04-26  6:30 ` [pve-devel] applied: " Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Fabian Ebner @ 2022-03-10  7:50 UTC (permalink / raw)
  To: pve-devel

Ping

Am 30.11.21 um 11:38 schrieb Fabian Ebner:
> to avoid a "malformed JSON string" warning when there is no old
> version present (e.g. after starting a cluster).
> 
> get_node_kv will always return something that evaluates to true, so
> instead, test if the result has an entry for the current node. Also,
> it's enough to request the kv for the current node only.
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>  PVE/Ceph/Services.pm | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/Ceph/Services.pm b/PVE/Ceph/Services.pm
> index cda13c6a..e0f31e8e 100644
> --- a/PVE/Ceph/Services.pm
> +++ b/PVE/Ceph/Services.pm
> @@ -51,8 +51,9 @@ sub broadcast_ceph_versions {
>      my ($version, $buildcommit, $vers_parts) = PVE::Ceph::Tools::get_local_version(1);
>  
>      if ($version) {
> -	if (my $old = PVE::Cluster::get_node_kv("ceph-versions")) {
> -	    my $nodename = PVE::INotify::nodename();
> +	my $nodename = PVE::INotify::nodename();
> +	my $old = PVE::Cluster::get_node_kv("ceph-versions", $nodename);
> +	if (defined($old->{$nodename})) {
>  	    $old = eval { decode_json($old->{$nodename}) };
>  	    warn $@ if $@; # should not happen
>  	    if (defined($old) && $old->{buildcommit} eq $buildcommit && $old->{version}->{str} eq $version) {




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] applied: [PATCH manager] ceph: services: broadcast versions: improve requesting old version
  2021-11-30 10:38 [pve-devel] [PATCH manager] ceph: services: broadcast versions: improve requesting old version Fabian Ebner
  2022-03-10  7:50 ` Fabian Ebner
@ 2022-04-26  6:30 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2022-04-26  6:30 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Ebner

On 30.11.21 11:38, Fabian Ebner wrote:
> to avoid a "malformed JSON string" warning when there is no old
> version present (e.g. after starting a cluster).
> 
> get_node_kv will always return something that evaluates to true, so
> instead, test if the result has an entry for the current node. Also,
> it's enough to request the kv for the current node only.
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>  PVE/Ceph/Services.pm | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-26  6:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 10:38 [pve-devel] [PATCH manager] ceph: services: broadcast versions: improve requesting old version Fabian Ebner
2022-03-10  7:50 ` Fabian Ebner
2022-04-26  6:30 ` [pve-devel] applied: " Thomas Lamprecht

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