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

feat(snap): add support for devmode confinement #117

Merged
merged 3 commits into from
Feb 7, 2024

Conversation

gruyaume
Copy link
Contributor

@gruyaume gruyaume commented Feb 2, 2024

Snaps have 3 confinement levels: strict, classic and devmode. devmode snaps are useful during the development process. Here we add support for installing snaps with the devmode level of confinement.

Rationale

The first reason to add support for devmode is by symmetry with snaps/snapcraft. devmode is supported by snapcraft.io, why not support it here?

The second reason is pragmatic. The telco team has the SD-Core UPF charm which is only available in devmode. Adding strict confinement for this charm won't be straightforward but we don't want to go through the "classic" review process until we really had a try with strict confinement for it. Until then it will only be available in devmode and we need a way to move ahead with the machine charm.

@gruyaume gruyaume marked this pull request as ready for review February 2, 2024 18:16
@benhoyt benhoyt changed the title feat: Add support for devmode confinement feat(snap): add support for devmode confinement Feb 4, 2024
Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Overall looks reasonable, thanks for the addition. A couple of style (keyword arg) comments as well as a note about not using Optional[bool] (your thoughts welcome).

Additionally, can we please add an integration test that exercises the devmode=True code path?

lib/charms/operator_libs_linux/v2/snap.py Outdated Show resolved Hide resolved
lib/charms/operator_libs_linux/v2/snap.py Outdated Show resolved Hide resolved
lib/charms/operator_libs_linux/v2/snap.py Outdated Show resolved Hide resolved
lib/charms/operator_libs_linux/v2/snap.py Outdated Show resolved Hide resolved
lib/charms/operator_libs_linux/v2/snap.py Outdated Show resolved Hide resolved
lib/charms/operator_libs_linux/v2/snap.py Outdated Show resolved Hide resolved
lib/charms/operator_libs_linux/v2/snap.py Outdated Show resolved Hide resolved
Comment on lines +1047 to +1049
classic: Optional[bool] = False,
devmode: Optional[bool] = False,
dangerous: Optional[bool] = False,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these should all be changed to non-optional too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While I do agree, the scope of this PR wasn't to refactor the existing code. The other comments were addressed though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair -- thanks.

tests/unit/test_snap.py Outdated Show resolved Hide resolved
@gruyaume
Copy link
Contributor Author

gruyaume commented Feb 6, 2024

@benhoyt as for the remark related to the integration tests, I could add a test that installs the sdcore-upf snap (which is only available in devmode), however I'm not convinced this is a great idea as the goal at some point will be to have it available as a strictly confined snap and remove devmode confinement (which will break this existing project). Do you have a suggestion here?

@gruyaume gruyaume requested a review from benhoyt February 6, 2024 20:07
Copy link
Collaborator

@benhoyt benhoyt 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 to me now, thanks. We can always clean up those other Optional[bool]s later.

@benhoyt as for the remark related to the integration tests, I could add a test that installs the sdcore-upf snap (which is only available in devmode), however I'm not convinced this is a great idea as the goal at some point will be to have it available as a strictly confined snap and remove devmode confinement (which will break this existing project). Do you have a suggestion here?

Yeah, that's fair enough. In that case I suggest you just test this code manually against a real Juju (you may have done that already) and report back with results here for the record.

Comment on lines +1047 to +1049
classic: Optional[bool] = False,
devmode: Optional[bool] = False,
dangerous: Optional[bool] = False,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair -- thanks.

@benhoyt benhoyt merged commit b945094 into canonical:main Feb 7, 2024
5 checks passed
@benhoyt
Copy link
Collaborator

benhoyt commented Feb 7, 2024

To speed things up, I've merged this pre-emptively -- if you find anything wonky in your manual testing, we can push up another PR.

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.

2 participants