public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Max R. Carrara" <m.carrara@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-manager master v1 4/6] ceph: tools: simplify helper sub for crash keyring file
Date: Tue, 16 Sep 2025 19:20:05 +0200	[thread overview]
Message-ID: <20250916172012.739807-5-m.carrara@proxmox.com> (raw)
In-Reply-To: <20250916172012.739807-1-m.carrara@proxmox.com>

... by using the new, more generic `create_or_update_keyring_file()`
helper sub.

Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
 PVE/Ceph/Tools.pm | 34 ++++++++--------------------------
 1 file changed, 8 insertions(+), 26 deletions(-)

diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index afff1a0a..b6430f79 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -541,33 +541,15 @@ my sub create_or_update_keyring_file {
 sub create_or_update_crash_keyring_file {
     my ($rados) = @_;
 
-    if (!defined($rados)) {
-        $rados = PVE::RADOS->new();
-    }
+    my $entity = 'client.crash';
+    my $caps = [
+        mon => 'profile crash',
+        mgr => 'profile crash',
+    ];
 
-    my $output = $rados->mon_command({
-        prefix => 'auth get-or-create',
-        entity => 'client.crash',
-        caps => [
-            mon => 'profile crash',
-            mgr => 'profile crash',
-        ],
-        format => 'plain',
-    });
-
-    if (-f $pve_ceph_crash_key_path) {
-        my $contents = PVE::Tools::file_get_contents($pve_ceph_crash_key_path);
-
-        if ($contents ne $output) {
-            PVE::Tools::file_set_contents($pve_ceph_crash_key_path, $output);
-            return 1;
-        }
-    } else {
-        PVE::Tools::file_set_contents($pve_ceph_crash_key_path, $output);
-        return 1;
-    }
-
-    return 0;
+    return create_or_update_keyring_file(
+        $pve_ceph_crash_key_path, $entity, $caps, $rados,
+    );
 }
 
 # is also used in `pve-ceph-keyring` helper
-- 
2.47.3



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


  parent reply	other threads:[~2025-09-16 17:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16 17:20 [pve-devel] [PATCH pve-manager, ceph master v1 0/6] Fix #6816: Prevent ceph-exporter Daemon from Crashing on Starting Max R. Carrara
2025-09-16 17:20 ` [pve-devel] [PATCH pve-manager master v1 1/6] ceph: tools: add helper sub for creating or updating keyring files Max R. Carrara
2025-09-16 17:20 ` [pve-devel] [PATCH pve-manager master v1 2/6] fix #6816: api: ceph: create 'client.exporter' w/ keyring Max R. Carrara
2025-09-16 17:20 ` [pve-devel] [PATCH pve-manager master v1 3/6] fix #6816: bin: add pve-ceph-keyring helper and call it in postinst Max R. Carrara
2025-09-16 17:20 ` Max R. Carrara [this message]
2025-09-16 17:20 ` [pve-devel] [PATCH pve-manager master v1 5/6] bin: make pve-init-ceph-crash call pve-ceph-keyring Max R. Carrara
2025-09-16 17:20 ` [pve-devel] [PATCH ceph master v1 6/6] fix #6816: patches: make ceph-exporter use custom keyring Max R. 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=20250916172012.739807-5-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