Skip to content

Commit

Permalink
Adjust a couple of migrations
Browse files Browse the repository at this point in the history
I had forgot the include logic to not run some migrations if the changes
have already taken place. This skip is just the "naive" approach instead
of doing a complete validation that the previous fields have migrated.
  • Loading branch information
JacobCallahan committed Oct 10, 2024
1 parent e264799 commit 70de788
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions broker/config_migrations/v0_6_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def remove_test_nick(config_dict):


def move_ssh_settings(config_dict):
"""Move SSH settings from the top leve into its own chunk."""
"""Move SSH settings from the top level into its own chunk."""
# Check if the migration has already been performed
if "ssh" in config_dict:
return config_dict
logger.debug("Moving SSH settings into their own section.")
ssh_settings = {
"backend": config_dict.pop("ssh_backend", "ssh2-python312"),
Expand All @@ -57,7 +60,7 @@ def move_ssh_settings(config_dict):
def add_thread_limit(config_dict):
"""Add a thread limit to the config."""
logger.debug("Adding a thread limit to the config.")
config_dict["thread_limit"] = None
config_dict["thread_limit"] = config_dict.get("thread_limit")
return config_dict


Expand All @@ -73,6 +76,8 @@ def add_inventory_fields(config_dict):
Action: $action # some special field values are possible, check the wiki
OS: os_distribution os_distribution_version # you can combine multiple values with a space between
"""
if "inventory_fields" in config_dict:
return config_dict
logger.debug("Adding inventory fields to the config.")
config_dict["inventory_fields"] = {
"Host": "hostname",
Expand Down
2 changes: 1 addition & 1 deletion broker/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _resolve_inv_field(field, host_dict, **extras):
if "|" in field:
resolved = [_resolve_inv_field(f.strip(), host_dict, **extras) for f in field.split("|")]
for val in resolved:
if val:
if val and val != "Unknown":
return val
return "Unknown"
# Users can combine multiple values in a single field, so evaluate each
Expand Down

0 comments on commit 70de788

Please sign in to comment.