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

Improve Schema For cc_set_passwords (SC-1105) #1517

Merged
merged 21 commits into from
Jul 11, 2022

Conversation

holmanb
Copy link
Member

@holmanb holmanb commented Jun 13, 2022

Update chpasswd schema to deprecate password parsing

Additionally:

- chpasswd is specific to distro, make it a distro method
- add test to verify parity between new and old schema options
- update docs to encourage use of new schema keys

I've seen this come up as a concern multiple times from users. I'd also personally like to see this improved.

One remaining item to check before merging: what happens when identical users are in both list: and users:? Would it be better to catch this with a runtime exception or allow any error to bubble up from chpasswd? <- No longer a todo item: tests have been added that verify current behavior is preserved with the current change.

@holmanb holmanb changed the title Improve Schema For cc_set_passwords Improve Schema For cc_set_passwords (SC-1105)23 Jun 14, 2022
@TheRealFalcon
Copy link
Member

TheRealFalcon commented Jun 17, 2022

Just a drive by comment...
I don't remember all of the details, but when #847 happened, we found a much larger use case for random passwords than we had expected. IIRC, it's even used by subiquity for installs. So we need to keep the random password feature. The new schema is nicer and involves much less guesswork, so +1 to that.

@holmanb
Copy link
Member Author

holmanb commented Jun 17, 2022

So we need to keep the random password feature.

Sounds good. No problem, I'll add that to the new key as well.

@TheRealFalcon
Copy link
Member

FYI, https://bugs.launchpad.net/cloud-init/+bug/1979065 . Not sure if it makes sense to address this here (I actually think it's probably better not to), but since you're in the middle of modifying some of this, you may want to incorporate this too.

@holmanb
Copy link
Member Author

holmanb commented Jun 22, 2022

FYI, https://bugs.launchpad.net/cloud-init/+bug/1979065 . Not sure if it makes sense to address this here (I actually think it's probably better not to), but since you're in the middle of modifying some of this, you may want to incorporate this too.

I can do that in a follow up PR while this module is fresh in my brain.

@blackboxsw blackboxsw self-assigned this Jun 22, 2022
@holmanb holmanb changed the title Improve Schema For cc_set_passwords (SC-1105)23 Improve Schema For cc_set_passwords (SC-1105) Jun 27, 2022
@holmanb
Copy link
Member Author

holmanb commented Jun 28, 2022

I just added some tests to verify that duplicate users in input don't break anything in a new way. This is arguably invalid input, but since we don't currently check for it I just wanted to ensure it didn't lead to brokenness while merging the two supported inputs together.

plist = util.get_cfg_option_str(chfg, "list", plist)
if plist:
plist = plist.splitlines()
multiline = util.get_cfg_option_str(chfg, "list")
Copy link
Member Author

Choose a reason for hiding this comment

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

The change here should be a noop change and was made for typing reasons.

Copy link
Contributor

@aciba90 aciba90 left a comment

Choose a reason for hiding this comment

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

+1. Really nice UX schema addition.

I left you a minor nit. The indentation in that line was made with tabs instead of spaces.

cloudinit/config/schemas/schema-cloud-config-v1.json Outdated Show resolved Hide resolved
Co-authored-by: Alberto Contreras <aciba90@gmail.com>
Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

@holmanb much delayed review. but looks great. Just a missing deprecated: true I think and minor text changes.
Do what you will with the unittest suggestions.

Non-blocking comments, you can merge once deprecated: true is in schema.

cloudinit/config/schemas/schema-cloud-config-v1.json Outdated Show resolved Hide resolved
cloudinit/config/cc_set_passwords.py Outdated Show resolved Hide resolved
tests/unittests/config/test_cc_set_passwords.py Outdated Show resolved Hide resolved
Co-authored-by: Chad Smith <chad.smith@canonical.com>
holmanb and others added 4 commits July 11, 2022 14:08
Co-authored-by: Chad Smith <chad.smith@canonical.com>
Co-authored-by: Chad Smith <chad.smith@canonical.com>
@holmanb
Copy link
Member Author

holmanb commented Jul 11, 2022

@blackboxsw - Great feedback, thanks! I committed your suggestions verbatim.

Non-blocking comments, you can merge once deprecated: true is in schema.

It looks like adding the deprecation key causes schemavalidation errors to be raised under strict validation in some tests.

You already gave approval, but given this change wasn't discussed previously I'll wait until you've had a chance to review that part (last commit).

Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

LGTM, and yes incorporates @aciba90's deprecation handling now from ccea0d4. - +1

@holmanb holmanb merged commit a28e2b6 into canonical:main Jul 11, 2022
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.

None yet

4 participants