Skip to content

Validate features - only valid features can be enabled#405

Open
arvind4501 wants to merge 7 commits intotheforeman:masterfrom
arvind4501:validate-features
Open

Validate features - only valid features can be enabled#405
arvind4501 wants to merge 7 commits intotheforeman:masterfrom
arvind4501:validate-features

Conversation

@arvind4501
Copy link
Contributor

@arvind4501 arvind4501 commented Mar 11, 2026

Add feature validation to prevent invalid features from being enabled during deployment:

 ./foremanctl deploy --add-feature invalid-feature

[ERROR]: Task failed: Action failed: ERROR: Unknown feature(s) requested: invalid-feature

Run 'foremanctl features' to list all available features.

@@ -0,0 +1,40 @@
---
- name: Remove invalid features from parameters.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't touch parameters.yaml from Ansible, that's obsah's space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking behind this is that when we do --add-feature invalid-feature it adds it to parameters.yaml and then also gives error to user that its not valid but does not remove from that file. which forces the same invalid-feature to be passed on next deploy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this problem in other places too. Like when the user provides a tuning that has requirements higher than the system they are deploying on.

I wonder if it would make sense to enhance obsah so that it can have two playbooks for a command:

  1. a validate playbook, that runs checks and only if that passes, params are persisted
  2. a run playbook, that contains the actual "do things" part.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this starts to feel like hooks in kafo, which I am not sure I like… 👀 @ehelms @ekohl )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we fix it in obsah, it will be a centralized solution and would make these user mistakes be handled more explictely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a validate playbook, that runs checks and only if that passes, params are persisted

i have one doubt here like what are we validating against? do we have to defined whats valid args looks like before actually validating

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can argparse / Obsah metadata handle this for us? I tend to agree this feels more like a CLI level check and error situation rather than a runtime error.

This might present like a kafo hook, and I would like to avoid "hooks" but this does feel like a CLI-level validation that should occur to the user early on and provide quick feedback.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argparse has choices, but that'd require either having a static list (duplicating data in features.yaml) or a way to dynamically read features.yaml at runtime, which we don't have today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the manual removal of parameters.yaml by ansible and created a issue theforeman/obsah#109 that can be handled. Do we need to handle this issue with this PR, or is it fine it can be fixed standalone?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to handle it here and can do it standalone

@stejskalleos stejskalleos self-assigned this Mar 11, 2026
Copy link
Member

@evgeni evgeni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be squashed on merge. Works nicely.

fail_msg: |
ERROR: Unknown feature(s) requested: {{ found_invalid_features | join(', ') }}

Run 'foremanctl features' to list all available features.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume with this here, this shouldn't be merged until #404 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants