diff --git a/deploy-agent/deployd/__init__.py b/deploy-agent/deployd/__init__.py index e56287e1fe..512642c618 100644 --- a/deploy-agent/deployd/__init__.py +++ b/deploy-agent/deployd/__init__.py @@ -27,4 +27,4 @@ # 2: puppet applied successfully with changes PUPPET_SUCCESS_EXIT_CODES = [0, 2] -__version__ = '1.2.59' \ No newline at end of file +__version__ = '1.2.60' \ No newline at end of file diff --git a/deploy-agent/deployd/client/client.py b/deploy-agent/deployd/client/client.py index da8a4ac31e..549833608c 100644 --- a/deploy-agent/deployd/client/client.py +++ b/deploy-agent/deployd/client/client.py @@ -3,9 +3,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ class Client(BaseClient): - def __init__(self, config=None, hostname=None, ip=None, hostgroup=None, + def __init__(self, config=None, hostname=None, ip=None, hostgroup=None, host_id=None, use_facter=None, use_host_info=False) -> None: self._hostname = hostname self._ip = ip @@ -145,13 +145,18 @@ def _read_host_info(self) -> bool: if IS_PINTEREST and self._use_host_info is False: # Read new keys from facter always az_key = self._config.get_facter_az_key() + secondary_az_key = self._config.get_facter_secondary_az_key() asg_tag_key = self._config.get_facter_asg_tag_key() ec2_tags_key = self._config.get_facter_ec2_tags_key() stage_type_key = self._config.get_stage_type_key() account_id_key = self._config.get_facter_account_id_key() keys_to_fetch = set() - if not self._availability_zone and az_key: - keys_to_fetch.add(az_key) + + if not self._availability_zone: + if az_key: + keys_to_fetch.add(az_key) + if secondary_az_key: + keys_to_fetch.add(secondary_az_key) if not self._autoscaling_group: keys_to_fetch.add(ec2_tags_key) @@ -168,6 +173,9 @@ def _read_host_info(self) -> bool: if not self._availability_zone: self._availability_zone = facter_data.get(az_key, None) + if not self._availability_zone: + self._availability_zone = facter_data.get(secondary_az_key, None) + # Hosts brought up outside of ASG or Teletraan might not have ASG # Note: on U14, facter -p ec2_tags.Autoscaling does not work. # so need to read ec2_tags from facter and parse Autoscaling tag to cover this case @@ -190,7 +198,7 @@ def _read_host_info(self) -> bool: log.info("Host information is loaded. " "Host name: {}, IP: {}, host id: {}, agent_version={}, autoscaling_group: {}, " - "availability_zone: {}, ec2_tags: {}, stage_type: {}, group: {}, account id: {}".format(self._hostname, self._ip, self._id, + "availability_zone: {}, ec2_tags: {}, stage_type: {}, group: {}, account id: {}".format(self._hostname, self._ip, self._id, self._agent_version, self._autoscaling_group, self._availability_zone, self._ec2_tags, self._stage_type, self._hostgroup, self._account_id)) if not self._availability_zone: diff --git a/deploy-agent/deployd/common/config.py b/deploy-agent/deployd/common/config.py index ff7e9b25c2..0b26e59ad2 100644 --- a/deploy-agent/deployd/common/config.py +++ b/deploy-agent/deployd/common/config.py @@ -282,6 +282,9 @@ def get_deploy_agent_version(self) -> str: def get_facter_az_key(self) -> Optional[str]: return self.get_var('availability_zone_key', None) + def get_facter_secondary_az_key(self) -> Optional[str]: + return self.get_var('secondary_availability_zone_key', 'ec2_metadata.placement.availability-zone') + def get_facter_ec2_tags_key(self) -> Optional[str]: return self.get_var('ec2_tags_key', None)