* [pve-devel] [PATCH manager 1/2] vzdump jobs: make job ID a standard option
@ 2024-09-20 9:05 Fabian Grünbichler
2024-09-20 9:05 ` [pve-devel] [PATCH manager 2/2] fix #5731: vzdump jobs: fix execution of converted jobs Fabian Grünbichler
2024-09-20 15:55 ` [pve-devel] applied-series: [PATCH manager 1/2] vzdump jobs: make job ID a standard option Thomas Lamprecht
0 siblings, 2 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2024-09-20 9:05 UTC (permalink / raw)
To: pve-devel
and put it into PVE::VZDump because there is a cycle between
PVE::Jobs::VZDump, PVE::API2::VZDump and PVE::API2::Backups
that prevents any of those containing it for now.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
PVE/API2/Backup.pm | 18 ++++++------------
PVE/VZDump.pm | 10 ++++++++++
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/PVE/API2/Backup.pm b/PVE/API2/Backup.pm
index 48598b8f4..f37e23931 100644
--- a/PVE/API2/Backup.pm
+++ b/PVE/API2/Backup.pm
@@ -10,7 +10,7 @@ use PVE::Tools qw(extract_param);
use PVE::Cluster qw(cfs_lock_file cfs_read_file cfs_write_file);
use PVE::RESTHandler;
use PVE::RPCEnvironment;
-use PVE::JSONSchema;
+use PVE::JSONSchema qw(get_standard_option);
use PVE::Storage;
use PVE::Exception qw(raise_param_exc);
use PVE::VZDump;
@@ -34,12 +34,6 @@ sub verify_day_of_week {
die "invalid day '$value'\n";
}
-my $vzdump_job_id_prop = {
- type => 'string',
- description => "The job ID.",
- maxLength => 50
-};
-
# NOTE: also used by the vzdump API call.
sub assert_param_permission_common {
my ($rpcenv, $user, $param, $is_delete) = @_;
@@ -142,7 +136,7 @@ __PACKAGE__->register_method({
items => {
type => "object",
properties => {
- id => $vzdump_job_id_prop
+ id => get_standard_option('pve-backup-jobid'),
},
},
links => [ { rel => 'child', href => "{id}" } ],
@@ -298,7 +292,7 @@ __PACKAGE__->register_method({
parameters => {
additionalProperties => 0,
properties => {
- id => $vzdump_job_id_prop
+ id => get_standard_option('pve-backup-jobid'),
},
},
returns => {
@@ -346,7 +340,7 @@ __PACKAGE__->register_method({
parameters => {
additionalProperties => 0,
properties => {
- id => $vzdump_job_id_prop
+ id => get_standard_option('pve-backup-jobid'),
},
},
returns => { type => 'null' },
@@ -412,7 +406,7 @@ __PACKAGE__->register_method({
parameters => {
additionalProperties => 0,
properties => PVE::VZDump::Common::json_config_properties({
- id => $vzdump_job_id_prop,
+ id => get_standard_option('pve-backup-jobid'),
schedule => {
description => "Backup schedule. The format is a subset of `systemd` calendar events.",
type => 'string', format => 'pve-calendar-event',
@@ -570,7 +564,7 @@ __PACKAGE__->register_method({
parameters => {
additionalProperties => 0,
properties => {
- id => $vzdump_job_id_prop
+ id => get_standard_option('pve-backup-jobid'),
},
},
returns => {
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index f1a6b2206..f813bba60 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -27,6 +27,16 @@ use PVE::VZDump::Plugin;
use PVE::Tools qw(extract_param split_list);
use PVE::API2Tools;
+# section config header/ID, this needs to cover UUIDs, user given values
+# and `$digest:$counter` values converted from vzdump.cron
+# TODO move to a better place once cycle
+# Jobs::VZDump -> API2::VZDump -> API2::Backups -> Jobs::VZDump is broken..
+PVE::JSONSchema::register_standard_option('pve-backup-jobid', {
+ type => 'string',
+ description => "The job ID.",
+ maxLength => 50,
+});
+
my @posix_filesystems = qw(ext3 ext4 nfs nfs4 reiserfs xfs);
my $lockfile = '/var/run/vzdump.lock';
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH manager 2/2] fix #5731: vzdump jobs: fix execution of converted jobs
2024-09-20 9:05 [pve-devel] [PATCH manager 1/2] vzdump jobs: make job ID a standard option Fabian Grünbichler
@ 2024-09-20 9:05 ` Fabian Grünbichler
2024-09-20 15:55 ` [pve-devel] applied-series: [PATCH manager 1/2] vzdump jobs: make job ID a standard option Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2024-09-20 9:05 UTC (permalink / raw)
To: pve-devel
jobs converted from vzdump.cron have an ID of the format
$digest:$counter
where $digest is the hash of the vzdump.cron file, and $counter is the position
of the job within the crontab.
while the section config schema pretends jobs.cfg's section IDs are of type
pve-configid, that is not enforced anywhere, and the API endpoints managing
such jobs allowed arbitrary strings in the past.
the ':' character is not allowed by `pve-configid`, but it is by the section
config parsers and the Job API.
convert the API schema to use the unification of previous definition used by
the job API, and what the section config parser accepts.
Fixes: f5a97f1f5 (api: jobs: vzdump: pass job 'job-id' parameter)
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
PVE/API2/VZDump.pm | 7 ++-----
PVE/VZDump.pm | 1 +
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm
index 15c9b0dcd..6fcac5ba7 100644
--- a/PVE/API2/VZDump.pm
+++ b/PVE/API2/VZDump.pm
@@ -53,15 +53,12 @@ __PACKAGE__->register_method ({
parameters => {
additionalProperties => 0,
properties => PVE::VZDump::Common::json_config_properties({
- 'job-id' => {
+ 'job-id' => get_standard_option('pve-backup-jobid', {
description => "The ID of the backup job. If set, the 'backup-job' metadata field"
. " of the backup notification will be set to this value. Only root\@pam"
. " can set this parameter.",
- type => 'string',
- format => 'pve-configid',
- maxLength => 256,
optional => 1,
- },
+ }),
stdout => {
type => 'boolean',
description => "Write tar to stdout, not to a file.",
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index f813bba60..861ccddd0 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -35,6 +35,7 @@ PVE::JSONSchema::register_standard_option('pve-backup-jobid', {
type => 'string',
description => "The job ID.",
maxLength => 50,
+ pattern => '\S+',
});
my @posix_filesystems = qw(ext3 ext4 nfs nfs4 reiserfs xfs);
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] applied-series: [PATCH manager 1/2] vzdump jobs: make job ID a standard option
2024-09-20 9:05 [pve-devel] [PATCH manager 1/2] vzdump jobs: make job ID a standard option Fabian Grünbichler
2024-09-20 9:05 ` [pve-devel] [PATCH manager 2/2] fix #5731: vzdump jobs: fix execution of converted jobs Fabian Grünbichler
@ 2024-09-20 15:55 ` Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2024-09-20 15:55 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Grünbichler
Am 20/09/2024 um 11:05 schrieb Fabian Grünbichler:
> and put it into PVE::VZDump because there is a cycle between
>
> PVE::Jobs::VZDump, PVE::API2::VZDump and PVE::API2::Backups
>
> that prevents any of those containing it for now.
>
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> PVE/API2/Backup.pm | 18 ++++++------------
> PVE/VZDump.pm | 10 ++++++++++
> 2 files changed, 16 insertions(+), 12 deletions(-)
>
>
applied both patches, thanks!
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-20 15:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-20 9:05 [pve-devel] [PATCH manager 1/2] vzdump jobs: make job ID a standard option Fabian Grünbichler
2024-09-20 9:05 ` [pve-devel] [PATCH manager 2/2] fix #5731: vzdump jobs: fix execution of converted jobs Fabian Grünbichler
2024-09-20 15:55 ` [pve-devel] applied-series: [PATCH manager 1/2] vzdump jobs: make job ID a standard option Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox