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/ifacestate: record warning if prompting errors during startup #14838

Conversation

olivercalder
Copy link
Member

@olivercalder olivercalder commented Dec 9, 2024

If an error occurs during interfaces requests manager initialization, record a warning containing the error and indicating that prompting will remain inactive until snapd is restarted.

Even when an error occurs, the "apparmor-prompting" feature flag is left enabled, as the user deliberately turned this flag on, and we don't want to change feature flags without user interaction.

This work is tracked internally by: https://warthogs.atlassian.net/browse/SNAPDENG-32064

If an error occurs during interfaces requests manager initialization,
record a warning containing the error and indicating that prompting
will remain inactive until snapd is restarted.

Even when an error occurs, the `"apparmor-prompting"` feature flag is
left enabled, as the user deliberately turned this flag on, and we
don't want to change feature flags without user interaction.

Signed-off-by: Oliver Calder <[email protected]>
@olivercalder olivercalder added Simple 😃 A small PR which can be reviewed quickly Needs Samuele review Needs a review from Samuele before it can land labels Dec 9, 2024
@olivercalder olivercalder added this to the 2.68 milestone Dec 9, 2024
@olivercalder
Copy link
Member Author

@pedronis please advise on the warning text.
@ZeyadYasser do you think this would be a good candidate for mutable warnings in the future?

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.25%. Comparing base (24a0034) to head (3b7e272).
Report is 41 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14838      +/-   ##
==========================================
+ Coverage   78.20%   78.25%   +0.04%     
==========================================
  Files        1151     1155       +4     
  Lines      151396   152038     +642     
==========================================
+ Hits       118402   118975     +573     
- Misses      25662    25707      +45     
- Partials     7332     7356      +24     
Flag Coverage Δ
unittests 78.25% <100.00%> (+0.04%) ⬆️

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.

Copy link
Contributor

@ZeyadYasser ZeyadYasser left a comment

Choose a reason for hiding this comment

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

LGTM!

Regarding mutable warning, I don't think so. The only thing that could change is the error message, and I suppose different error messages would indicate different problem so mutable warnings would mask them, no? unless of course those errors bubbling up are dynamically built, in this case maybe.

c.Check(mgr.AppArmorPromptingRunning(), Equals, true)
c.Check(mgr.InterfacesRequestsManager(), Equals, fakeManager)

func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

is the function for the defer?

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 so

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 indeed

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

// warning so the user knows prompting is not current running.
m.state.Lock()
defer m.state.Unlock()
m.state.AddWarning(fmt.Sprintf("failed to start prompting backend: %v\nprompting will be inactive until snapd is restarted", err), nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/failed to/cannot/ ?

Copy link
Member Author

@olivercalder olivercalder Dec 11, 2024

Choose a reason for hiding this comment

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

Thanks, I'll make the change. Just to confirm, is it alright for the warning to be multi-line (the bit about how prompting will be inactive until snapd restart on the next line, after the error), or should I shorten the warning and put it all in one line, with semicolon after the error message?

c.Check(mgr.AppArmorPromptingRunning(), Equals, true)
c.Check(mgr.InterfacesRequestsManager(), Equals, fakeManager)

func() {
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 so

@olivercalder olivercalder force-pushed the prompting-warning-on-startup-error branch from 9543eab to 3b7e272 Compare December 11, 2024 15:39
@olivercalder olivercalder added the Squash-merge Please squash this PR when merging. label Dec 11, 2024
@olivercalder
Copy link
Member Author

Test failures:

  • debian-non-req -- openstack issues
  • fedora -- openstack issues
  • openstack:opensuse-15.5-64:project -- spread issues on openstack
  • google:ubuntu-16.04-64:tests/main/degraded -- NTP issues, unrelated

@alfonsosanchezbeato alfonsosanchezbeato merged commit b800bb2 into canonical:master Dec 16, 2024
55 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Samuele review Needs a review from Samuele before it can land Simple 😃 A small PR which can be reviewed quickly Squash-merge Please squash this PR when merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants