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

[cli] run --rm overrides restart: always #1205

Merged
merged 2 commits into from
Apr 21, 2015
Merged

[cli] run --rm overrides restart: always #1205

merged 2 commits into from
Apr 21, 2015

Conversation

josephpage
Copy link

Fix #1013

I think docs is not needed because it's an intuitive behavior.

@josephpage
Copy link
Author

All tests pass on local, why they failed with Jenkins ?

@aanand
Copy link

aanand commented Mar 27, 2015

Your commit needs signing off:

$ git commit --amend --reuse-message=HEAD --signoff
$ git push --force

@aanand
Copy link

aanand commented Mar 27, 2015

Also, could we get an integration test please? Thanks!

#1013

Signed-off-by: Joseph Page <joseph.page@rednet.io>
@josephpage
Copy link
Author

@aanand Because the container is created and immediately removed by docker-compose run --rm command, it's difficult to test that the container doesn't have a restart policy.
Note that the --rm option is not tested today.

What do you think about it ?

    @patch('dockerpty.start')
    def test_run_service_with_restart_always(self, __):
        name = 'simple'
        self.command.base_dir = 'tests/fixtures/restart-composefile'

        self.command.dispatch(['run', name, '/bin/echo', 'helloworld'], None)
        service = self.project.get_service(name)
        container = service.containers(one_off=True)[0]
        self.assertEqual(container.get('HostConfig.RestartPolicy.Name'), 'always')

        self.command.dispatch(['run', '--rm', name, '/bin/echo', 'helloworld'], None)
        self.assertEqual(len(service.containers()), 0)
        self.assertEqual(len(service.containers(stopped=True)), 0)

with this tests/fixtures/restart-composefile/docker-compose.yml :

simple:
  image: busybox:latest
  restart: always

@aanand
Copy link

aanand commented Mar 31, 2015

Hm, good point. In that case, maybe just a unit test - use mock_client to check that create_container() is called with restart=None.

Signed-off-by: Joseph Page <joseph.page@rednet.io>
@josephpage
Copy link
Author

Just added a unit test. Seems good to you @aanand ?

@jaimegildesagredo
Copy link

@aanand some updates here? we would need this fix merged. If I can be of some help just ping me.

@dnephin
Copy link

dnephin commented Apr 15, 2015

LGTM

@aanand
Copy link

aanand commented Apr 21, 2015

OK, looks like the CLI code is too tightly coupled to improve that unit test without a lot of refactoring.

LGTM

aanand added a commit that referenced this pull request Apr 21, 2015
[cli] run --rm overrides restart: always
@aanand aanand merged commit b317071 into docker:master Apr 21, 2015
@aanand aanand added this to the 1.3.0 milestone Apr 21, 2015
@josephpage josephpage deleted the run-rm-restart branch May 30, 2015 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker-compose run command continuously restarting
4 participants