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

wrappers: do not reload activation units #14724

Merged

Conversation

Meulengracht
Copy link
Member

@Meulengracht Meulengracht commented Nov 14, 2024

Reported here: https://bugs.launchpad.net/snapd/+bug/2083961 it seems that we fail to restart services that have activation units when passing --reload.

Difference of snap restart and snap restart --reload

When we do snap restart we actually do systemctl stop ... and then systemctl start .... This works completely fine when doing this on activated service units, with their activation units, and thus we do not see an issue here.

When we do snap restart --reload, we directly call systemctl reload-or-restart on the service unit and its activation units, however this causes an error from systemd, for two different reasons:

  • We cannot restart socket units while the main service is running (i.e main service must be stopped, which happens during normal restart path)
  • Systemd does not support reloading of socket units (so --reload makes no sense for activation units)

To fix this, we revert to the default behavior when reloading for activated units. Meaning, instead of operating on the activation units as well as the activated unit, we just operate on the activated unit (which does support reload-or-restart).

REF: SNAPDENG-34173

@Meulengracht Meulengracht added this to the 2.67 milestone Nov 14, 2024
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 79.01%. Comparing base (96ea7b0) to head (43dc611).
Report is 70 commits behind head on master.

Files with missing lines Patch % Lines
wrappers/services.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14724      +/-   ##
==========================================
+ Coverage   78.95%   79.01%   +0.06%     
==========================================
  Files        1084     1085       +1     
  Lines      146638   147535     +897     
==========================================
+ Hits       115773   116575     +802     
- Misses      23667    23732      +65     
- Partials     7198     7228      +30     
Flag Coverage Δ
unittests 79.01% <0.00%> (+0.06%) ⬆️

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.

@Meulengracht Meulengracht force-pushed the bugfix/reload-activated-services branch from 85552dc to 0b732f1 Compare November 14, 2024 10:24
@bboozzoo bboozzoo requested a review from zyga November 14, 2024 11:06
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
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.

Thank you!

I think this maybe warrants a cli documentation update for --reload to clarify this behavior.

@Meulengracht Meulengracht force-pushed the bugfix/reload-activated-services branch from 43dc611 to 50304e8 Compare November 19, 2024 10:56
@Meulengracht Meulengracht merged commit 5d64090 into canonical:master Nov 19, 2024
44 of 54 checks passed
@Meulengracht Meulengracht deleted the bugfix/reload-activated-services branch November 19, 2024 13:17
sespiros added a commit to sespiros/snapd that referenced this pull request Nov 19, 2024
* master: (44 commits)
  wrappers: do not reload activation units (canonical#14724)
  gadget/install: support for no{exec,dev,suid} mount flags
  interfaces/builtin/mount_control: add support for nfs mounts (canonical#14694)
  tests: use gojq - part 1 (canonical#14686)
  interfaces/desktop-legacy: allow DBus access to com.canonical.dbusmenu
  interfaces/builtin/fwupd.go: allow access to nvmem for thunderbolt plugin
  tests: removing uc16 executions (canonical#14575)
  tests: Added arm github runner to build snapd (canonical#14504)
  tests: no need to run spread when there are not tests matching the filter (canonical#14728)
  tests/lib/tools/store-state: exit on errors, update relevant tests (canonical#14725)
  tests: udpate the github workflow to run tests suggested by spread-filter tool (canonical#14519)
  testtime: add mockable timers for use in tests (canonical#14672)
  interface/screen_inhibit_control: Improve screen inhibit control for use on core (canonical#14134)
  tests: use images with 20G disk in openstack (canonical#14720)
  i/builtin: allow @ in custom-device filepaths (canonical#14651)
  tests: refactor test-snapd-desktop-layout-with-content
  tests: fix broken app definition
  tests: capitalize sentences in comments
  tests: wrap very long shell line
  tests: fix raciness in async startup and sync install
  ...
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.

3 participants