-
Notifications
You must be signed in to change notification settings - Fork 574
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
cmd: add snap debug validate-seed <path>
cmd
#6771
Conversation
We had a bug where one of the recent livecd-rootfs build images had an incorrect seed.yaml. This caused a panic of snapd on when seeding. To prevent this here is a small helper that we can run inside livecd-rootfs to ensure seed.yaml is good enough to not crash snapd.
snap debug validate-seed <path>
cmd
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.
Some comments
} | ||
|
||
func init() { | ||
cmd := addDebugCommand("validate-seed", |
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.
or validate-seed-file
?
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.
Not sure, feel a bit long but I don't really mind strongly either way. Its a debug command after all :)
return ErrExtraArgs | ||
} | ||
|
||
if _, err := snap.ReadSeedYaml(x.Positionals.SeedYamlPath); err != nil { |
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.
Not super important, but would it make sense to make seed yaml path argument optional, and use the default /var/lib/snapd/.../seed.yaml path if not provided, for convienience?
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.
I like the idea, but I'm also a bit lazy :) We could do it in a followup.
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.
Sure, no problem.
The current code in ReadSeedYaml is not doing much validation and missing or invalid elements will be caught only (much) later. This commit adds some basic validations to the read of the seed.yaml.
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, thanks for implementing it! Just one nitpick to consider.
snap/seed_yaml.go
Outdated
yamlData, err := ioutil.ReadFile(fn) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot read seed yaml: %s", fn) | ||
return nil, fmt.Errorf(errPrefix+"%v", err) |
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.
Nitpick: looks a bit weird to concatenate errorPrefix that way when using fmt formatting anyway, why not simply fmt.Errorf("%s%v", errorPrefix, err)
(also below)?
if err := ValidateInstanceName(sn.Name); err != nil { | ||
return nil, fmt.Errorf(errPrefix+"%v", err) | ||
} | ||
if sn.Channel != "" { |
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.
Nice
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.
LGTM
Shall we land it? |
We had a bug where one of the recent livecd-rootfs build images
had an incorrect seed.yaml. This caused a panic of snapd on when
seeding. To prevent this here is a small helper that we can run
inside livecd-rootfs to ensure seed.yaml is good enough to not
crash snapd.
This is for https://bugs.launchpad.net/ubuntu/+source/livecd-rootfs/+bug/1825437