From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 2/5] lib/server: include subscription statistics in subscription information
Date: Tue, 2 Dec 2025 15:31:05 +0100 [thread overview]
Message-ID: <20251202143226.3681712-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20251202143226.3681712-1-d.csapak@proxmox.com>
so we can show that information on the subscription panel. This is
useful for users to see why the subscription is marked as invalid.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
lib/pdm-api-types/src/subscription.rs | 20 +++++++++++++++++++-
server/src/api/nodes/subscription.rs | 24 +++++++++++++-----------
2 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/lib/pdm-api-types/src/subscription.rs b/lib/pdm-api-types/src/subscription.rs
index d38611e3..ca23b8e5 100644
--- a/lib/pdm-api-types/src/subscription.rs
+++ b/lib/pdm-api-types/src/subscription.rs
@@ -4,7 +4,7 @@ use anyhow::Error;
use serde::{Deserialize, Serialize};
use proxmox_schema::api;
-use proxmox_subscription::SubscriptionStatus;
+use proxmox_subscription::{SubscriptionInfo, SubscriptionStatus};
#[api]
// order is important here, since we use that for determining if a node has a valid subscription
@@ -156,3 +156,21 @@ pub struct SubscriptionStatistics {
/// Total number of community level subscriptions across all remotes
pub community: usize,
}
+
+#[api(
+ properties: {
+ info: {
+ type: SubscriptionInfo,
+ }
+ }
+)]
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// The PDM subscription info
+pub struct PdmSubscriptionInfo {
+ #[serde(flatten)]
+ pub info: SubscriptionInfo,
+
+ /// PDM subscription statistics
+ pub statistics: SubscriptionStatistics,
+}
diff --git a/server/src/api/nodes/subscription.rs b/server/src/api/nodes/subscription.rs
index d9b44d59..d41a1794 100644
--- a/server/src/api/nodes/subscription.rs
+++ b/server/src/api/nodes/subscription.rs
@@ -11,7 +11,7 @@ use proxmox_sys::fs::CreateOptions;
use pdm_api_types::remotes::RemoteType;
use pdm_api_types::subscription::{
- NodeSubscriptionInfo, SubscriptionLevel, SubscriptionStatistics,
+ NodeSubscriptionInfo, PdmSubscriptionInfo, SubscriptionLevel, SubscriptionStatistics,
};
use pdm_api_types::PRIV_SYS_MODIFY;
@@ -78,7 +78,7 @@ fn count_subscriptions(
stats
}
-fn check_counts(stats: SubscriptionStatistics) -> Result<(), Error> {
+fn check_counts(stats: &SubscriptionStatistics) -> Result<(), Error> {
let subscribed_ratio = stats.active_subscriptions as f64 / stats.total_nodes as f64;
let community_ratio = stats.community as f64 / stats.active_subscriptions as f64;
@@ -107,26 +107,28 @@ fn check_counts(stats: SubscriptionStatistics) -> Result<(), Error> {
}
)]
/// Return subscription status
-pub async fn get_subscription() -> Result<SubscriptionInfo, Error> {
+pub async fn get_subscription() -> Result<PdmSubscriptionInfo, Error> {
let infos = get_all_subscription_infos().await?;
- let stats = count_subscriptions(&infos);
+ let statistics = count_subscriptions(&infos);
- if let Err(err) = check_counts(stats) {
- Ok(SubscriptionInfo {
+ let info = if let Err(err) = check_counts(&statistics) {
+ SubscriptionInfo {
status: SubscriptionStatus::Invalid,
message: Some(format!("{err}")),
serverid: None,
url: Some(PRODUCT_URL.into()),
..Default::default()
- })
+ }
} else {
- Ok(SubscriptionInfo {
+ SubscriptionInfo {
status: SubscriptionStatus::Active,
url: Some(PRODUCT_URL.into()),
..Default::default()
- })
- }
+ }
+ };
+
+ Ok(PdmSubscriptionInfo { info, statistics })
}
#[api(
@@ -147,7 +149,7 @@ pub async fn check_subscription() -> Result<(), Error> {
let infos = get_all_subscription_infos().await?;
let stats = count_subscriptions(&infos);
- if let Err(err) = check_counts(stats) {
+ if let Err(err) = check_counts(&stats) {
update_apt_auth(APT_AUTH_FN, apt_auth_file_opts(), APT_AUTH_URL, None, None)?;
return Err(err);
}
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-12-02 14:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 14:31 [pdm-devel] [PATCH datacenter-manager/yew-comp 0/7] add top bar subscription state and dedicated panel Dominik Csapak
2025-12-02 14:31 ` [pdm-devel] [PATCH yew-comp 1/2] subscription check: use more useful function signature Dominik Csapak
2025-12-02 15:23 ` [pdm-devel] applied: " Thomas Lamprecht
2025-12-02 14:31 ` [pdm-devel] [PATCH yew-comp 2/2] subscriptions: expose subscription_icon Dominik Csapak
2025-12-02 15:23 ` [pdm-devel] applied: " Thomas Lamprecht
2025-12-02 14:31 ` [pdm-devel] [PATCH datacenter-manager 1/5] ui: adapt to signature change of subscription_is_active Dominik Csapak
2025-12-02 16:13 ` [pdm-devel] applied: " Thomas Lamprecht
2025-12-02 14:31 ` Dominik Csapak [this message]
2025-12-02 16:13 ` [pdm-devel] applied: [PATCH datacenter-manager 2/5] lib/server: include subscription statistics in subscription information Thomas Lamprecht
2025-12-02 14:31 ` [pdm-devel] [PATCH datacenter-manager 3/5] ui: configuration: add subscription panel Dominik Csapak
2025-12-02 16:13 ` [pdm-devel] applied: " Thomas Lamprecht
2025-12-02 14:31 ` [pdm-devel] [PATCH datacenter-manager 4/5] ui: show pdm subscription state in top nav bar Dominik Csapak
2025-12-02 14:31 ` [pdm-devel] [PATCH datacenter-manager 5/5] ui: views: make Subscription panel not required anymore Dominik Csapak
2025-12-03 12:08 ` Thomas Lamprecht
2025-12-02 15:27 ` [pdm-devel] [PATCH datacenter-manager/yew-comp 0/7] add top bar subscription state and dedicated panel Thomas Lamprecht
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=20251202143226.3681712-5-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-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