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

Introduce public methods to access PlayIterator._host_states #74416

Merged
merged 2 commits into from Nov 9, 2021

Conversation

mkrizek
Copy link
Contributor

@mkrizek mkrizek commented Apr 26, 2021

SUMMARY

Per #74175 (comment)

ci_complete

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/executor/play_iterator.py

@ansibot ansibot added WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. affects_2.12 feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Apr 26, 2021
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Apr 27, 2021
@mkrizek mkrizek marked this pull request as ready for review April 27, 2021 15:49
@mkrizek mkrizek requested review from bcoca and Shrews April 27, 2021 15:49
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. labels Apr 27, 2021
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label May 5, 2021
@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jun 8, 2021
@mkrizek mkrizek force-pushed the PlayIterator-set_state-methods branch from ea74f48 to 40aa705 Compare October 26, 2021 11:19
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Oct 26, 2021
raise AnsibleAssertionError('Expected run_state to be a IteratingStates but was %s' % (type(run_state)))
self._host_states[hostname].run_state = run_state

def set_fail_state_for_host(self, hostname, fail_state):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An alternative would be to have clear_fail_state_for_host that would set fail_state to FailedState.NONE and set_fail_state_for_host that would do fail_state |= .... But it is not needed at the moment, so ¯_(ツ)_/¯

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Nov 3, 2021
Copy link
Member

@nitzmahone nitzmahone left a comment

Choose a reason for hiding this comment

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

Agreed, this is another long-needed change; also allows us to intercept/log these changes in the future for $reasons much easier than attrs did. Change looks good, just an open question if we want to add type annotations on the new public methods.

self._host_states[host.name] = self._insert_tasks_into_state(self.get_host_state(host), task_list)
self.set_state_for_host(host.name, self._insert_tasks_into_state(self.get_host_state(host), task_list))

def set_state_for_host(self, hostname, state):
Copy link
Member

Choose a reason for hiding this comment

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

Since this is new public API that's 3.8+, any reason we shouldn't type annotate these methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1, added.

@mkrizek mkrizek force-pushed the PlayIterator-set_state-methods branch from 40aa705 to efd4cad Compare November 8, 2021 08:54
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Nov 8, 2021
@mkrizek mkrizek merged commit 5c225dc into ansible:devel Nov 9, 2021
@mkrizek mkrizek deleted the PlayIterator-set_state-methods branch November 9, 2021 07:07
@ansible ansible locked and limited conversation to collaborators Nov 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.12 core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants