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

mutex: Add a logical mutex locking module to help prevent global or per-host race conditions #50382

Closed
wants to merge 1 commit into from

Conversation

aramalipoor
Copy link

@aramalipoor aramalipoor commented Dec 29, 2018

Work in progress

SUMMARY

We usually need to have a global mutex lock to avoid simultaneous ansible playbooks to run from our bastion machine targeting our cluster.

One example is adding a new node to the cluster, which due to many complex tasks involved must be done only once "per cluster" at a time. This needs a global mutex on the bastion machine to prevent other ansible processes to run the same role/tasks.

Another example would be per-host procedures which don't have internal locks.

Before diving deep into creating a custom module it would be great to have your feedbacks on such a module. Is this a good practice to provide users with a mutex locking module at all? Based on current description in mutex.py in this PR, would this be a useful module?

I intend to use file.py's LockFile and create a lock file on the machine that is running the ansible process.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

mutex

Related to issue #31096

Disclaimer: I'm new to python and contributing to Ansible

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 community_review In order to be merged, this PR must follow the community review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. labels Dec 29, 2018
@ansibot
Copy link
Contributor

ansibot commented Dec 29, 2018

The test ansible-test sanity --test boilerplate [explain] failed with 2 errors:

lib/ansible/modules/utilities/logic/mutex.py:0:0: missing: __metaclass__ = type
lib/ansible/modules/utilities/logic/mutex.py:0:0: missing: from __future__ import (absolute_import, division, print_function)

The test ansible-test sanity --test pep8 [explain] failed with 15 errors:

lib/ansible/modules/utilities/logic/mutex.py:21:109: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:23:108: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:27:73: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:32:117: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:39:109: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:50:111: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:51:51: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:59:116: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:60:110: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:66:69: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:79:68: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:84:71: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:126:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/utilities/logic/mutex.py:156:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/utilities/logic/mutex.py:159:1: E305 expected 2 blank lines after class or function definition, found 1

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/utilities/logic/mutex.py:0:0: E324 Value for "default" from the argument_spec (False) for "release_on_exit" does not match the documentation (True)

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Dec 29, 2018
@aramalipoor aramalipoor force-pushed the feature/mutex-module branch 2 times, most recently from 4f05c85 to a52db3e Compare December 29, 2018 15:40
@acalm
Copy link
Contributor

acalm commented Dec 29, 2018 via email

@ansibot
Copy link
Contributor

ansibot commented Dec 29, 2018

The test ansible-test sanity --test pep8 [explain] failed with 4 errors:

lib/ansible/modules/utilities/logic/mutex.py:31:73: W291 trailing whitespace
lib/ansible/modules/utilities/logic/mutex.py:130:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/utilities/logic/mutex.py:158:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/utilities/logic/mutex.py:161:1: E305 expected 2 blank lines after class or function definition, found 1

click here for bot help

@aramalipoor aramalipoor force-pushed the feature/mutex-module branch 4 times, most recently from f359c7b to 61bff16 Compare December 29, 2018 16:10
@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed ci_verified Changes made in this PR are causing tests to fail. labels Dec 29, 2018
@ansibot
Copy link
Contributor

ansibot commented Dec 29, 2018

@AnderEnder @gregswift @jarv @jhoekx @linuxdynasty @tbielawa

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Dec 29, 2018
@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 Jan 6, 2019
@ansibot ansibot added the utilities Utilities category label Feb 15, 2019
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Dec 17, 2019
@ansible ansible locked and limited conversation to collaborators Jan 7, 2020
@aramalipoor aramalipoor deleted the feature/mutex-module branch July 13, 2021 15:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 community_review In order to be merged, this PR must follow the community review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. new_module This PR includes a new module. new_plugin This PR includes a new plugin. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community. utilities Utilities category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants