From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 562D21FF14C for ; Fri, 15 May 2026 17:21:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8FA27126A0; Fri, 15 May 2026 17:21:49 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [PATCH datacenter-manager v3 02/12] pdm-client: add wait_for_local_task helper From: Wolfgang Bumiller To: Thomas Lamprecht In-Reply-To: <20260515074623.766766-3-t.lamprecht@proxmox.com> References: <20260515074623.766766-1-t.lamprecht@proxmox.com> <20260515074623.766766-3-t.lamprecht@proxmox.com> Date: Fri, 15 May 2026 17:21:04 +0200 Message-Id: <177885846421.344453.12557013409386368535.b4-review@b4> X-Mailer: b4 0.15.2 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778858465742 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.087 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_SHORT 0.001 Use of a URL Shortener for very short URL SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 6ELNI5NSVMA4PSCZIDTB3736PZOWUXOV X-Message-ID-Hash: 6ELNI5NSVMA4PSCZIDTB3736PZOWUXOV X-MailFrom: w.bumiller@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pdm-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 15 May 2026 09:43:12 +0200, Thomas Lamprecht wrote: > diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs > index 76b33ef..cb5bb04 100644 > --- a/lib/pdm-client/src/lib.rs > +++ b/lib/pdm-client/src/lib.rs > @@ -890,6 +890,36 @@ impl PdmClient { > [ ... skip 20 lines ... ] > + let body: Value = self.0.get(&path).await?.expect_json()?.data; > + let running = body > + .get("status") > + .and_then(Value::as_str) > + .map(|s| s == "running") > + .unwrap_or(false); Minor nit: The last 3 lines could be condensed to == Some("running") which is slightly easier to read, and even makes it short enough to fit within `if` and `{`. Also, since `body` is already a `Value`, it's safe to just index it. If it is not a map, it'll just give you a `Null`, and it does the same if it is a map but the key does not exist. This means we could call `.as_str()` without needing `.and_then()`, so the entire check could be: if body["running"].as_str() == Some("running") { ... } See the indexing docs here[1] [1] https://docs.rs/serde_json/latest/serde_json/enum.Value.html#method.get --