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

o/snapstate: download, link, unlink, and discard snap icon in snapstate handlers #15070

Merged

Conversation

olivercalder
Copy link
Member

This PR is based on #15051, and replaces #15003.

During the "download-snap" task, download the snap icon as well.

During "link-snap" and "unlink-snap", link/unlink the snap icon from the downloaded icons pool to the installed icons directory. Do this by adding snap icon management helpers, and calling them from the store metadata helpers in the backend.

Lastly, discard the downloaded snap icon when the final revision of the snap is discarded from disk (and there are no other instances). We want to ensure that the snap icon remains in the pool during any situation when it's possible to install the snap without doing another "download-snap" task, such as via a revert.

This PR is tracked internally by https://warthogs.atlassian.net/browse/SNAPDENG-34436

@olivercalder olivercalder changed the title o/snapstate: download, link, unlink, and discard snap icon in snapstate helpers o/snapstate: download, link, unlink, and discard snap icon in snapstate handlers Feb 13, 2025
Copy link

github-actions bot commented Feb 13, 2025

Thu Feb 20 21:33:42 UTC 2025
The following results are from: https://github.com/canonical/snapd/actions/runs/13437389977

Failures:

Executing:

  • google:ubuntu-25.04-64:tests/main/security-device-cgroups:uinput
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-helper
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-self-manage
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-strict-enforced
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-required-or-optional
  • google:ubuntu-25.04-64:tests/main/snap-user-service-socket-activation
  • google:ubuntu-25.04-64:tests/main/cgroup-devices-v2
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-serial-port
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups:kmsg
  • google:ubuntu-25.04-64:tests/main/snap-ns-forward-compat

Restoring:

  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-strict-enforced

Copy link

codecov bot commented Feb 13, 2025

Codecov Report

Attention: Patch coverage is 36.36364% with 56 lines in your changes missing coverage. Please review.

Project coverage is 78.06%. Comparing base (a272aac) to head (33e02b0).
Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
overlord/snapstate/backend/icon.go 37.20% 18 Missing and 9 partials ⚠️
overlord/snapstate/backend/metadata.go 11.11% 12 Missing and 4 partials ⚠️
overlord/snapstate/handlers.go 64.70% 4 Missing and 2 partials ⚠️
overlord/snapstate/backend/aux_store_info.go 0.00% 5 Missing ⚠️
store/storetest/storetest.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #15070      +/-   ##
==========================================
- Coverage   78.07%   78.06%   -0.02%     
==========================================
  Files        1182     1185       +3     
  Lines      157743   157993     +250     
==========================================
+ Hits       123154   123332     +178     
- Misses      26943    26994      +51     
- Partials     7646     7667      +21     
Flag Coverage Δ
unittests 78.06% <36.36%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@olivercalder olivercalder force-pushed the snap-icons-metadata-management branch from 54c4013 to e7b453f Compare February 14, 2025 16:27
Copy link
Contributor

@bboozzoo bboozzoo 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, mostly comments about logging & errors

iconURL = resultIconURL
}

ctx := tomb.Context(nil) // XXX: should this be a real context?
Copy link
Contributor

Choose a reason for hiding this comment

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

you mean for e.g. context.Background() as a parent?

AFAIU we want the 'tomb' wrapped context as it allows us to detect someone calling Kill() on the associated tomb, and thus allows for the download to be interrupted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was thinking context.Background(). But it previously had nil passed as the ctx parameter directly, so I'm not sure what's correct. Would this work?

Suggested change
ctx := tomb.Context(nil) // XXX: should this be a real context?
ctx := tomb.Context(context.Background())

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

thanks, did a pass

@@ -753,17 +755,53 @@ func (m *SnapManager) doDownloadSnap(t *state.Task, tomb *tomb.Tomb) error {
if err != nil {
return err
}

// Re-compute icon download filepath and URL if the result info has the
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a very old compatibility path I'm not sure we should worry adding icon support here

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

thank you

Copy link
Contributor

@bboozzoo bboozzoo 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
Member

@andrewphelpsj andrewphelpsj left a comment

Choose a reason for hiding this comment

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

Thanks!

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
…icons

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
During `InstallStoreMetadata`, link snap icon from the icons download
pool to the icons install directory.

During `UninstallStoreMetadata`, remove the linked icon from the icons
install directory, if it exists there.

During `DiscardStoreMetadata`, remove the linked icon from both the
icons install directory and the icons download pool, if it exists there.

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
@olivercalder olivercalder force-pushed the snap-icons-metadata-management branch from 33e02b0 to 487ebf8 Compare February 20, 2025 14:20
@olivercalder olivercalder merged commit 25b403a into canonical:master Feb 20, 2025
75 of 76 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.

4 participants