diff options
Diffstat (limited to 'azurelinuxagent/daemon/main.py')
-rw-r--r-- | azurelinuxagent/daemon/main.py | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/azurelinuxagent/daemon/main.py b/azurelinuxagent/daemon/main.py index b0da02a..5b8db2f 100644 --- a/azurelinuxagent/daemon/main.py +++ b/azurelinuxagent/daemon/main.py @@ -25,12 +25,15 @@ import traceback import azurelinuxagent.common.conf as conf import azurelinuxagent.common.logger as logger import azurelinuxagent.common.utils.fileutil as fileutil + from azurelinuxagent.common.event import add_event, WALAEventOperation from azurelinuxagent.common.future import ustr from azurelinuxagent.common.osutil import get_osutil from azurelinuxagent.common.protocol import get_protocol_util +from azurelinuxagent.common.protocol.wire import WireClient from azurelinuxagent.common.rdma import setup_rdma_device -from azurelinuxagent.common.version import AGENT_LONG_NAME, AGENT_VERSION, \ +from azurelinuxagent.common.version import AGENT_NAME, AGENT_LONG_NAME, \ + AGENT_VERSION, \ DISTRO_NAME, DISTRO_VERSION, PY_VERSION_MAJOR, PY_VERSION_MINOR, \ PY_VERSION_MICRO from azurelinuxagent.daemon.resourcedisk import get_resourcedisk_handler @@ -39,6 +42,8 @@ from azurelinuxagent.ga.update import get_update_handler from azurelinuxagent.pa.provision import get_provision_handler from azurelinuxagent.pa.rdma import get_rdma_handler +OPENSSL_FIPS_ENVIRONMENT = "OPENSSL_FIPS" + def get_daemon_handler(): return DaemonHandler() @@ -53,7 +58,7 @@ class DaemonHandler(object): self.running = True self.osutil = get_osutil() - def run(self): + def run(self, child_args=None): logger.info("{0} Version:{1}", AGENT_LONG_NAME, AGENT_VERSION) logger.info("OS: {0} {1}", DISTRO_NAME, DISTRO_VERSION) logger.info("Python: {0}.{1}.{2}", PY_VERSION_MAJOR, PY_VERSION_MINOR, @@ -61,12 +66,18 @@ class DaemonHandler(object): self.check_pid() + # If FIPS is enabled, set the OpenSSL environment variable + # Note: + # -- Subprocesses inherit the current environment + if conf.get_fips_enabled(): + os.environ[OPENSSL_FIPS_ENVIRONMENT] = '1' + while self.running: try: - self.daemon() + self.daemon(child_args) except Exception as e: err_msg = traceback.format_exc() - add_event("WALA", is_success=False, message=ustr(err_msg), + add_event(name=AGENT_NAME, is_success=False, message=ustr(err_msg), op=WALAEventOperation.UnhandledError) logger.info("Sleep 15 seconds and restart daemon") time.sleep(15) @@ -84,7 +95,7 @@ class DaemonHandler(object): fileutil.write_file(pid_file, ustr(os.getpid())) - def daemon(self): + def daemon(self, child_args=None): logger.info("Run daemon") self.protocol_util = get_protocol_util() @@ -117,6 +128,16 @@ class DaemonHandler(object): logger.info("RDMA capabilities are enabled in configuration") try: + # Ensure the most recent SharedConfig is available + # - Changes to RDMA state may not increment the goal state + # incarnation number. A forced update ensures the most + # current values. + protocol = self.protocol_util.get_protocol() + client = protocol.client + if client is None or type(client) is not WireClient: + raise Exception("Attempt to setup RDMA without Wireserver") + client.update_goal_state(forced=True) + setup_rdma_device() except Exception as e: logger.error("Error setting up rdma device: %s" % e) @@ -124,4 +145,4 @@ class DaemonHandler(object): logger.info("RDMA capabilities are not enabled, skipping") while self.running: - self.update_handler.run_latest() + self.update_handler.run_latest(child_args=child_args) |