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

docker_container - #65993 - update restart policy (restart policy & restart retries) wit… #66192

Merged
merged 7 commits into from Jan 6, 2020
Merged

docker_container - #65993 - update restart policy (restart policy & restart retries) wit… #66192

merged 7 commits into from Jan 6, 2020

Conversation

winem
Copy link
Contributor

@winem winem commented Jan 5, 2020

SUMMARY

Fixes #65993 and allows to change the restart policy without restarting the container.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/modules/cloud/docker/docker_container.py

ADDITIONAL INFORMATION

I ran several test cases on my own dev environment and hope that I covered all cases.

Let me share one of the minified inventories to test it:

---
- hosts: all
  gather_facts: false
  roles:
    - single-docker-container
---
- name: Create a data container
  local_action:
    module: docker_container
    name: my-test-container2
    image: python:3.6
    command: /bin/sleep 600
    restart_policy: 'always'
    #restart_retries: 33

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 cloud community_review In order to be merged, this PR must follow the community review workflow. docker 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. python3 support:community This issue/PR relates to code supported by the Ansible community. labels Jan 5, 2020
@ansibot
Copy link
Contributor

ansibot commented Jan 5, 2020

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

lib/ansible/modules/cloud/docker/docker_container.py:1437:53: E127: continuation line over-indented for visual indent

click here for bot help

@ansibot ansibot added 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 Jan 5, 2020
Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Besides the comments below, you also need to add a changelog fragment: https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#changelogs-how-to

Something like

bugfixes:
 - "docker_container - changes to ``restart_policy`` and ``restart_retries`` now update the container instead of recreating it, if supported by the docker daemon."

lib/ansible/modules/cloud/docker/docker_container.py Outdated Show resolved Hide resolved
lib/ansible/modules/cloud/docker/docker_container.py Outdated Show resolved Hide resolved
lib/ansible/modules/cloud/docker/docker_container.py Outdated Show resolved Hide resolved
lib/ansible/modules/cloud/docker/docker_container.py Outdated Show resolved Hide resolved
lib/ansible/modules/cloud/docker/docker_container.py Outdated Show resolved Hide resolved
@felixfontein felixfontein changed the title #65993 - update restart policy (restart policy & restart retries) wit… docker_container - #65993 - update restart policy (restart policy & restart retries) wit… Jan 5, 2020
@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Jan 5, 2020
- set restart_policy to the correct value independent from the api version
- add a new variable for the restart_policy configuration value
@winem
Copy link
Contributor Author

winem commented Jan 5, 2020

All done. Many thanks for the review and all your input! Some of them are smart solutions to things I was not completely satisfied by before.

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. community_review In order to be merged, this PR must follow the community review workflow. labels Jan 5, 2020
@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jan 5, 2020
@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. labels Jan 6, 2020
Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

shipit

@ansibot ansibot added automerge This PR was automatically merged by ansibot. shipit This PR is ready to be merged by Core and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jan 6, 2020
@felixfontein felixfontein merged commit 02c126f into ansible:devel Jan 6, 2020
@felixfontein
Copy link
Contributor

@winem thanks a lot for fixing this! I'll create backport PRs so this fix will propagate to 2.9.x and 2.8.x.

felixfontein pushed a commit to felixfontein/ansible that referenced this pull request Jan 6, 2020
…icy & restart retries) wit… (ansible#66192)

* ansible#65993 - update restart policy (restart policy & restart retries) without restarting the container

* - proper indentation on the continuation-line
- set restart_policy to the correct value independent from the api version

* - move restart_policy definitions into the if block
- add a new variable for the restart_policy configuration value

* add changelog fragment

* typo; minus -> underscore

* rename changelog fragment to contain the correct module name

* rename restart_policy_config_value to just restart_policy and refer to the correct dict values

(cherry picked from commit 02c126f)
felixfontein pushed a commit to felixfontein/ansible that referenced this pull request Jan 6, 2020
…icy & restart retries) wit… (ansible#66192)

* ansible#65993 - update restart policy (restart policy & restart retries) without restarting the container

* - proper indentation on the continuation-line
- set restart_policy to the correct value independent from the api version

* - move restart_policy definitions into the if block
- add a new variable for the restart_policy configuration value

* add changelog fragment

* typo; minus -> underscore

* rename changelog fragment to contain the correct module name

* rename restart_policy_config_value to just restart_policy and refer to the correct dict values

(cherry picked from commit 02c126f)
@mweinberg-cm
Copy link

Thanks for your input. This was really helpful to get "back" into programming and is appreciated. I'll take a look at your activities regarding the backport, too. Great chance to learn.

mattclay pushed a commit that referenced this pull request Jan 10, 2020
…estart retries) wit… (#66192)

* #65993 - update restart policy (restart policy & restart retries) without restarting the container

* - proper indentation on the continuation-line
- set restart_policy to the correct value independent from the api version

* - move restart_policy definitions into the if block
- add a new variable for the restart_policy configuration value

* add changelog fragment

* typo; minus -> underscore

* rename changelog fragment to contain the correct module name

* rename restart_policy_config_value to just restart_policy and refer to the correct dict values

(cherry picked from commit 02c126f)
mattclay pushed a commit that referenced this pull request Jan 10, 2020
…estart retries) wit… (#66192)

* #65993 - update restart policy (restart policy & restart retries) without restarting the container

* - proper indentation on the continuation-line
- set restart_policy to the correct value independent from the api version

* - move restart_policy definitions into the if block
- add a new variable for the restart_policy configuration value

* add changelog fragment

* typo; minus -> underscore

* rename changelog fragment to contain the correct module name

* rename restart_policy_config_value to just restart_policy and refer to the correct dict values

(cherry picked from commit 02c126f)
@ansible ansible locked and limited conversation to collaborators Feb 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 automerge This PR was automatically merged by ansibot. cloud docker 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. python3 shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker_container: Always recreates the container when restart_policy is changed
4 participants