# contact: bdiaz@whitestack.com or glavado@whitestack.com
##
-FROM ubuntu:16.04
+FROM ubuntu:20.04
-LABEL authors="Benjamín Díaz"
+LABEL authors="Benjamín Díaz, Fabián Bravo"
RUN apt-get --yes update \
&& apt-get --yes install python3 python3-pip libmysqlclient-dev git mysql-client \
ENV OSMPOL_GLOBAL_LOGLEVEL INFO
-HEALTHCHECK --interval=5s --timeout=2s --retries=12 \
+HEALTHCHECK --interval=10s --timeout=5s --retries=10 --start-period=30s \
CMD osm-pol-healthcheck || exit 1
CMD /bin/bash /policy_module/docker/scripts/start.sh
\ No newline at end of file
import asyncio
import logging
import sys
+import os
from osm_policy_module.core.agent import PolicyModuleAgent
from osm_policy_module.core.config import Config
def main():
+ # Cleanup old temp health file
+ if os.path.exists('/tmp/osm_pol_agent_health_flag'):
+ os.remove('/tmp/osm_pol_agent_health_flag')
+
parser = argparse.ArgumentParser(prog='osm-policy-agent')
parser.add_argument('--config-file', nargs='?', help='POL configuration file')
args = parser.parse_args()
import logging
import subprocess
import sys
+import os
log = logging.getLogger(__name__)
if not _contains_process(processes_running, p):
log.error("Process %s not running!" % p)
return False
- return True
+
+ # Check if process is running properly (listening to kafka bus)
+ if os.path.exists('/tmp/osm_pol_agent_health_flag'):
+ return True
+ else:
+ return False
if __name__ == '__main__':
##
import asyncio
import logging
+from pathlib import Path
+import os
import peewee
self.loop.run_until_complete(self.start())
async def start(self):
+ Path('/tmp/osm_pol_agent_health_flag').touch()
topics = [
"ns",
"alarm_response"
]
await self.msg_bus.aioread(topics, self._process_msg)
log.critical("Exiting...")
+ if os.path.exists('/tmp/osm_pol_agent_health_flag'):
+ os.remove('/tmp/osm_pol_agent_health_flag')
async def _process_msg(self, topic, key, msg):
+ Path('/tmp/osm_pol_agent_health_flag').touch()
log.debug("_process_msg topic=%s key=%s msg=%s", topic, key, msg)
try:
if key in ALLOWED_KAFKA_KEYS: