-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
fix: disabe auto remove if debug is enabled #757
fix: disabe auto remove if debug is enabled #757
Conversation
This is awesome! I see one issue with this change: |
Codecov ReportBase: 86.32% // Head: 78.52% // Decreases project coverage by
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #757 +/- ##
==========================================
- Coverage 86.32% 78.52% -7.80%
==========================================
Files 49 48 -1
Lines 2325 2324 -1
==========================================
- Hits 2007 1825 -182
- Misses 165 319 +154
- Partials 153 180 +27
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Good point. I will take a look next week. |
@Haegi correct, because if the |
I implemented it in Haegi@7f3b016. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Haegi, thank you for taking care of container removal. There are a couple of small things I think are still missing. Otherwise this is great😻
docker.go
Outdated
d.lock.Lock() | ||
defer d.lock.Unlock() | ||
|
||
err := d.client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use Force: true
here, just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it here: a2b478c
@@ -252,7 +252,7 @@ func (g *g) stop(c *Container) error { | |||
} | |||
} | |||
|
|||
return nil | |||
return cli.removeContainer(context.Background(), id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle the "in progress" error gracefully (return without error), otherwise - fail with error. The error happens most likely due to the AutoRemove
flag triggering container removal before the code reaches this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take care of it in a2b478c
Thanks :) I also noticed also two other things.
|
Hi @Haegi, Thanks for the updates and sorry for taking long to reply. I like both ideas, but I think investing in the second one is a bit of an overkill right now. The first point is much more important. It would be great if you could take care of it. Waiting for the final fixes to finally release a new version with your fixes 😼 |
No worries :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
The test you are mentioning fails because of the same (or very similar) reason that the other test you fixed was failing: the original test expected an error because it was a "not found" error when trying to stop a container that doesn't exist anymore (it gets replaced with a new container with the same name). Now that we ignore the "not found" error the test doesn't get an expected error, so we basically change the expectations and should not expect an error anymore.
I also left one last comment, and unless I'm missing something, fixing it together with the test will complete that work, and I'll prepare a new release. This is awesome!
docker.go
Outdated
defer d.lock.Unlock() | ||
|
||
err := d.client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true}) | ||
if err != nil && !client.IsErrNotFound(err) && isDeletionAlreadyInProgessError(err, id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think isDeletionAlreadyInProgessError
should be negated just like "not found" error, we want to ignore it instead of failing container removal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the hint! I had to change the logic of isDeletionAlreadyInProgessError
. It seems like it was not really checking for the error. Now I was able to get it right and negate it.
Thanks for the explanation. I removed the error expectation and instead check with the docker client if the container is done. Unfortunately, I noticed some other side effect. gnomockd doesn't return |
I think |
I just changed the test and I also extracted the container listing by id into some helper function called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job, thank you for the contribution!
fixes: #748
Changes
This PR changes the behaviour of the
WithDebugMode
option. If it is specified, the container will not be auto removed.Tests
WithDebugMode
-> should be goneWithDebugMode
-> should be still visible