From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH ha-manager 1/9] sim: add command to set static service stats
Date: Tue, 14 Oct 2025 11:47:19 +0200 [thread overview]
Message-ID: <20251014094739.209924-2-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20251014094739.209924-1-m.sandoval@proxmox.com>
This will allow testing different cluster resource schedulers.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/HA/Sim/Hardware.pm | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 9e8c799..4d84eeb 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -178,6 +178,25 @@ sub set_service_state {
return $conf;
}
+sub set_static_service_stats {
+ my ($self, $sid, $new_stats) = @_;
+
+ my $stats = $self->read_static_service_stats();
+ die "no such service '$sid'" if !$stats->{$sid};
+
+ if (my $memory = $new_stats->{maxmemory}) {
+ print "setting $sid memory to $memory\n" if $memory != $stats->{$sid}->{maxmemory};
+ $stats->{$sid}->{maxmemory} = $memory;
+ }
+
+ if (my $cpu = $new_stats->{maxcpu}) {
+ print "setting $sid memory to $cpu\n" if $cpu != $stats->{$sid}->{maxcpu};
+ $stats->{$sid}->{maxcpu} = $cpu;
+ }
+
+ $self->write_static_service_stats($stats);
+}
+
sub add_service {
my ($self, $sid, $opts, $running) = @_;
@@ -397,6 +416,14 @@ sub read_static_service_stats {
return $stats;
}
+sub write_static_service_stats {
+ my ($self, $stats) = @_;
+
+ my $filename = "$self->{statusdir}/static_service_stats";
+ eval { PVE::HA::Tools::write_json_to_file($filename, $stats) };
+ $self->log('error', "writing static service stats failed - $@") if $@;
+}
+
sub new {
my ($this, $testdir) = @_;
@@ -611,6 +638,7 @@ sub get_cfs_state {
# service <sid> stop <timeout>
# service <sid> lock/unlock [lockname]
# service <sid> add <node> [<request-state=started>] [<running=0>]
+# service <sid> set-static-stats <maxcpu> <maxmemory>
# service <sid> delete
sub sim_hardware_cmd {
my ($self, $cmdstr, $logid) = @_;
@@ -760,6 +788,15 @@ sub sim_hardware_cmd {
$params[2] || 0,
);
+ } elsif ($action eq 'set-static-stats') {
+ die "sim_hardware_cmd: missing maxcpu for '$action' command" if !$params[0];
+ die "sim_hardware_cmd: missing maxmemory for '$action' command" if !$params[1];
+
+ $self->set_static_service_stats(
+ $sid,
+ { maxcpu => $params[0], maxmemory => $params[1] },
+ );
+
} elsif ($action eq 'delete') {
$self->delete_service($sid);
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-10-14 9:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
2025-10-14 9:47 ` Maximiliano Sandoval [this message]
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 2/9] sim: add UI to set resource stats for new guests Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 3/9] sim: allow editing static resources of resource Maximiliano Sandoval
2025-10-14 10:00 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 4/9] sim: add helper to store datacenter configuration Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 5/9] sim: allow configuring " Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 6/9] sim: add method to persist current state Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 7/9] sim: add button to persist state to header bar Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 8/9] sim: set default cpu count and memory on new nodes Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 9/9] gitignore: ignore build directory Maximiliano Sandoval
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=20251014094739.209924-2-m.sandoval@proxmox.com \
--to=m.sandoval@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