Re: [systemd-devel] systemd behavior during shutdown

2018-09-19 Thread Tiwari, Hari Sahaya
HI,
Many thanks for the reply.

I tried putting DefaultDependencies=false in both .socket & .service files.
I was able to verify that socket was still in "listening" state when my other 
systemd service tried to start a new connection with socket.
Also the "Suppressing connection request since unit stop is scheduled" message 
is no more seen.

Now I am getting below error when the new connection is requested.

Sep 19 23:31:33 jara1 systemd[1]: hacl-cfg.socket: Incoming traffic
Sep 19 23:31:33 jara1 systemd[1]: 
hacl-cfg@6-127.0.0.1:5302-127.0.0.1:63714.service: Trying to enqueue job 
hacl-cfg@6-127.0.0.1:5302-127.0.0.1:63714.service/start/replace
Sep 19 23:31:33 jara1 systemd[1]: Requested transaction contradicts existing 
jobs: Transaction is destructive.
Sep 19 23:31:33 jara1 systemd[1]: hacl-cfg.socket: One connection closed, 1 
left.
Sep 19 23:31:33 jara1 systemd[1]: hacl-cfg.socket: Failed to queue service 
startup job (Maybe the service file is missing or not a non-template unit?): 
Transaction is destructive.
Sep 19 23:31:33 jara1 systemd[1]: hacl-cfg.socket: Changed listening -> failed

Do I have to set some other parameter in the systemd unit files ?

Following are the contents of systemd files,
Service File
---
# cat hacl-cfg@.service
[Unit]
Description=config TCP service
Requires=hacl-cfg.socket
DefaultDependencies=false

[Service]
ExecStart=/opt/cmcluster/bin/cmclconfd -c
StandardInput=socket
KillMode=process

[Install]
WantedBy=multi-user.target

Socket File
-
# cat hacl-cfg.socket
[Unit]
Description= config TCP socket
DefaultDependencies=false

[Socket]
ListenStream=5302
Accept=true
MaxConnections=900

[Install]
WantedBy=sockets.target


Service file which tries to open a new connection with hacl-cfg.socket during 
shutdown

# cat test.service
[Unit]
Description=test Service

[Service]
ExecStart=/bin/test start
ExecStop=/bin/test stop
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target


Thanks,
Hari.

-Original Message-
From: Zbigniew Jędrzejewski-Szmek [mailto:zbys...@in.waw.pl] 
Sent: Wednesday, September 19, 2018 12:11 PM
To: Tiwari, Hari Sahaya 
Cc: systemd-devel@lists.freedesktop.org
Subject: Re: [systemd-devel] systemd behavior during shutdown

On Wed, Sep 19, 2018 at 05:01:33AM +, Tiwari, Hari Sahaya wrote:
> Hi,
> 
> I am facing one issue with systemd where systems socket is not opening a new 
> connection during shutdown.
> I get below logs,
> 
> Sep 12 20:01:32 jara2 systemd[1]: mytestX.socket: Incoming traffic Sep 
> 12 20:01:32 jara2 systemd[1]: mytestX.socket: Suppressing connection request 
> since unit stop is scheduled.
> 
> I have one systemd service which is trying to open a new connection during 
> shutdown sequence but looks like systemd sockets stop accepting new 
> connections as soon as they are marked for stop.
> I tried putting various combination of dependencies but that didn't help. 
> Everytime getting the above message.
> 
> Is there any parameter which can be set in unit files to resolve this issue? 
> Any pointers will be appreciated.

Hi,

yes, this is intentional. It was added to avoid the situation where services 
are stop and subsequently restarted during shutdown because something opens a 
connection, leading to loops.

If you absolutely need to open a connection to a socket activated unit, then 
you could try making the .socket and .service units have 
DefaultDependencies=false, so that they will not conflict with shutdown.target 
and the start jobs will not be created for them. But then you need to make sure 
that they actually *are* stopped at the right time, but issuing a 'systemctl 
stop' request for them.
This can be done, but will be messy, so I'd use a different approach if 
possible.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd behavior during shutdown

2018-09-19 Thread Colin Guthrie
Tiwari, Hari Sahaya wrote on 19/09/18 06:01:
> Hi,
> 
>  
> 
> I am facing one issue with systemd where systems socket is not opening a
> new connection during shutdown.
> 
> I get below logs,
> 
>  
> 
> Sep 12 20:01:32 jara2 systemd[1]: mytestX.socket: Incoming traffic
> Sep 12 20:01:32 jara2 systemd[1]: mytestX.socket: Suppressing connection
> request since unit stop is scheduled.
> 
>  
> 
> I have one systemd service which is trying to open a new connection
> during shutdown sequence but looks like systemd sockets stop accepting
> new connections as soon as they are marked for stop.
> 
> I tried putting various combination of dependencies but that didn’t
> help. Everytime getting the above message.

What dependence did you try?

Ultimately the service attached to this socket should be ordered
"before" the service which is trying to use it. This should mean that
the stop is not performed until after the unit that's using it.

I'm not 100% sure how the socket activation stuff works in this
scenario, but you may need to make sure the service unit of for the
socket is actually started rather than relying on socket activation...

Col



-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd behavior during shutdown

2018-09-19 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Sep 19, 2018 at 05:01:33AM +, Tiwari, Hari Sahaya wrote:
> Hi,
> 
> I am facing one issue with systemd where systems socket is not opening a new 
> connection during shutdown.
> I get below logs,
> 
> Sep 12 20:01:32 jara2 systemd[1]: mytestX.socket: Incoming traffic
> Sep 12 20:01:32 jara2 systemd[1]: mytestX.socket: Suppressing connection 
> request since unit stop is scheduled.
> 
> I have one systemd service which is trying to open a new connection during 
> shutdown sequence but looks like systemd sockets stop accepting new 
> connections as soon as they are marked for stop.
> I tried putting various combination of dependencies but that didn't help. 
> Everytime getting the above message.
> 
> Is there any parameter which can be set in unit files to resolve this issue? 
> Any pointers will be appreciated.

Hi,

yes, this is intentional. It was added to avoid the situation where
services are stop and subsequently restarted during shutdown because
something opens a connection, leading to loops.

If you absolutely need to open a connection to a socket activated
unit, then you could try making the .socket and .service units have
DefaultDependencies=false, so that they will not conflict with
shutdown.target and the start jobs will not be created for them. But
then you need to make sure that they actually *are* stopped at the
right time, but issuing a 'systemctl stop' request for them.
This can be done, but will be messy, so I'd use a different approach
if possible.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel