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

interfaces/systemd: use batch systemd operations #11372

Merged

Conversation

bboozzoo
Copy link
Collaborator

@bboozzoo bboozzoo commented Feb 10, 2022

The PR cherry picks some of the changes from #10463, and some test tweaks from #11353. The main change calling systemd to operate on services in batch, rather than one by one.

cc @kubiko

kubiko and others added 3 commits February 10, 2022 13:20
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
Drop the changes that require new API calls to DaemonReloadIfNeeded(), and only
enable batched operations.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2022

Codecov Report

Merging #11372 (409743d) into master (2f7b43d) will decrease coverage by 0.00%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11372      +/-   ##
==========================================
- Coverage   78.36%   78.35%   -0.01%     
==========================================
  Files         931      931              
  Lines      106558   106569      +11     
==========================================
+ Hits        83499    83507       +8     
- Misses      17859    17861       +2     
- Partials     5200     5201       +1     
Flag Coverage Δ
unittests 78.35% <50.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
interfaces/systemd/backend.go 67.21% <50.00%> (+1.99%) ⬆️
overlord/snapstate/backend/copydata.go 51.06% <0.00%> (-0.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f7b43d...409743d. Read the comment docs.

}
}
}
if 0 < len(disableUnits) {
Copy link
Contributor

Choose a reason for hiding this comment

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

(nitpick) this is slightly unusual, we usually have if len(disableUnits) > 0 (same below)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed a tweak, thanks!

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
@bboozzoo bboozzoo requested a review from mvo5 February 11, 2022 09:04
Copy link
Contributor

@mardy mardy left a comment

Choose a reason for hiding this comment

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

LGTM, only nitpicks about comments and error messages which should now be in plural form.

if err := systemd.Enable(serviceUnits); err != nil {
logger.Noticef("cannot enable service %q: %s", service, err)
if len(changed) > 0 {
// Ensure the service is running right now and on reboots
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: this comment should use the plural now.

if len(removed) > 0 {
logger.Noticef("systemd-backend: Disable: removed services: %q", removed)
if err := systemd.Disable(removed); err != nil {
logger.Noticef("cannot disable service %q: %s", removed, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: this message should now say "services"

if err := systemd.Stop(serviceUnits, 5*time.Second); err != nil {
logger.Noticef("cannot stop service %q: %s", service, err)
if err := systemd.Stop(removed, 5*time.Second); err != nil {
logger.Noticef("cannot stop service %q: %s", removed, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

}
}
}
if len(disableUnits) > 0 {
if err := systemd.Disable(disableUnits); err != nil {
logger.Noticef("cannot disable service %q: %s", disableUnits, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

plural

}
if len(stopUnits) > 0 {
if err := systemd.Stop(stopUnits, 5*time.Second); err != nil {
logger.Noticef("cannot stop service %q: %s", stopUnits, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

plural

Copy link
Contributor

@MiguelPires MiguelPires left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Copy link
Contributor

@mvo5 mvo5 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!

@mvo5 mvo5 merged commit 1b8a1bf into snapcore:master Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants