-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add reclass-rs
inventory backend
#1059
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Just some things:
- As I'm currently working on a pluggable inventory system, I would offer, to migrate your
reclass_rs
into the new system. It seems really easy with just the call toReclass(...)
. This would work that in the beginning an inventory backend gets selected and then we don't need all this flag passing. - Did you made some measurements on how much the performance increases. Because then we can write a cool docs / blog entry about it.
- When do you think missing features like
compose_node_name
will be ready? Maybe it would make sense to wait with the merge for that.
Seems like a good idea, I'm not in a hurry to get this merged, see below as well. I'd be happy to refactor this onto the pluggable inventory system. What's your expected timeline for the pluggable inventory system?
I have some measurements on our inventories, performance of reclass-rs (with a custom print showing the actual inventory rendering time):
Python reclass:
It's unlikely that this will happen very quickly, since we don't use that feature. I'd assume that it will be at least 6 months (unless we get external contributions) until we reach feature parity with the Python reclass implementation. |
Hey @simu , the inventory interface is finally ready. Please give it a review ( #1106 ) and check if I missed something in functionality 😅 After we merged this, these would be the steps to have
|
Hey @MatteoVoges I tried to implement support for First off, the new inventory backend flags don't appear to be ever used in inventory_backend_parser = argparse.ArgumentParser(add_help=False)
inventory_backend_parser.add_argument(
"--inventory-backend",
action="store",
default=from_dot_kapitan("inventory_backend", "inventory", "reclass"),
choices=["reclass", "reclass-rs"],
help="Select the inventory backend to use (default=reclass)",
) To make sure cached.args["inventory-backend"] = args.inventory_backend Then we can just do something like the following in inventory_backends: dict(str, Inventory) = {
"reclass": ReclassInventory,
"reclass-rs": ReclassRsInventory,
}
# select inventory backend
backend_id = cached.args.get("inventory-backend")
backend = inventory_backends.get(backend_id)
inventory_backend: Inventory | None = None
if backend != None:
logger.debug(f"Using {backend_id} as inventory backend")
inventory_backend = backend(inventory_path)
else:
logger.debug("No backend specified, falling back to reclass as inventory backend")
inventory_backend = ReclassInventory(inventory_path) Second, there seems to be a bug in Let me know how you think we should proceed regarding the command line flags to select inventory backends. Edit: See #1127 for a Draft PR which implements the proposed change for the command line flags. |
You're right. The selection via cli args is only on my omegaconf branch and would then have been included, but your fix / suggestion looks good, so I think I will adapt my changes. The selection of the inventory with choices is a good alternative to having one flag per inventory backend. 👍 Thanks for your feedback. I will have a look at your pr's in a minute! |
1edda0e
to
fb39689
Compare
reclass-rs
reclass-rs
inventory backend
4a19ed3
to
75d959e
Compare
…for `get_reclass_config()` By introducing these parameters, we don't need to override as many options in the returned reclass config. Additionally, this change introduces a clean interface for getting Kapitan's expected Reclass config for the reclass-rs integration.
This commit introduces a new optional parameter for `get_reclass_config()` which allows callers to disable the normalisation of the `nodes_uri` and `classes_uri` parameters. This option is required for reclass-rs, which expects these parameters to be relative to the inventory path, rather than relative to the working directory.
We reuse `get_reclass_config()` in the `ReclassRsInventory` backend. Additionally, we make the backend selectable through the `--inventory-backend` CLI option.
This commit is based on the test case introduced in PR kapicorp#1138. We move the compose-node-name test implementation to `tests/` so it's stored in the same place as the other tests and make the test class inheritable so that we can reuse the test for reclass-rs. Additionally we extend the test to check that all targets found by `search_targets()` are rendered by `render_targets()`. This is needed since we don't use reclass(-rs)'s target discovery logic in `search_targets()` but instead use a simplified version that's implemented directly in Kapitan's inventory backend base class. However, `render_targets()` then renders whatever targets reclass(-rs)'s target discovery finds, so if there's a mismatch we'd want to be informed. Co-authored-by: Matteo Voges <matteo.voges@nexenio.com> Co-authored-by: Simon Gerber <simon.gerber@vshn.ch>
We implement the timing simply by executing `datetime.now()` before and after the call to the method which renders the reclass inventory.
…lass*` This is not required anymore since we don't import reclass as a Python submodule anymore.
…s-rs backend We forgot to update kapicorp#1059 to also initialize the `applications` and `exports` fields in the target dataclass in the reclass-rs backend. This commit updates the reclass-rs backend to correctly initialize these fields to match the fix in kapicorp#1142.
As announced in the Kapitan Slack channel, we (@projectsyn / @vshn) have started a reimplementation of Reclass in Rust: https://github.com/projectsyn/reclass-rs
This PR adds opt-in support for reclass-rs in Kapitan. The change is modelled after the opt-in support for gojsonnet.
Proposed Changes
reclass-rs
0.4.0 as an optional dependency. This version supportscompose_node_name
. If you're relying on compose-node-name splitting target names on dots in the file name, you'll need to set thecompose-node-name-literal-dots
compatibility flag. An example is shown in the reclass-rs testsReclassRsInventory
as new inventory backend. Users can use reclass-rs by specifying--inventory-backend=reclass-rs
compose_target_name
#1138)*reclass*
inmake test_coverage
anymore