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

Fix and clean up systemd tgt.service unit file #41

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

JohnAZoidberg
Copy link

@JohnAZoidberg JohnAZoidberg commented Jul 29, 2019

The service would fail to run for me. This makes it work and also nicer. See commits:

tgtd.service: Wait for tgtd to be ready
    If we don't wait, it fails with:
    tgtadm: failed to send request hdr to tgt daemon, Transport endpoint is
    not connected

    It's not a pretty solution but CentOS and Fedora do the same workaround.

Kill tgtd after targets were deleted
    Otherwise the daemon will keep running.

Remove getty comment
    getty does not seem to be related to this service.

Run tgt-admin verbose
    So that it shows all the underlying tgtadm commands it executes.
    Makes debugging easier.
    Also expand the arguments to their full form so that it's clearer what
    each command does.

tgtd.service: Don't fork but notify
    Let systemd handle the process management.
    Type=notify so that the ExecStartPost commands are only executed when
    the daemon is ready.

Fix Documentation URI
    systemd issues a warning with the space present.

Maybe you can suggest a better way to wait for tgtd to become ready?

@JohnAZoidberg JohnAZoidberg changed the title Clean up systemd tgt.service unit file Fix and clean up systemd tgt.service unit file Jul 29, 2019
ExecStart=/usr/sbin/tgtd --foreground
# Wait for tgtd to be ready
# See https://bugzilla.redhat.com/show_bug.cgi?id=848942
ExecStartPost=/usr/sbin/sleep 5
Copy link
Contributor

Choose a reason for hiding this comment

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

This is kind of ugly. Why not make tgtd only signal systemd is's ready when it's actually ready (using sd_notify())?

Copy link
Author

Choose a reason for hiding this comment

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

I forgot about sd_notify, thanks! tgtd even already implements this https://github.com/fujita/tgt/blob/master/usr/tgtd.c#L659

systemd issues a warning with the space present

Signed-off-by: Daniel Schaefer <git@danielschaefer.me>
Let systemd handle the process management.
Type=notify so that the ExecStartPost commands are only executed when
the daemon is ready.

Signed-off-by: Daniel Schaefer <git@danielschaefer.me>
So that it shows all the underlying tgtadm commands it executes.
Makes debugging easier.
Also expand the arguments to their full form so that it's clearer what
each command does.

Signed-off-by: Daniel Schaefer <git@danielschaefer.me>
getty does not seem to be related to this service.

Signed-off-by: Daniel Schaefer <git@danielschaefer.me>
Otherwise the daemon will keep running.

Signed-off-by: Daniel Schaefer <git@danielschaefer.me>
ExecStop=/usr/sbin/tgtadm --op delete --mode system
ExecStop=/usr/sbin/kill -9 $MAINPID
Copy link

Choose a reason for hiding this comment

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

are you sure this is needed? I run tgtd with foreground in a container. And stopping it via https://github.com/fujita/tgt/pull/41/files#diff-f589b6bd883ba54cbe2ebfc7b864d73fde17e245a48cf272fcf8dc9b37ac4969R19-R21 definitely stops the whole process.

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