From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox Datacenter Manager development discussion
<pdm-devel@lists.proxmox.com>,
Lukas Wagner <l.wagner@proxmox.com>
Subject: Re: [pdm-devel] [PATCH datacenter-manager v5 04/11] views: add implementation for view resource filtering
Date: Thu, 13 Nov 2025 20:54:30 +0100 [thread overview]
Message-ID: <7af68c3c-f71d-4304-be2a-e47f7e6e63fb@proxmox.com> (raw)
In-Reply-To: <20251113121644.236005-5-l.wagner@proxmox.com>
Am 13.11.25 um 13:16 schrieb Lukas Wagner:
> This commit adds the resource filter implementation for the previously
> defined ViewConfig type.
>
a bit late given that this was already applied, don't get me wrong, I'm
thankful @Dominik for doing so, just a quick heads-up for coordination would
have been welcome by my side. Only few higher level comments for potential
future improvement below.
> There are include/exclude rules for the following properties:
> - (global) resource-id
(host)name would be good to have too from the start.
> - resource pool
> - resource type
> - remote
> - tags
>
> The rules are interpreted as follows:
> - no rules: everything matches
No hard feelings and this definitively works, but it might be a bit clearer
(and safer!) to require an explicit include "all" rule for that.
Deleting all rules by accident is easier than setting some explicit value,
and giving out access to all resources can have implications.
And sure, that's not something frequent or the like, but if there's no
disadvantage it can be still worth to go for the safer route.
It could be also a specific "include-all" flag, to make matching for it
easier and avoid that one has to iterate over all loops.
FWIW, we could still introduce this later if users actually run into it,
so mostly interested in what you think?
> - only includes: included resources match
> - only excluded: everything *but* the excluded resources match
> - include and exclude: excludes are applied *after* includes, meaning if
> one has a `include-remote foo` and `exclude-remote foo` at the same
> time, the remote `foo` will never match
>
> Some experiments were performed with a cache that works roughly as following:
> - HashMap<ViewId, HashMap<ResourceId, bool>> in a mutex
> - Cache invalidated if view config digest changed
> - Cache invalidated if certain resource fields such as tags or resource pools change
> from the last time (also with a digest-based implementation)
>
> Experimented with the `fake-remote` feature and and 15000 guests showed
> that caching was only faster than direct evaluation if the number of
> rules in the ViewConfig is *huge* (e.g. >1000 `include-resource-id`
> entries). But even for those, direct evaluation was always plenty fast,
> with evaluation times ~20ms for *all* resources.
>
> -> for any *realistic* view config, we should be good with direct
> evaluation, as long as we don't add any filter rules which are very
> expensive to evaluate.
As already mentioned offlist a few weeks ago: I really would like to
see some flexible matching support (glob, regex, ...?)
I'm fine with that not being done here already, getting the core plumbing
in place is definitively more important, but I'd like to know how this
would look like, so doing at least a tiny/simple POC would be IMO good to
try before bumping 1.0.
> diff --git a/server/src/views/tests.rs b/server/src/views/tests.rs
> new file mode 100644
> index 00000000..030b7994
> --- /dev/null
> +++ b/server/src/views/tests.rs
> @@ -0,0 +1,619 @@
> +fn run_test(config: ViewConfig, tests: &[((&str, &Resource), bool)]) {
> + let filter = View::new(config);
> +
> + for ((remote_name, resource), expected) in tests {
> + eprintln!("remote: {remote_name}, resource: {resource:?}");
> + assert_eq!(filter.resource_matches(remote_name, resource), *expected);
> + }
> +}
> +
> +const NODE: &str = "somenode";
> +const STORAGE: &str = "somestorage";
> +const REMOTE: &str = "someremote";
> +
> +#[test]
> +fn include_remotes() {
> + let config = ViewConfig {
> + id: "only-includes".into(),
> + include: vec![
> + FilterRule::Remote("remote-a".into()),
> + FilterRule::Remote("remote-b".into()),
> + ],
> + ..Default::default()
> + };
might be nice to have some of the tests also deserialize the config from
a raw string, as while one can argue that it's section config's job to get
us from that to the deserialized type, one can still introduce regressions
outside of the format it self (e.g. typos) and it's IMO also just nice to
see how the configs look in their serialized form, especially when planning
to extend this feature-wise.
_______________________________________________
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-11-13 19:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 12:16 [pdm-devel] [PATCH datacenter-manager v5 00/11] backend implementation for view filters Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 01/11] pdm-api-types: views: add ViewConfig type Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 02/11] pdm-config: views: add support for views Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 03/11] acl: add '/view' and '/view/{view-id}' as allowed ACL paths Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 04/11] views: add implementation for view resource filtering Lukas Wagner
2025-11-13 19:54 ` Thomas Lamprecht [this message]
2025-11-14 13:25 ` Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 05/11] api: resources: list: add support for view parameter Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 06/11] api: resources: top entities: " Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 07/11] api: resources: status: " Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 08/11] api: subscription " Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 09/11] api: remote-tasks: " Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 10/11] pdm-client: resource list: add " Lukas Wagner
2025-11-13 12:16 ` [pdm-devel] [PATCH datacenter-manager v5 11/11] pdm-client: top entities: " Lukas Wagner
2025-11-13 14:42 ` [pdm-devel] applied: [PATCH datacenter-manager v5 00/11] backend implementation for view filters Dominik Csapak
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=7af68c3c-f71d-4304-be2a-e47f7e6e63fb@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=l.wagner@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.