Fix python3 issue in patch-alarm-manager.
Wrap DaemonRunner class from 3rd party python-daemon library which
is not compatible with python3.
The solution was lifted from:
https://review.opendev.org/c/starlingx/utilities/+/786837
as it was the acceptable way to work around python-daemon limitations.
Patching python-daemon was not accepted as per:
https://review.opendev.org/c/starlingx/integ/+/785523
Story: 2008454
Task: 42789
Depends-On: I3c68322603eaaf9a78d101b5b1198e9582497105
Signed-off-by: Andrei Grosu <andrei.grosu@windriver.com>
Change-Id: I66b2ac6825b78228a40869a3721e6853f2bbe83f
(cherry picked from commit fd1717baee
)
This commit is contained in:
parent
90c32646fa
commit
6b8988fbba
@ -28,13 +28,27 @@ LOG_FILE = '/var/log/patch-alarms.log'
|
|||||||
PID_FILE = '/var/run/patch-alarm-manager.pid'
|
PID_FILE = '/var/run/patch-alarm-manager.pid'
|
||||||
|
|
||||||
|
|
||||||
|
class DaemonRunnerWrapper(runner.DaemonRunner):
|
||||||
|
# Workaround: fix the "unbuffered bytes I/O for py3" runtime
|
||||||
|
# error in pyhon3 env.
|
||||||
|
# Picked from [starlingx/utilities]:utilities/logmgmt/logmgmt/logmgmt/logmgmt.py
|
||||||
|
# If there will be a saner approach, it must be changed also in utilities repo.
|
||||||
|
def _open_streams_from_app_stream_paths(self, app):
|
||||||
|
self.daemon_context.stdin = open(app.stdin_path, 'rt')
|
||||||
|
self.daemon_context.stdout = open(app.stdout_path, 'w+t')
|
||||||
|
try:
|
||||||
|
self.daemon_context.stderr = open(app.stderr_path, 'w+t', buffering=0)
|
||||||
|
except Exception:
|
||||||
|
self.daemon_context.stderr = open(app.stderr_path, 'wb+', buffering=0)
|
||||||
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# METHODS
|
# METHODS
|
||||||
###################
|
###################
|
||||||
def start_polling():
|
def start_polling():
|
||||||
cfg.read_config()
|
cfg.read_config()
|
||||||
patch_alarm_daemon = PatchAlarmDaemon()
|
patch_alarm_daemon = PatchAlarmDaemon()
|
||||||
alarm_runner = runner.DaemonRunner(patch_alarm_daemon)
|
alarm_runner = DaemonRunnerWrapper(patch_alarm_daemon)
|
||||||
alarm_runner.daemon_context.umask = 0o022
|
alarm_runner.daemon_context.umask = 0o022
|
||||||
alarm_runner.do_action()
|
alarm_runner.do_action()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user