Skip to content

Commit

Permalink
Add contextual awareness to host creation
Browse files Browse the repository at this point in the history
This change fixes an issue we're seeing where host entries, missing a
hostname and ip, are being reconstructed for checkin. While that shouldn't
be an issue during checkin, it would be if used for other purposes.

With that in mind, this adds a check to see if the host is being
reconstructed. If so, then it will just debug log instead of raising an
error.
  • Loading branch information
JacobCallahan committed May 1, 2023
1 parent 33c9741 commit 1188908
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion broker/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ def __init__(self, hostname=None, name=None, from_dict=False, **kwargs):
else:
self.hostname = hostname or kwargs.get("ip", None)
if not self.hostname:
raise HostError("Host must be constructed with a hostname or ip")
# check to see if we're being reconstructued, likely for checkin
import inspect
if any(f.function == "reconstruct_host" for f in inspect.stack()):
logger.debug("Ignoring missing hostname and ip for checkin reconstruction.")
else:
raise HostError("Host must be constructed with a hostname or ip")
self.name = name
self.username = kwargs.get("username", settings.HOST_USERNAME)
self.password = kwargs.get("password", settings.HOST_PASSWORD)
Expand Down

0 comments on commit 1188908

Please sign in to comment.