Commit Graph

3498 Commits

Author SHA1 Message Date
Lukas Wagner
bc078b9f59 notify: clippy fixes
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2025-04-15 12:26:47 +02:00
Maximiliano Sandoval
08c28ddeaf router: format: add newline at the end
Without this newline running commands with missing arguments, e.g.
```
proxmox-backup-client backup
```

will print their usage string without a newline at the end, which is
costing me my sanity.

As per commit d872eb9d7e ("router: cli: rework newline handling for
doc and help output"), usage shouldn't contain trailing new lines and
this in principle should not print double new lines.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-04-15 07:57:17 +02:00
Fabian Grünbichler
550ebbed7c bump proxmox-log to 0.2.9-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-04-09 16:41:37 +02:00
Lukas Wagner
b01036f5cd log: set up custom priority mapping for tracing-journald
By default, the mapping between tracing/log error levels to
syslog priorities is as follows:
  error! -> Error
  warn! -> Warning
  info! -> Notice
  debug! -> Informational
  trace! -> Debug

Before using tracing-journald, we used `syslog` to write log messages
to the journal. That one has the following mapping:

  error! -> Error
  warn! -> Warning
  info! -> Informational
  debug! -> Debug
  trace! -> Debug

The changed mapping of info! log messages led to many messages being
written with the Notice priority, which are formatted bold when running
journalctl to view log messages.

This commit changes the mapping so that it is the same as with the
syslog crate.

Support for custom priority mappings was only introduced in
tracing-journald 0.3.1, so we have to bump the dependency
to that version.

Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2025-04-09 16:38:40 +02:00
Fabian Grünbichler
179a413fe8 bump proxmox-http to 0.9.5-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-04-09 14:06:06 +02:00
Christian Ebner
ca351ecf7e http: client: make https connector generic over resolver
Allow to instantiate a `HttpsConnector` not using the default
`getaddrinfo` based `GaiResolver` for domain name resolution, but
rather a custom resolver implementing the required traits.

The usecase for this is to swap out the DNS resolver for the
statically linked proxmox-backup-client binary, where the glibc
dependency is problematic because of possible ABI incompatibility.

However, set the generic type on `HttpsConnector` to default to
`GaiResolver` to limit inconvenience for implementations using it.

Adds tower-service as cargo workspace dependency and build dependency
to debian/control.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2025-04-09 13:33:44 +02:00
Thomas Lamprecht
64b2f082f5 rest-server: mark version to 0.8.9-1 as released
it's just a source code package so not end user visible and no point
in rebumping.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-08 17:04:07 +02:00
Thomas Lamprecht
92f6e7455e bump: rest-server: bump version to 0.8.9-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-08 16:23:14 +02:00
Thomas Lamprecht
e042f447bd rest-serve: move max body size limit to a constant
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-08 16:16:48 +02:00
Gabriel Goller
cf9e6c03a0 rest-server: increase max body size
Increase maximum POST request body size from 64 kiB to 512 kiB to
match the value used in pve-http-server [0]. This change addresses
potential limitations with the newly introduced consent-banner
feature, which can contain lots of text that could approach the
previous limits [1].

[0]: https://git.proxmox.com/?p=pve-http-server.git;a=commit;h=2650923a42c9ea357dc0e663a69294410190cc7c
[1]: https://lore.proxmox.com/pbs-devel/e0cfec76-5149-4d3d-80be-b96ae633e1ee@proxmox.com/

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
Link: https://lore.proxmox.com/20250408132626.381476-1-g.goller@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-08 16:16:48 +02:00
Thomas Lamprecht
22ffd650c2 notify: bump version to 0.5.4-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-08 12:37:41 +02:00
Alexander Zeidler
684ffacdf9 fix #6143: notify: allow overriding notification templates
Previously, notification templates could be modified by the user, but
these were overwritten again with installing newer package versions of
pve-manager and proxmox-backup.

Now override templates can be created cluster-wide in the path
“/etc/{pve,proxmox-backup}/notification-templates/{namespace}”, which
are used with priority. The folder structure has to be created and
populated manually (e.g. /etc/pve/notification-templates/default).

If override templates are not existing or their rendering fails, the
vendor templates in
"/usr/share/{pve-manager,proxmox-backup}/templates/default/" are used.

Sequence: [override html -> vendor html ->] override txt -> vendor txt

An error is only returned if none of the template candidates could be
used. Using an override template gets not logged.

Signed-off-by: Alexander Zeidler <a.zeidler@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
Link: https://lore.proxmox.com/20250321133341.151340-1-a.zeidler@proxmox.com
2025-04-08 12:25:32 +02:00
Thomas Lamprecht
0afeba4b67 sys: bump version to 0.6.7-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07 20:55:58 +02:00
Thomas Lamprecht
f980cdc661 sys: add MemAvailable to ProcFsMemInfo
To promote using this over the rather useless, or well very different,
MemFree.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07 20:50:01 +02:00
Thomas Lamprecht
a3381b6197 sys: add doc-comments for ProcFsMemInfo type
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07 20:50:01 +02:00
Thomas Lamprecht
58d6e8d492 sys: memory info: use MemAvailable from kernel to compute used memory
The old code was wrong and overestimated the memory used because it
did not take into account things like "SReclaimable", a part of slab
(in-kernel memory allocator) describing things like caches that can be
reclaimed, plus the memory for "Active(file)" and "Inactive(file)",
and other internal kernel things that even though small for each one,
can add up quickly.

Most of these metrics are exposed and could be included in the
calculation, but this will simply become obsolete in the future as the
kernel changes how it does things and how it calculates such available
memory, as it has done many times in the past.

To solve this problem for the long term, the MemAvailable field was
added to /proc/meminfo as of kernel 3.14. It describes "the amount of
memory available for a new workload without pushing the system into
swap". While it is only an estimate, it is as good as it gets, and
since it comes from the kernel, we can always assume that it is
correct for the currently booted kernel.

So, switch over to this metric for calculating the used memory by
subtracting MemAvailable from MemTotal.

Also adds a simple test case for the parser.

This commit is based on a patch from Dietmar [1].

[0]: https://git.kernel.org/torvalds/c/34e431b0ae398fc54ea69ff85ec700722c9da773
[1]: https://lore.proxmox.com/all/20250313114535.99912-2-dietmar@proxmox.com/

Originally-by: Dietmar Maurer <dietmar@proxmox.com>
 [TL: rewrite comments and commit message from scratch]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07 20:49:00 +02:00
Thomas Lamprecht
deb32a6c4a pbs-api-types: bump to 0.2.2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-05 17:25:33 +02:00
Christian Ebner
573d4d149b pbs-api-types: add garbage collection cache capacity tuning option
Allows to adjust the capacity for the LRU cache used to keep track of
recently touched chunks during phase 1 of garbage collection.

Values are provided as multiples of 1024 cache entries, the default
value of 1024 * 1024  was chosen as tradeoff between runtime
improvements and memory usage [0]. The maximum of 8192 * 1024 was
chosen based on the linear regression from [1], resulting in about
8 * 80 MiB = 640 MiB of memory requirement, while allowing to keep
chunks which can reference about 32 TiB of data in case of 4 MiB
fixed size chunks.

[0] https://git.proxmox.com/?p=proxmox-backup.git;a=commit;h=03143eee0a59cf319be0052e139f7e20e124d572
[1] https://lore.proxmox.com/pbs-devel/fa3800dd-e812-4c9a-9d3d-2d8673e05355@proxmox.com/

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Link: https://lore.proxmox.com/pbs-devel/20250404130713.376630-1-c.ebner@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-05 15:59:11 +02:00
Christian Ebner
88e4f4831a pbs-api-types: sync: add sync encrypted/verified snapshots only flags
Add optional sync job config options to allow to include only
encrypted and/or verified backup snapshots, excluding others from the
sync.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Link: https://lore.proxmox.com/pbs-devel/20250404132106.388829-2-c.ebner@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-05 15:59:11 +02:00
Christoph Heiss
969e1ad645 pbs-api-types: introduce proper types for PAM and PBS realms
Introduces two new, simple API types representing the built-in PAM and
PBS authentication realms.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
 [TL: adapt doc-comment for new default field like Shannon pointed out
 but with a slightly different text than she proposed]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-05 15:59:11 +02:00
Christoph Heiss
b143160c12 fix #5379: pbs-api-types: add default field for all realm types
The field indicates whether the realm should be the default realm to
select in the login dialog.

Per definition, the field should only ever be set to `true` on exactly
one realm - up to the consumer/storage to ensure that.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
 [TL: adapt doc-comment for new default field like Shannon pointed out
  but with a slightly different text than she proposed and change
  regular comment to doc-comment.]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-05 15:59:08 +02:00
Christian Ebner
8468dd18d2 pbs-api-types: add option to set GC chunk cleanup atime cutoff
Add the `gc-atime-cutoff` option to the datastore tuning parameters.
This allows to specify the time after which the chunks are not
considered in use anymore if their atime has not been updated since
then.

The default is to keep chunks within the 24h 5m timespan (given no
active writers).

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2025-04-05 15:58:45 +02:00
Christian Ebner
0f658cf79b pbs-api-types: add garbage collection atime safety check flag
Add the `gc-atime-safety-check` flag to the datastore tuning
parameters. This flag allows to enable/disable a check to detect if
the atime update is honored by the filesystem backing the chunk store
during phase 1 of garbage collection and during datastore creation.

The default is to perform the check.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2025-04-05 15:58:39 +02:00
Fabian Grünbichler
f1bcce2796 openid: adapt d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-04-04 15:51:23 +02:00
Fabian Grünbichler
56763c1184 bump proxmox-openid to 0.10.4-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-04-04 15:41:08 +02:00
Thomas Skinner
6f5fefecc0 fix #4234: openid: add library functions for optional userinfo endpoint
Signed-off-by: Thomas Skinner <thomas@atskinner.net>
FG: rebased
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-04-04 15:40:28 +02:00
Thomas Skinner
1c25b76c5d fix #4411: openid: add library code for generic id token claim support
Signed-off-by: Thomas Skinner <thomas@atskinner.net>
Tested-by: Mira Limbeck <m.limbeck@proxmox.com>
Reviewed-by: Mira Limbeck <m.limbeck@proxmox.com>
2025-04-04 14:52:23 +02:00
Thomas Lamprecht
c057adcfed pbs-api-types: bump to 0.2.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-02 15:51:17 +02:00
Hannes Laimer
6dd53a89b5 pbs-api-types: add REGENERATE_TOKEN_SCHEMA
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
2025-04-02 15:01:35 +02:00
Dominik Csapak
1fc5630c71 pbs api types: tape backup job: add worker threads option
Sometimes it's useful to give the user control over how much
parallelized the job is, so introduce a worker thread option.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2025-04-02 14:47:57 +02:00
Lukas Wagner
4097d3697d notify: gotify: use constant from http crate for 'Authorization' header
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2025-03-25 19:37:37 +01:00
Lukas Wagner
6d4c115f05 notify: webhook: gotify: set Content-Length header
To quote from RFC 9110 [1]:

  A user agent SHOULD send Content-Length in a request when
  the method defines a meaning for enclosed content and it
  is not sending Transfer-Encoding. For example, a user agent
  normally sends Content-Length in a POST request even when
  the value is 0 (indicating empty content).
  A user agent SHOULD NOT send a Content-Length header field
  when the request message does not contain content and the
  method semantics do not anticipate such data.

It seemed like our HTTP client lib did not set the header
automatically, which is why we should do it manually.

While most services seemed to have worked fine without setting
the header, some Microsoft services seem to require it
to accept the webhook request [2].

[1] https://datatracker.ietf.org/doc/html/rfc9110#name-content-length
[2] https://forum.proxmox.com/threads/158827

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2025-03-25 19:37:37 +01:00
Thomas Lamprecht
7abd2da759 pbs-api-types: acl: fix indentation error in macro
expand tabs to spaces

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-24 17:56:13 +01:00
Dietmar Maurer
ec8a3de133 sys: procfs: split read_meminfo into read and parse functions
So that we can write tests.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2025-03-20 18:42:05 +01:00
Wolfgang Bumiller
da8fdea632 rest-server: bump to 0.8.8-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-20 14:45:19 +01:00
Christian Ebner
10cf5ed7b4 rest-server: worker task: include context in state error message
Currently the anyhow error context of a given error is not included
in the error message, as `to_string` does use the default formatting
[0].

Include the error context, formatting it as single line as the
message is also shown to the users in e.g. the Proxmox Backup Severs
task state in the UI.

[0] https://docs.rs/anyhow/latest/anyhow/struct.Error.html#display-representations

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2025-03-20 14:40:58 +01:00
Maximiliano Sandoval
25c08ad247 sys: add variable bindings for temporaries in unsafe blocks
These will produce an error in edition 2024 otherwise. The reason this
is needed is because the `unsafe` block has its own scope.

The bytes were defined inside of the let-mut block to preserve the
lifetime they had before this commit.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:32:42 +01:00
Wolfgang Bumiller
e06277ac7a log: bump to 0.2.8-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 12:19:43 +01:00
Wolfgang Bumiller
86a517d087 sys: bump to 0.6.6-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 12:19:43 +01:00
Wolfgang Bumiller
57eb5a36e9 sys, shared-memory: deny unsafe_op_in_unsafe_fn explicitly
can be removed in these and the other crates when switching to edition
2024

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 12:19:43 +01:00
Wolfgang Bumiller
d42810e3c1 log, rest-server: cargo fmt / formatting cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 12:19:43 +01:00
Maximiliano Sandoval
3db442fb8f async: accommodate to edition 2024 changes to RPIT
Prevents the following error:

```
error[E0597]: `inner` does not live long enough
   --> proxmox-async/src/broadcast_future.rs:109:24
    |
107 |         inner: Arc<Mutex<BroadCastFutureBinding<T>>>,
    |         ----- binding `inner` declared here
108 |     ) -> impl Future<Output = Result<T, Error>> {
109 |         let mut data = inner.lock().unwrap();
    |                        ^^^^^ borrowed value does not live long enough
...
121 |         data.broadcast.listen()
    |         ----------------------- argument requires that `inner` is borrowed for `'static`
122 |     }
    |     - `inner` dropped here while still borrowed

