Page MenuHomePhabricator

Consider using BindsTo instead of Requires to declare dependencies between systemd unit
Closed, ResolvedPublic

Description

While working on T283660, @MMandere discovered the systemd setting BindsTo, documented here:

Configures requirement dependencies, very similar in style to Requires=. However, this dependency type is stronger: in addition to the effect of Requires= it declares that if the unit bound to is stopped, this unit will be stopped too.

We currently use Requires for quite a few units, including many services depending on varnish such as varnishfetcherr, varnishmtail, varnishospital, and various others. For all those services, the stricter guarantees of BindsTo seem to be more appropriate than Requires: if varnish is stopped, all those services stop operating correctly.

The list of services currently using Requires is:

  • codesearch-frontend
  • hound
  • fifo-log-demux
  • keyholder-proxy
  • atsmtail
  • docker-service-shim
  • varnishfetcherr
  • varnishmtail
  • varnishospital
  • varnishslowlog
  • varnishtlsinspector
  • varnishkafka

For each service, we need to understand if Requires is the appropriate choice, or if BindsTo would be better instead.

Event Timeline

When we looked into this for the Bird-based anycast stuff, we found that the combination you want for strong service binding is both BindsTo= + After= on the same underlying service (cf https://www.freedesktop.org/software/systemd/man/systemd.unit.html ).

The swap of Traffic for Traffic-Icebox in this ticket's set of tags was based on a bulk action for all tickets that aren't are neither part of our current planned work nor clearly a recent, higher-priority emergent issue. This is simply one step in a larger task cleanup effort. Further triage of these tickets (and especially, organizing future potential project ideas from them into a new medium) will occur afterwards! For more detail, have a look at the extended explanation on the main page of Traffic-Icebox . Thank you!

Change 895875 had a related patch set uploaded (by BCornwall; author: BCornwall):

[operations/puppet@production] varnish: Change systemd units Requires to BindsTo

https://gerrit.wikimedia.org/r/895875

BCornwall changed the task status from Open to In Progress.Mar 8 2023, 11:11 PM
BCornwall claimed this task.

Change 895877 had a related patch set uploaded (by BCornwall; author: BCornwall):

[operations/puppet@production] docker-service-shim: change Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895877

Change 895878 had a related patch set uploaded (by BCornwall; author: BCornwall):

[operations/puppet@production] ats-mtail: Change systemd Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895878

Removed ircecho from the list as it had Requires=network.target, which is of Type=oneshot (and thus not really appropriate for such a binding).

Change 895884 had a related patch set uploaded (by BCornwall; author: BCornwall):

[operations/puppet@production] codesearch: Change systemd Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895884

Change 895885 had a related patch set uploaded (by BCornwall; author: BCornwall):

[operations/puppet@production] keyholder-proxy: systemd Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895885

Change 895886 had a related patch set uploaded (by BCornwall; author: BCornwall):

[operations/puppet@production] fifo-log-demux: systemd Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895886

Change 895875 merged by BCornwall:

[operations/puppet@production] varnish: Change systemd units Requires to BindsTo

https://gerrit.wikimedia.org/r/895875

Mentioned in SAL (#wikimedia-operations) [2023-03-29T16:44:08Z] <brett> Disable puppet on A:cp to roll out T284555

Change 895877 merged by BCornwall:

[operations/puppet@production] docker-service-shim: change Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895877

Mentioned in SAL (#wikimedia-operations) [2023-03-29T17:28:59Z] <brett> Disable puppet on A:cp to roll out another T284555

Change 895878 merged by BCornwall:

[operations/puppet@production] ats-mtail: Change systemd Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895878

Change 895886 merged by BCornwall:

[operations/puppet@production] fifo-log-demux: systemd Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895886

Removing the Traffic team as our services have been rolled out with the change. Added tags for the relevant projects; Feel free to merge these patches!

BCornwall changed the task status from In Progress to Open.Mar 29 2023, 6:13 PM
BCornwall removed BCornwall as the assignee of this task.
BCornwall subscribed.

Change 895884 merged by Legoktm:

[operations/puppet@production] codesearch: Change systemd Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895884

Change 895885 merged by BCornwall:

[operations/puppet@production] keyholder-proxy: systemd Requires= to BindsTo=

https://gerrit.wikimedia.org/r/895885

BCornwall removed a project: SRE.
BCornwall updated the task description. (Show Details)

Change 927989 had a related patch set uploaded (by Vgutierrez; author: Vgutierrez):

[operations/puppet@production] fifo_log_demux: Fix systemd unit file

https://gerrit.wikimedia.org/r/927989

Change 927989 merged by BCornwall:

[operations/puppet@production] fifo_log_demux: Fix systemd unit file

https://gerrit.wikimedia.org/r/927989