-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[daemon_base] fix to not reregister signal handler #4998
[daemon_base] fix to not reregister signal handler #4998
Conversation
-src/sonic-daemon-base/sonic_daemon_base/daemon_base.py Problem: Currently all daemons inherit from daemon_base class, and for signal handling functionality they register the signal_handler() by overriding the siganl_handler() in daemon_base by their own implmentation. But some sonic_platform instances also can invoke the daemon_base constructor while trying to instantiate the common utilities for example platform_chassis = sonic_platform.platform.Platform().get_chassis() This will cause the re registration of signal_handler which will cause base class signal_handler() to be invoked when the daemon gets a signal, whereas their own signal_handler should have been invoked. Fix: We only register the siganl_handler once, and if signal_handler has been registered, not re register it. Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
added a coment for the changes Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
fixing some spellings Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
Retest vsimage please |
1 similar comment
Retest vsimage please |
Just a note for posterity: only Python-based daemons should inherit from the DaemonBase class or even import daemon_base.py. However, currently, other Python code is using this module, like the platform API, which in turn has created the situation which is being fixed by this PR. I have intended to create a Python library that both DaemonBase as well as non-daemon code can import which contains common, general SONiC-related functions. I have opened an issue to track this: #4999 |
retest vsimage please |
* [daemon_base] fix to not reregister signal handler -src/sonic-daemon-base/sonic_daemon_base/daemon_base.py Problem: Currently all daemons inherit from daemon_base class, and for signal handling functionality they register the signal_handler() by overriding the siganl_handler() in daemon_base by their own implmentation. But some sonic_platform instances also can invoke the daemon_base constructor while trying to instantiate the common utilities for example platform_chassis = sonic_platform.platform.Platform().get_chassis() This will cause the re registration of signal_handler which will cause base class signal_handler() to be invoked when the daemon gets a signal, whereas their own signal_handler should have been invoked. Fix: We only register the siganl_handler once, and if signal_handler has been registered, not re register it. Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com> * [daemon_base] fix to not reregister signal handler Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
Why I did it
Currently all daemons inherit from daemon_base class, and for
signal handling functionality they register the signal_handler() by
overriding the siganl_handler() in daemon_base by their own
implmentation.
But some sonic_platform instances also can invoke the daemon_base
constructor while trying to instantiate the common utilities
for example
platform_chassis = sonic_platform.platform.Platform().get_chassis()
This will cause the re registration of signal_handler which will
cause base class signal_handler() to be invoked when the daemon
gets a signal, whereas their own signal_handler should have been
invoked.
How I did it
We only register the siganl_handler once, and if signal_handler has
been registered, not re register it.
How to verify it
Run any daemon and send a signal to it and ensure that the
correct signal_handler is invoked.
-src/sonic-daemon-base/sonic_daemon_base/daemon_base.py
added an if check for signal registration to not re register if
the signal is already registered.
Signed-off-by: vaibhav-dahiya vdahiya@microsoft.com