Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial attempts to automatically clean up dangling hosts #337

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JacobCallahan
Copy link
Member

@JacobCallahan JacobCallahan commented Nov 19, 2024

Now, when workflows fail, Broker will attempt to find a dangling host and check it in if found.

@JacobCallahan JacobCallahan added the enhancement New feature or request label Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no suggestions.

Comments skipped due to low confidence (2)

broker/providers/ansible_tower.py:381

  • Check for the existence of 'node.summary_fields["job"]' and 'node.summary_fields["job"]["failed"]' before accessing them to avoid potential KeyError.
if node.summary_fields["job"]["failed"]:

broker/providers/ansible_tower.py:388

  • Ensure that 'job' is not None before proceeding to avoid potential AttributeError.
def _try_checkin_dangling_host(self, job):
@JacobCallahan JacobCallahan force-pushed the cleanup branch 3 times, most recently from ed68222 to 6d65d28 Compare November 22, 2024 03:35
@JacobCallahan JacobCallahan marked this pull request as ready for review November 26, 2024 13:33
@JacobCallahan JacobCallahan force-pushed the cleanup branch 2 times, most recently from 47c310f to 17b419f Compare November 26, 2024 21:05
@JacobCallahan JacobCallahan marked this pull request as draft November 26, 2024 21:05

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no suggestions.

Comments skipped due to low confidence (1)

broker/config_manager.py:102

  • The condition 'and "example" not in module.name' could be more specific to avoid false positives.
if hasattr(module, "run_migrations") and "example" not in module.__name__:
@JacobCallahan JacobCallahan force-pushed the cleanup branch 2 times, most recently from 8c7ce23 to e46159d Compare December 2, 2024 21:04
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR introduces automatic clean‐up for dangling hosts by adding a configuration migration and extending the AnsibleTower provider to handle dangling hosts when workflows fail.

  • Adds a new migration (v0_6_3.py) to set a default dangling_behavior of "checkin" for AnsibleTower.
  • Implements new methods (_try_get_dangling_hosts and handle_dangling_hosts) in the AnsibleTower provider with support for prompting the user.
  • Adjusts the config manager to bypass example migrations when running migrations.

Reviewed Changes

File Description
broker/config_migrations/v0_6_3.py New migration adding default dangling_behavior configuration
broker/config_migrations/example_migration.py Provides template for creating new migrations
broker/providers/ansible_tower.py Implements dangling host cleanup logic and user prompt
broker/config_manager.py Filters out example migrations from the migrations list

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR introduces an initial implementation for automatically cleaning up dangling hosts left behind by failed workflows in Broker’s AnsibleTower provider. The changes include:

  • A new configuration migration (v0_6_3.py) that adds a "dangling_behavior" setting to AnsibleTower.
  • Extensions to the AnsibleTower provider with new methods for detecting and handling dangling hosts, including an interactive prompt option.
  • A minor update to the configuration manager to exclude example migration modules from execution.

Reviewed Changes

File Description
broker/config_migrations/v0_6_3.py Adds a migration function to introduce "dangling_behavior".
broker/providers/ansible_tower.py Enhances the provider with methods (_try_get_dangling_hosts & handle_dangling_hosts) and adjusts configuration handling.
broker/config_migrations/example_migration.py Provides an example migration file with usage instructions.
broker/config_manager.py Updates migration discovery to skip example migration modules.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

Now, when workflows fail, Broker will attempt to find a handgling host
and check it in if found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants