From a465aa91412cb9eea055c49abea67698e0ee4faf Mon Sep 17 00:00:00 2001 From: Wen Guan Date: Sat, 23 Jul 2022 14:13:38 +0200 Subject: [PATCH 1/2] [ATLASPANDA-624] improve to be able to parse new activemq broker cfg format with port in brokers --- .../agents/conductor/plugins/messaging.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/main/lib/idds/agents/conductor/plugins/messaging.py b/main/lib/idds/agents/conductor/plugins/messaging.py index cce41a02..191830fa 100644 --- a/main/lib/idds/agents/conductor/plugins/messaging.py +++ b/main/lib/idds/agents/conductor/plugins/messaging.py @@ -90,17 +90,22 @@ def connect_to_messaging_brokers(self): broker_addresses = [] for b in self.brokers: try: + if ":" in b: + b, port = b.split(":") + else: + port = self.port + addrinfos = socket.getaddrinfo(b, 0, socket.AF_INET, 0, socket.IPPROTO_TCP) for addrinfo in addrinfos: b_addr = addrinfo[4][0] - broker_addresses.append(b_addr) + broker_addresses.append((b_addr, port)) except socket.gaierror as error: self.logger.error('Cannot resolve hostname %s: %s' % (b, str(error))) self.logger.info("Resolved broker addresses: %s" % broker_addresses) - for broker in broker_addresses: - conn = stomp.Connection12(host_and_ports=[(broker, self.port)], + for broker, port in broker_addresses: + conn = stomp.Connection12(host_and_ports=[(broker, port)], vhost=self.vhost, keepalive=True, timeout=self.broker_timeout) @@ -157,17 +162,22 @@ def subscribe(self): broker_addresses = [] for b in self.brokers: try: + if ":" in b: + b, port = b.split(":") + else: + port = self.port + addrinfos = socket.getaddrinfo(b, 0, socket.AF_INET, 0, socket.IPPROTO_TCP) for addrinfo in addrinfos: b_addr = addrinfo[4][0] - broker_addresses.append(b_addr) + broker_addresses.append((b_addr, port)) except socket.gaierror as error: self.logger.error('Cannot resolve hostname %s: %s' % (b, str(error))) self.logger.info("Resolved broker addresses: %s" % broker_addresses) - for broker in broker_addresses: - conn = stomp.Connection12(host_and_ports=[(broker, self.port)], + for broker, port in broker_addresses: + conn = stomp.Connection12(host_and_ports=[(broker, port)], vhost=self.vhost, keepalive=True) conn.set_listener('message-receiver', self.get_listener(conn.transport._Transport__host_and_ports[0])) From 0631f5fd3f0c6327e2ec8e2c2fe39f684e15ef62 Mon Sep 17 00:00:00 2001 From: Wen Guan Date: Sat, 23 Jul 2022 14:19:25 +0200 Subject: [PATCH 2/2] [ATLASPANDA-625] improve iDDS to mount certs in a different directory from configmap --- common/lib/idds/common/utils.py | 2 ++ start-daemon.sh | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/lib/idds/common/utils.py b/common/lib/idds/common/utils.py index 3e391805..428fde66 100644 --- a/common/lib/idds/common/utils.py +++ b/common/lib/idds/common/utils.py @@ -146,6 +146,8 @@ def get_rest_host(): """ Function to get rest host """ + if "IDDS_HOST" in os.environ: + return os.environ.get("IDDS_HOST") host = config_get('rest', 'host') url_prefix = get_rest_url_prefix() while host.endswith("/"): diff --git a/start-daemon.sh b/start-daemon.sh index 43a0dd86..c37769b3 100755 --- a/start-daemon.sh +++ b/start-daemon.sh @@ -10,10 +10,10 @@ export IDDS_HOME=/opt/idds if [ -f /etc/grid-security/hostkey.pem ]; then echo "host certificate is already created." chmod 600 /etc/grid-security/hostkey.pem -elif [ -f /opt/idds/configmap/hostkey.pem ]; then - echo "mount /opt/idds/configmap/hostkey.pem to /etc/grid-security/hostkey.pem" - ln -fs /opt/idds/configmap/hostkey.pem /etc/grid-security/hostkey.pem - ln -fs /opt/idds/configmap/hostcert.pem /etc/grid-security/hostcert.pem +elif [ -f /opt/idds/certs/hostkey.pem ]; then + echo "mount /opt/idds/certs/hostkey.pem to /etc/grid-security/hostkey.pem" + ln -fs /opt/idds/certs/hostkey.pem /etc/grid-security/hostkey.pem + ln -fs /opt/idds/certs/hostcert.pem /etc/grid-security/hostcert.pem chmod 600 /etc/grid-security/hostkey.pem fi