in pbspro/src/pbspro/driver.py [0:0]
def _validate_reverse_dns(self, node: Node) -> bool:
# let's make sure the hostname is valid and reverse
# dns compatible before adding to GE
# if there is no private ip, then the hostname was removed, most likely
# by azure DNS
if not node.private_ip:
return True
try:
addr_info = socket.gethostbyaddr(node.private_ip)
except Exception as e:
logging.error(
"Could not convert private_ip(%s) to hostname using gethostbyaddr() for %s: %s",
node.private_ip,
node,
str(e),
)
return False
addr_info_ips = addr_info[-1]
if isinstance(addr_info_ips, str):
addr_info_ips = [addr_info_ips]
if node.private_ip not in addr_info_ips:
logging.warning(
"%s has a hostname that does not match the"
+ " private_ip (%s) reported by cyclecloud (%s)! Skipping",
node,
addr_info_ips,
node.private_ip,
)
return False
expect_multiple_entries = (
node.software_configuration.get("cyclecloud", {})
.get("hosts", {})
.get("standalone_dns", {})
.get("enabled", True)
)
addr_info_hostname = addr_info[0].split(".")[0]
if addr_info_hostname.lower() != node.hostname.lower():
if expect_multiple_entries:
logging.warning(
"%s has a hostname that can not be queried via reverse"
+ " dns (private_ip=%s cyclecloud hostname=%s reverse dns hostname=%s)."
+ " This is common and usually repairs itself. Skipping",
node,
node.private_ip,
node.hostname,
addr_info_hostname,
)
else:
logging.error(
"%s has a hostname that can not be queried via reverse"
+ " dns (private_ip=%s cyclecloud hostname=%s reverse dns hostname=%s)."
+ " If you have an entry for this address in your /etc/hosts file, please remove it.",
node,
node.private_ip,
node.hostname,
addr_info_hostname,
)
return False
return True