Skip to content
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

Update validate-autoinstall-user-data script #1901

Merged

Conversation

Chris-Peterson444
Copy link
Contributor

@Chris-Peterson444 Chris-Peterson444 commented Jan 30, 2024

./scripts/validate-autoinstall-user-data is used by the integration tests to verify the written user data is correct, but we can additionally advertise this script as something for users to pre-validate their autoinstall data.

Changes include some refactoring and trying to catch some likely common mistakes.

Todo:

  • Write how-to page in documentation
  • [ ] Tests

@Chris-Peterson444 Chris-Peterson444 changed the title User data validation Update validate-autoinstall-user-data script Jan 30, 2024
@Chris-Peterson444 Chris-Peterson444 force-pushed the user-data-validation branch 2 times, most recently from 722fc30 to d8d9f0c Compare May 8, 2024 23:32
Copy link
Collaborator

@dbungert dbungert left a comment

Choose a reason for hiding this comment

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

Looks good so far. Use of dry run here is interesting. We do occasionally have bugs where dry run really runs commands but I don't consider that blocking.

@Chris-Peterson444 Chris-Peterson444 force-pushed the user-data-validation branch 3 times, most recently from 691476d to 6a3abc7 Compare May 22, 2024 00:55
@Chris-Peterson444
Copy link
Contributor Author

Chris-Peterson444 commented May 22, 2024

I think this is ready. It's not perfect but it's a good start. I think I would like to punt writing tests for this since it uses the dry-run logic that is already tested. Eventually I think we could use this in CI for some more testing, which at that point we could write some more tests for this particular script if we wanted.

Eventually I would like to package this (and subiquity as a whole) in a way that users could just install the subiquity snap and invoke the validator from there, which would reduce the setup here.

@Chris-Peterson444 Chris-Peterson444 marked this pull request as ready for review May 22, 2024 01:03
Copy link
Member

@ogayot ogayot left a comment

Choose a reason for hiding this comment

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

Looks nice overall. A few comments though.

scripts/validate-autoinstall-user-data.py Outdated Show resolved Hide resolved
scripts/validate-autoinstall-user-data.py Outdated Show resolved Hide resolved
scripts/validate-autoinstall-user-data.py Outdated Show resolved Hide resolved
scripts/validate-autoinstall-user-data.py Outdated Show resolved Hide resolved
scripts/validate-autoinstall-user-data.py Outdated Show resolved Hide resolved
doc/howto/autoinstall-validation.rst Outdated Show resolved Hide resolved
doc/howto/autoinstall-validation.rst Outdated Show resolved Hide resolved
scripts/validate-autoinstall-user-data.py Outdated Show resolved Hide resolved


SUCCESS_MSG = "Success: The provided autoinstall config validated succesfully"
FAILURE_MSG = "Failure: The provided autoinstall config did not validate succesfully"
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: I'd reword just a bit so that the last words written are not "validate successfully". I'm a lazy reader 😆

The provided autoinstall config failed validation?

Copy link
Member

Choose a reason for hiding this comment

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

Also, I'm tempted to suggest rich (https://rich.readthedocs.io/en/stable/introduction.html) but it's probably difficult to justify for only one message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lazy reader

Me too. I couldn't come up with something at the time but I like it. I used your suggested text.

I'm tempted to suggest rich

I do like the idea. And it's in Main, which is good. Although maybe once (if) we start having more error messaging we could use it?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, let's think about it later. This is not blocking.

scripts/validate-autoinstall-user-data.py Show resolved Hide resolved
@Chris-Peterson444 Chris-Peterson444 force-pushed the user-data-validation branch 2 times, most recently from 17ace31 to 77ab65d Compare June 12, 2024 02:12
@Chris-Peterson444
Copy link
Contributor Author

Updated + rebased onto main.

Thanks for the feedback @ogayot

@Chris-Peterson444 Chris-Peterson444 force-pushed the user-data-validation branch 3 times, most recently from 46c3981 to 5413f4d Compare June 12, 2024 02:40
Copy link
Member

@ogayot ogayot left a comment

Choose a reason for hiding this comment

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

LGTM once we can make the CI happy.

In the future we want to use dry-run and subiquity internals to
do more robust validation of autoinstall user-data. Today the CI
isn't ready for this and we should rely on old behavior to not
regress CI results. This effectively moves current behavior behind
the --legacy flag.
With moving to make the validation script more user facing, we
don't need users to have the documentation link in their autoinstall
file. Add a hidden flag, --check-link, to be used in CI to validate
rendered autoinstall config has the documentation link.
./scripts/validate-autoinstall-user-data is used by the integration
tests to verify the rendered user data validates against the combined
JSON schema, but we have introduced run-time checks for more things
than can be caught by simple JSON validation (e.g. warns/errors on
unknown keys or strict top-level key checking for supporting a
top-level "autoinstall" keyword in the non-cloud-config delivery
scenario). Now the validation logic relies on the server validation
logic directly to perform pre-validation of the the supplied autoinstall
configuration.
@Chris-Peterson444
Copy link
Contributor Author

Finally coming back to this. A couple of things:

  1. I've refactored the code a bit and split the changes into smaller logical
    commits. Hopefully this makes re-review a little easier if necessary.

  2. Changing the CI to rely on the new behavior isn't going to work right away.
    It's uncovering quite a few things we should eventually fix, but I don't think
    we need to do that all in this PR. I'm proposing a hidden --legacy flag we
    can use in CI to rely on the old JSON schema direct validation behavior and
    over time we can work out the fixes to make CI happy with the dry-run validation.
    What do you think?

Copy link
Collaborator

@dbungert dbungert left a comment

Choose a reason for hiding this comment

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

An interesting challenge with the run-time verifier is that it has assumptions that may not match the target installation ISO.
Examples, which can be valid but will fail validation:

  • missing identity / user-data - would be valid on Desktop
  • source asking for anything but id: synthesized - might be valid, if the id matches install-sources.yaml on the ISO

I feel like the validator is still useful but I think it would be worth mentioning these limitations, if we haven't already.

@Chris-Peterson444
Copy link
Contributor Author

Great point. This is one of the issues I was trying to avoid in CI for now and we should definitely document it. How does this look? I added a new section "Validator Limitations" and tried to address all of the things I might consider as limitations of the validator (mostly rearranging the disclaimers I had put in the intro previously), including the points you provided.

@Chris-Peterson444 Chris-Peterson444 merged commit 1495b36 into canonical:main Aug 29, 2024
13 checks passed
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.

3 participants