error[E0597]: `data` does not live long enough
   --> proxmox-async/src/broadcast_future.rs:121:9
    |
109 |         let mut data = inner.lock().unwrap();
    |             -------- binding `data` declared here
...
121 |         data.broadcast.listen()
    |         ^^^^-------------------
    |         |
    |         borrowed value does not live long enough
    |         argument requires that `data` is borrowed for `'static`
122 |     }
    |     - `data` dropped here while still borrowed
```

The use<...> pattern was introduced in rust 1.82.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:19:33 +01:00
Maximiliano Sandoval
51c3a31115 mark blocks inside unsafe fns unsafe
In edition 2024 unsafe code inside unsafe functions has to be explicitly
marked as such.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:19:19 +01:00
Maximiliano Sandoval
9be42ea5ad daemon: set_var is now unsafe
In edition 2024 set_var is unsafe.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:19:19 +01:00
Maximiliano Sandoval
abd07ffcff mark extern C blocks as unsafe
This is required in edition 2024.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:19:19 +01:00
Gabriel Goller
a75b97da76 log, rest-server: worker_task: add log_unfiltered
To write result message manually, bypassing tracing.

The workertasks currently get their status from parsing the log
messages in the task-log file. The problem is that if these messages are
filtered – which is now possible using the PBS_LOG env variable – some
workertasks will end up with a "stopped: unknown" status. This is not
desirable so write the message manually to the workertask file and
bypass tracing.

This way we are guaranteed that, regardless of the max logging level the
user sets, the final message (and status) is written.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2025-03-19 12:19:02 +01:00
Wolfgang Bumiller
c99308ecfc log: factor out NoWorkerTask filter
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 11:52:08 +01:00
Wolfgang Bumiller
6bdd07075d log: fix doctests
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 11:51:53 +01:00
Gabriel Goller
656fedb0c4 log: add layer for pve workertasks in perlmod crates
Add a layer that outputs messages to stderr in a specific format. In
PVE, stderr is rerouted to the tasklog if the we are within a
workertask. Therefore, ensure the stderr output is formatted
appropriately.

Reported-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2025-03-19 09:52:35 +01:00
Gabriel Goller
f6269b800d log: introduce logging builder
Add a builder-like struct to compose a tracing logger using different
layers. Instead of having an init function per product/binary or
super-specific init functions that describe the logger, have a dynamic
builder. The builder improves the usability and makes the logging
initialization more self-explaining.

Suggested-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2025-03-19 09:52:35 +01:00