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

[services] make snmp.timer work again and delay telemetry.service #3742

Merged
merged 6 commits into from
Dec 16, 2019

Conversation

stepanblyschak
Copy link
Collaborator

- What I did
Delay CPU intensive services at boot

- How I did it
Made snmp.timer work and add telemetry.timer.
But this is not enough because it breaks the existing snmp dependency on swss.
So, in this solution snmp timer is a wanted by swss service, but since OnBootSec timer expires only once it will not trigger snmp service, so I added line "OnUnitActiveSec=0 sec" which will start snmp service based on the last time it was active. On boot only OnBootSec will expire, on swss start/restarts only second timer will expire immediately and trigger snmp service.
However, snmp service will not stop after "systemctl stop snmp" because of the second timer which will always expire when snmp service because unavailable.
So there is a conflict which will be handled by systemd if we add "Conflicts=" line to both snmp.service and snmp.timer.

So during boot:

  • snmp does not start by default
  • swss starts and starts snmp timer
  • OnUnitActiveSec=0 does not expire since there is no snmp active
  • OnBootSec expires and starts snmp service and snmp timer gets stopped

During "systemctl restart swss"

  • snmp stops because of Requisite on swss
  • snmp unblocks snmp timer from running
  • swss starts and starts snmp timer
  • OnUnitActiveSec=0 expires imidiately and start snmp which stops snmp timer

During "systemctl stop snmp"

  • stop of snmp service unblocks snmp timer but no one starts the timer so it is not started by "OnUnitActiveSec=0"

- How to verify it

  • systemctl stop snmp - stops snmp, swss is still running
  • systemctl start snmp - starts snmp, swss is still running
  • systemctl stop swss - snmp stops with swss
  • systemctl start swss - snmp starts with swss
  • systemctl restart swss - snmp stops before swss and start after swss
  • bootup - snmp & telemetry starts with 3.5 +- 1min delay

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Stepan Blyschak added 4 commits October 23, 2019 17:40
Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
swss.service but start with delay on boot

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
…enabled

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
files/build_templates/snmp.service.j2 Outdated Show resolved Hide resolved
Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
@@ -14,5 +15,3 @@ ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30

[Install]
WantedBy=multi-user.target swss.service
Copy link
Contributor

@yxieca yxieca Nov 18, 2019

Choose a reason for hiding this comment

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

By remove these 2 lines, restarting swss will no longer restarting snmp. You need to add snmp as a dependent of swss similar https://github.com/Azure/sonic-buildimage/blob/master/files/scripts/swss.sh#L5. But you need to add a logic to ignore this dependency if the uptime is less than 210 seconds.

I see that you did it with snmp.timer below.

I am wondering if we should use systemctrld to manage these dependencies that beyond the scope of systemctrld?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we will ignore snmp dependency in swss.sh if uptime is less than 210 sec, then who will start snmp? looks like we still need snmp.timer so the complexity will not decrease and we will have 210 sec hard coded in two places.
If the desired behavior can be done with systemd then why to do that in scripts?

@lguohan lguohan merged commit 4ba0ff2 into sonic-net:master Dec 16, 2019
abdosi pushed a commit that referenced this pull request Jan 6, 2020
)

Delay CPU intensive services at boot

- How I did it
Made snmp.timer work and add telemetry.timer.
But this is not enough because it breaks the existing snmp dependency on swss.
So, in this solution snmp timer is a wanted by swss service, but since OnBootSec timer expires only once it will not trigger snmp service, so I added line "OnUnitActiveSec=0 sec" which will start snmp service based on the last time it was active. On boot only OnBootSec will expire, on swss start/restarts only second timer will expire immediately and trigger snmp service.
However, snmp service will not stop after "systemctl stop snmp" because of the second timer which will always expire when snmp service because unavailable.
So there is a conflict which will be handled by systemd if we add "Conflicts=" line to both snmp.service and snmp.timer.

So during boot:

snmp does not start by default
swss starts and starts snmp timer
OnUnitActiveSec=0 does not expire since there is no snmp active
OnBootSec expires and starts snmp service and snmp timer gets stopped
During "systemctl restart swss"

snmp stops because of Requisite on swss
snmp unblocks snmp timer from running
swss starts and starts snmp timer
OnUnitActiveSec=0 expires imidiately and start snmp which stops snmp timer
During "systemctl stop snmp"

stop of snmp service unblocks snmp timer but no one starts the timer so it is not started by "OnUnitActiveSec=0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants