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_compose - Fix timeout defaulting behavior #163

Merged

Conversation

Ajpantuso
Copy link
Collaborator

@Ajpantuso Ajpantuso commented Jun 26, 2021

SUMMARY

Removed overwriting of default timeout so stop_grace_period can be correctly read from compose files.
Fixes #25

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

plugins/modules/docker_compose.py

ADDITIONAL INFORMATION
  • timeout documentation required default: null since a doc fragment this module extends already defines timeout with default: 60.

After the change the following example from #25 :

 tasks:
     - name: remove pre-existing container to clear logs from previous run
       docker_compose:
         project_src: "{{ project_src }}"
         services:
           - foo
         state: absent

     - name: start service
       docker_compose:
         project_src: "{{ project_src }}"
         services:
           - foo
         state: present

     - name: stop service
       docker_compose:
         project_src: "{{ project_src }}"
         services:
           - foo
         state: present
         stopped: yes

     - command: docker logs applications_foo_1
       register: output

     - debug:
         msg: "{{ output.stdout }}"

results in:

PLAY [localhost] ************************************************************************************************************************************************************************************************

TASK [remove pre-existing container to clear logs from previous run] ********************************************************************************************************************************************
changed: [localhost]

TASK [start service] ********************************************************************************************************************************************************************************************
changed: [localhost]

TASK [stop service] *********************************************************************************************************************************************************************************************
changed: [localhost]

TASK [command] **************************************************************************************************************************************************************************************************
changed: [localhost]

TASK [debug] ****************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "script has started\nreceived SIGTERM\nexited cleanly"
}

PLAY RECAP ******************************************************************************************************************************************************************************************************
localhost                  : ok=5    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Copy link
Collaborator

@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.

Isn't this a breaking change?

@Ajpantuso
Copy link
Collaborator Author

Isn't this a breaking change?

I detailed why it wasn't on the issue thread
Basically the module was enforcing a timeout before compose could apply it's defaulting logic and it was doing this by importing the DEFAULT_TIMEOUT setting from compose. So letting compose handle the defaulting itself results in the same timeout settings. I guess it's only breaking if this module never intended to honor stop_grace_period.

@Ajpantuso Ajpantuso marked this pull request as ready for review June 26, 2021 12:29
@felixfontein
Copy link
Collaborator

Well, it's still a breaking change, since in some cases (user had a different timeout in the service description than the default value) the module will change behavior. I tend to agree with @aaron-kaplan on:

Given that this is long-standing behavior, it might not be a good idea to change the default, but perhaps we could introduce a distinguished timeout value that lets the user explicitly specify that the timeout configured in the project should be used.

I think we should probably keep this for the 2.0.0 release and add a breaking_change changelog fragment. That way, if someone really needs the old behavior, they won't get surprised in a minor release.

@Ajpantuso
Copy link
Collaborator Author

Well, it's still a breaking change, since in some cases (user had a different timeout in the service description than the default value) the module will change behavior. I tend to agree with @aaron-kaplan on:

Given that this is long-standing behavior, it might not be a good idea to change the default, but perhaps we could introduce a distinguished timeout value that lets the user explicitly specify that the timeout configured in the project should be used.

I think we should probably keep this for the 2.0.0 release and add a breaking_change changelog fragment. That way, if someone really needs the old behavior, they won't get surprised in a minor release.

Updated the changelog fragment.
On a side note I was going to implement profiles for docker_compose since that's only a few lines of implementation (and the CLI option is bugged such that it only works when bringing services up so not much to test), but I can hold that for after 1.8.0 if you don't want to wait.

@felixfontein felixfontein added the breaking_change This PR contains a breaking change that MUST wait for the next major release label Jun 27, 2021
@felixfontein
Copy link
Collaborator

Updated the changelog fragment.

Thanks! I guess we'll start with the 2.0.0 preparations somewhen in September; I'll merge this PR then.

On a side note I was going to implement profiles for docker_compose since that's only a few lines of implementation (and the CLI option is bugged such that it only works when bringing services up so not much to test), but I can hold that for after 1.8.0 if you don't want to wait.

Feel free to start working on that now if you want. If the PR is done merged before I do the 1.8.0 release (probably on Tuesday morning), it will be in 1.8.0, otherwise it has to wait for 1.9.0.

@felixfontein
Copy link
Collaborator

Restarting tests.

@felixfontein felixfontein reopened this Oct 5, 2021
@felixfontein felixfontein merged commit 14f15c0 into ansible-collections:main Oct 5, 2021
@felixfontein
Copy link
Collaborator

@Ajpantuso thanks for contributing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change This PR contains a breaking change that MUST wait for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker_compose module uses inappropriate stop timeout
2 participants