mirror of
https://github.com/ansible/awx.git
synced 2026-02-01 01:28:09 -03:30
Recover rsyslog from 4xx error
Due to https://github.com/ansible/awx/issues/7560 'omhttp' module for rsyslog will completely stop forwarding message to external log aggregator after receiving a 4xx error from the external log aggregator This PR is an "workaround" for this problem by restarting rsyslogd after detecting that rsyslog received a 4xx error
This commit is contained in:
@@ -11,12 +11,10 @@ def write_stdout(s):
|
||||
sys.stdout.write(s)
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def write_stderr(s):
|
||||
sys.stderr.write(s)
|
||||
sys.stderr.flush()
|
||||
|
||||
|
||||
def main():
|
||||
while 1:
|
||||
write_stdout("READY\n")
|
||||
@@ -31,23 +29,6 @@ def main():
|
||||
except ValueError as e:
|
||||
write_stderr(str(e))
|
||||
|
||||
# now decide what do to based on eventnames
|
||||
if headers["eventname"] == "PROCESS_STATE_FATAL":
|
||||
headers.update(
|
||||
dict(
|
||||
[x.split(":") for x in sys.stdin.read(int(headers["len"])).split()]
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
# incoming event that produced PROCESS_STATE_FATAL will have a PID. SIGTERM it!
|
||||
write_stderr(
|
||||
f"{datetime.datetime.now(timezone.utc)} - sending SIGTERM to proc={headers} with data={headers}\n"
|
||||
)
|
||||
os.kill(headers["pid"], signal.SIGTERM)
|
||||
except Exception as e:
|
||||
write_stderr(str(e))
|
||||
|
||||
# awx-rsyslog PROCESS_LOG_STDERR handler
|
||||
if headers["eventname"] == "PROCESS_LOG_STDERR":
|
||||
# pertinent data to process that produced PROCES_LOG_STDERR is in the first line of the data payload; so lets extract it
|
||||
Reference in New Issue
Block a user