Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3057

Agent fails to enable/disable second instantiated systemd service

    XMLWordPrintable

    Details

      Description

      Hi,

      Systemd supports instantiated services (http://0pointer.de/blog/projects/instances.html). Cf-agent is able to start/stop them properly, but fails to enable/disable them properly starting from the second instance.

      For example:

      • (0) original state: all instances disabled for example@.service
      • (1) ask to enable+start example@foo.service: starts OK, enabled OK
      • (2) ask to enable+start example@bar.service: starts OK, but service is never enabled.
      • (3) ask to stop+disable example@baz.service: cf-agent should not do anything as this instance is not enabled, yet it will run systemctl disabled at each run.

      From what I could find, this is because as long as there's one instance enabled, "systemctl show" will return "UnitFileState=enabled" for all of them (even non existing instance). I think this is not considered a systemd bug because this property reflects the state of the unit file (so the template) and not the instance.

      However, "systemctl is-enabled" returns the proper state, so the workaround I tested (see attached patch) successfully is to skip the first "service_enabled" promise when an instantiated service is used.

      Thanks.

        Attachments

          Activity

            People

            Assignee:
            a10042 Nick Anderson
            Reporter:
            mrpouit Lionel Le Folgoc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: