Skip to content

feat: upstream snap hooks#710

Merged
mattculler merged 21 commits intomainfrom
work/CRAFT-3821-upstreamed-snap-hooks
Jan 16, 2025
Merged

feat: upstream snap hooks#710
mattculler merged 21 commits intomainfrom
work/CRAFT-3821-upstreamed-snap-hooks

Conversation

@mattculler
Copy link
Contributor

@mattculler mattculler commented Jan 7, 2025

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run tox?

Applications using craft-providers may inadvertently leave around lxc instances, either when new base instances supersede old ones, or when the application is uninstalled. Add a module implementing logic that applications can use in configure and remove snap hooks to prune these unneeded lxc instances.

@mattculler mattculler self-assigned this Jan 7, 2025
@mattculler mattculler linked an issue Jan 7, 2025 that may be closed by this pull request
@mattculler mattculler force-pushed the work/CRAFT-3821-upstreamed-snap-hooks branch from 10dde28 to f427dce Compare January 8, 2025 20:46
@mattculler mattculler marked this pull request as ready for review January 9, 2025 15:27
@mattculler mattculler requested review from cmatsuoka and mr-cal January 9, 2025 15:29
Copy link
Contributor

@mr-cal mr-cal left a comment

Choose a reason for hiding this comment

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

Looking good!

I'm not sure if the criteria for this task is to upstream or upstream and de-duplicate redundant code. My comments are based on the latter.

The de-duplication is only possible now that this is internal to craft-providers and therefore can import other internal modules.

Either way, I would like to have an integration test for the configure and remove hooks.

Copy link
Collaborator

@cmatsuoka cmatsuoka left a comment

Choose a reason for hiding this comment

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

The way the module data is organized is making the code hard to read, I think we can refactor this to make it easier for our future selves to rework this if needed. Also please add a description of the problem being solved to the PR so we can check if the implementation is doing everything that it's supposed to do.

@mattculler
Copy link
Contributor Author

mattculler commented Jan 10, 2025

Also please add a description of the problem being solved to the PR so we can check if the implementation is doing everything that it's supposed to do.

@cmatsuoka I reworked the description to add more detail, how does that look now?

@mattculler
Copy link
Contributor Author

Looking good!

I'm not sure if the criteria for this task is to upstream or upstream and de-duplicate redundant code. My comments are based on the latter.

The de-duplication is only possible now that this is internal to craft-providers and therefore can import other internal modules.

Either way, I would like to have an integration test for the configure and remove hooks.

Awesome - based on the task pointage I was just going to upstream, not deduplicate. I also didn't realize there would be so much deduplication possible - thanks for pointing all that out! I'll open another ticket to capture your knowledge drop.

Re: integration tests, the private repo that this originated from has spread tests that do this, I'll see if I can rework those into integration tests here.

@mattculler mattculler force-pushed the work/CRAFT-3821-upstreamed-snap-hooks branch from 42c5ae1 to 077854f Compare January 14, 2025 21:27
Copy link
Contributor

@mr-cal mr-cal left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@cmatsuoka cmatsuoka left a comment

Choose a reason for hiding this comment

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

Thanks! Remaining issues can be addressed in #715.

@mattculler mattculler merged commit 5bbaf39 into main Jan 16, 2025
14 checks passed
@mattculler mattculler deleted the work/CRAFT-3821-upstreamed-snap-hooks branch January 16, 2025 17:43
mattculler added a commit that referenced this pull request Jan 16, 2025
* feat: mknod intercepts now configurable from LXDProvider

* fix: unit test

* fix: lint

* docs: update changelog (also includes item from #710)
tigarmo pushed a commit that referenced this pull request Feb 3, 2025
…ks in Rockcraft. (#721)

* ci: install lxd on ubuntu 24.04

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>

* ci: install lxd from the candidate channel

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>

* docs: remove starter pack submodule (#713)

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>

* fix: use Multipass-compatible instance names (#712)

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>

* feat: upstream snap hooks (#710)

* feat: add hookutil from downstream repo

Lightly modified to remove proprietary identifiers, not functional in this
state.

* feat: make hookutil work generically

* chore: disable lint check - may change approach later

* feat: add unit tests from downstream

* chore: linter issues

* fix: craft-providers CI doesn't have lxd, mock it out

* chore(style): rename per code review

* chore(style): rename per code review

* chore(style): rename per code review

* chore: update changed names in test

* refactor: remove globals, let LXDInstances keep project_name

* chore: autoformat

* fix: compat tag structure had been dependent on craft-application

- This way is also simpler in the code, with a slight performance hit for the
  regex.
- There's no way to get the full compat tag without having a fully-instantiated
  application.
- Also fixed some debug output.

* feat(tests): add configure hook integration test

* feat: added remove hook test and beefed up configure hook test

* chore: autoformat

* fix: unit tests for changed interface

* chore: autoformat, this time with the other tool!

* chore: autoformat the third

* fix: use the superior is-installed check from c-prov proper

* fix: lint

* feat: mknod intercepts now configurable from LXDProvider (#717)

* feat: mknod intercepts now configurable from LXDProvider

* fix: unit test

* fix: lint

* docs: update changelog (also includes item from #710)

* feat: add modify_file method to Executor class

* feat: add properties for getting setting pro services applied to environment

* feat: make pull optional in Executor.modify_file

* fix(LXDInstance): missing pro_services file returns none

* trigger ci

* refactor: adjustments to satisfy linters

---------

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Co-authored-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Co-authored-by: Matt Culler <matt.culler@canonical.com>
clay-lake added a commit to clay-lake/craft-providers that referenced this pull request Aug 27, 2025
…ks in Rockcraft. (canonical#721)

* ci: install lxd on ubuntu 24.04

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>

* ci: install lxd from the candidate channel

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>

* docs: remove starter pack submodule (canonical#713)

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>

* fix: use Multipass-compatible instance names (canonical#712)

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>

* feat: upstream snap hooks (canonical#710)

* feat: add hookutil from downstream repo

Lightly modified to remove proprietary identifiers, not functional in this
state.

* feat: make hookutil work generically

* chore: disable lint check - may change approach later

* feat: add unit tests from downstream

* chore: linter issues

* fix: craft-providers CI doesn't have lxd, mock it out

* chore(style): rename per code review

* chore(style): rename per code review

* chore(style): rename per code review

* chore: update changed names in test

* refactor: remove globals, let LXDInstances keep project_name

* chore: autoformat

* fix: compat tag structure had been dependent on craft-application

- This way is also simpler in the code, with a slight performance hit for the
  regex.
- There's no way to get the full compat tag without having a fully-instantiated
  application.
- Also fixed some debug output.

* feat(tests): add configure hook integration test

* feat: added remove hook test and beefed up configure hook test

* chore: autoformat

* fix: unit tests for changed interface

* chore: autoformat, this time with the other tool!

* chore: autoformat the third

* fix: use the superior is-installed check from c-prov proper

* fix: lint

* feat: mknod intercepts now configurable from LXDProvider (canonical#717)

* feat: mknod intercepts now configurable from LXDProvider

* fix: unit test

* fix: lint

* docs: update changelog (also includes item from canonical#710)

* feat: add modify_file method to Executor class

* feat: add properties for getting setting pro services applied to environment

* feat: make pull optional in Executor.modify_file

* fix(LXDInstance): missing pro_services file returns none

* trigger ci

* refactor: adjustments to satisfy linters

---------

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Co-authored-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Co-authored-by: Matt Culler <matt.culler@canonical.com>
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.

Upstream snap hooks

3 participants