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

Optionally support removing container before trying to start it #238

Merged

Conversation

solarchad
Copy link
Contributor

@solarchad solarchad commented Jan 16, 2020

PR progress checklist (to be filled in by reviewers)

  • Changes to documentation are appropriate (or tick if not required)
  • Changes to tests are appropriate (or tick if not required)
  • Reviews completed

What type of PR is this?

Primary type

  • [build] Changes related to the build system
  • [chore] Changes to the build process or auxiliary tools and libraries such as documentation generation
  • [ci] Changes to the continuous integration configuration
  • [feat] A new feature
  • [fix] A bug fix
  • [perf] A code change that improves performance
  • [refactor] A code change that neither fixes a bug nor adds a feature
  • [revert] A change used to revert a previous commit
  • [style] Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)

Secondary type

  • [docs] Documentation changes
  • [test] Adding missing or correcting existing tests

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

Describe the changes you're proposing

This should avoid this problem when trying to start the service (and the container was created but not running). For example:

/usr/bin/docker: Error response from daemon: Conflict. The container name "/ecs-agent" is already in use by container "22cb0febefdfe96ba2558dd33329fb428c7ed45a2145361d25e8faf331b18428". You have to remove (or rename) that container to be able to reuse that name.

I hit the problem with the AWS ecs-agent and in their ECS developer guide (on page 212), you can see that they have their systemd unit file using an ExecStartPre to remove the container before trying to start it.

This is useful if say the container gets created from a failed run. If you try to run it again, it will continue to fail because the container was created with the same name.

Pillar / config required to test the proposed changes

See the pillar.example.

Debug log showing how the proposed changes work

Documentation checklist

  • Updated the README (e.g. Available states).
  • Updated pillar.example.

Testing checklist

  • Included in Kitchen (i.e. under state_top).
  • Covered by new/existing tests (e.g. InSpec, Serverspec, etc.).
  • Updated the relevant test pillar.

Additional context

Copy link
Member

@myii myii left a comment

Choose a reason for hiding this comment

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

@solarchad Apologies for the delay and thanks for your contribution. Just a couple of yamllint violations as mentioned inline. We're also using commitlint (for semantic-release):

https://travis-ci.com/saltstack-formulas/docker-formula/jobs/276317943#L374-L379

⧗   input: Optionally support removing container before trying to start it in upstart/systemd
✖   header must not be longer than 72 characters, current length is 82 [header-max-length]
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]
✖   found 3 problems, 0 warnings

So the commit message should be adjusted accordingly to something like:

-Optionally support removing container before trying to start it in upstart/systemd
+feat: support optional container removal before start in upstart/systemd

pillar.example Outdated Show resolved Hide resolved
pillar.example Outdated Show resolved Hide resolved
@solarchad solarchad force-pushed the support-rm-container-prestart branch from 9b8695f to 94f73c6 Compare January 22, 2020 14:03
@solarchad
Copy link
Contributor Author

Thanks @myii. I made these changes but I see that Travis is still unhappy. Is it failing for unrelated reasons now?

@myii
Copy link
Member

myii commented Jan 22, 2020

@solarchad The commitlint is passing now but the yamllint is still failing on the same lines.

https://travis-ci.com/saltstack-formulas/docker-formula/jobs/278367547#L298-L301

$ yamllint -s .
./pillar.example
  18:28     warning  truthy value should be one of [false, true]  (truthy)
  44:28     warning  truthy value should be one of [false, true]  (truthy)

Perhaps you didn't add the changes to the latest commit you pushed?

@solarchad solarchad force-pushed the support-rm-container-prestart branch from 94f73c6 to cc10d97 Compare January 22, 2020 14:32
@solarchad
Copy link
Contributor Author

Whoops, sorry about that. I forgot to add the pillar.example before the last push. Just added it and pushed again. 🤞

Copy link
Member

@myii myii left a comment

Choose a reason for hiding this comment

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

Thanks, looking good now.

@myii myii merged commit 6bf1642 into saltstack-formulas:master Jan 22, 2020
@solarchad solarchad deleted the support-rm-container-prestart branch January 22, 2020 14:41
@saltstack-formulas-travis

🎉 This PR is included in version 0.43.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants