post-start commands are not supported

Bug #1892696 reported by Dmitrii Shcherbakov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Triaged
Wishlist
Unassigned

Bug Description

I have the following scenario:

1) tgtd starts up and notifies systemd via sd_notify before entering its event loop;
https://git.launchpad.net/ubuntu/+source/tgt/tree/usr/tgtd.c?h=ubuntu/focal#n658

  tgtd:
    command: usr/sbin/tgtd -f
    stop-command: bin/tgtd-stop
    daemon: notify
----
   Status: "Starting event loop..."
    Tasks: 1 (limit: 7372)
   CGroup: /system.slice/snap.microstack.tgtd.service
           └─22652 /snap/microstack/x2/usr/sbin/tgtd -f

2) tgtd does not automatically read config files - there is no option to do this upstream;
http://manpages.ubuntu.com/manpages/focal/man8/tgtd.8.html

3) after tgtd starts, `tgt-admin -e -c $SNAP_COMMON/etc/tgt/targets.conf` needs to be executed in order to load the iscsi target config into tgtd.

For this to work, I need to execute a post-start command similar to how it is done in the Ubuntu distribution packaging:

https://git.launchpad.net/ubuntu/+source/tgt/tree/debian/tgt.service#n11
ExecStartPost=/usr/sbin/tgt-admin -e -c /etc/tgt/targets.conf

A systemd doc reference: https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStartPre=

Alternatively, a separate service like this could be used with the PartOf stanza (https://www.freedesktop.org/software/systemd/man/systemd.unit.html#PartOf=):

  tgtd-load-targets:
    command: usr/sbin/tgt-admin -e -c $SNAP_COMMON/etc/tgt/targets.conf
    daemon: oneshot
    after:
      - tgtd

However, it is not supported in snapd either.

Changed in snapd:
status: New → Triaged
importance: Undecided → Wishlist
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.