Skip to content

Add AutoRemove to HostConfig #1050

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

Merged

Conversation

rnacher
Copy link
Contributor

@rnacher rnacher commented Jun 7, 2018

I would like to be able to set this flag to a container creation. This is was added a long time ago to docker API 1.25+
It is related to issues: #792 and #979
I think that comments done in #336 are overdue now. I mean that version docker API 1.25 was not released at that time.


This change is Reviewable

@Override
@JsonIgnore
public Boolean getAutoRemove() {
return hostConfig.getAutoRemove();
Copy link
Member

Choose a reason for hiding this comment

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

don't proxy calls to hostconfig. If you need this value get hostconfig object and get value from it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am confused because I just did the same as it is already done with other HostConfig properties. I wanted to follow the same architectural implementation. Please, take a look at pidMode,oomKillDisable, publishAllPorts and so many others properties of HostConfig.

@codecov-io
Copy link

codecov-io commented Jun 8, 2018

Codecov Report

Merging #1050 into master will decrease coverage by 2.22%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1050      +/-   ##
==========================================
- Coverage   59.34%   57.11%   -2.23%     
==========================================
  Files         441      441              
  Lines        8692     8694       +2     
  Branches      528      528              
==========================================
- Hits         5158     4966     -192     
- Misses       3246     3455     +209     
+ Partials      288      273      -15
Impacted Files Coverage Δ
...ockerjava/core/command/CreateContainerCmdImpl.java 53.19% <ø> (-0.16%) ⬇️
...va/com/github/dockerjava/api/model/HostConfig.java 59.45% <33.33%> (-0.55%) ⬇️
...ain/java/com/github/dockerjava/api/model/Node.java 0% <0%> (-93.75%) ⬇️
.../com/github/dockerjava/jaxrs/ApacheUnixSocket.java 0% <0%> (-47.2%) ⬇️
...ckerjava/core/command/PullImageResultCallback.java 40.38% <0%> (-40.39%) ⬇️
...n/java/org/newsclub/net/unix/AFUNIXSocketImpl.java 0% <0%> (-37.08%) ⬇️
.../dockerjava/jaxrs/UnixConnectionSocketFactory.java 35.71% <0%> (-35.72%) ⬇️
...va/jaxrs/filter/ResponseStatusExceptionFilter.java 53.84% <0%> (-15.39%) ⬇️
.../github/dockerjava/api/model/PullResponseItem.java 50% <0%> (-12.5%) ⬇️
...ckerjava/api/command/InspectContainerResponse.java 71.62% <0%> (-12.17%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b637e28...8408403. Read the comment docs.

@rnacher
Copy link
Contributor Author

rnacher commented Jun 12, 2018

Review status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @KostyaSha)


src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java, line 202 at r1 (raw file):

Previously, rnacher (Ricard Nàcher Roig) wrote…

I am confused because I just did the same as it is already done with other HostConfig properties. I wanted to follow the same architectural implementation. Please, take a look at pidMode,oomKillDisable, publishAllPorts and so many others properties of HostConfig.

Done.


Comments from Reviewable

@rnacher
Copy link
Contributor Author

rnacher commented Jun 12, 2018

Can you help me to understand travis-ci errors? I don't know how to fix them.
I think that this PR is really a small change and it is not the final cause of them, isn't it?
Error response from daemon: datastore for scope "global" is not initialized
Please, let me know anything else I should do.

thanks

@@ -529,6 +530,13 @@ public CreateContainerCmd withAttachStdout(Boolean attachStdout) {
return this;
}

@Override
public CreateContainerCmd withAutoRemove(Boolean autoRemove) {
Copy link
Member

Choose a reason for hiding this comment

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

remove this chain, you are adding method for hostconfig, not for createcontainerCmdImpl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am sorry but I don't understand your request. I mean that right now, all other parameters of HostConfig can be set following a chain of setters in both CreateContainerCmd/Impl and in HostConfig. You can take a look at withCapDrop, withBinds, withDevices and so on. Do you want that autoRemove attribute would be different to all others? Why should this attribute be different? What do I misunderstand?

Copy link
Member

Choose a reason for hiding this comment

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

because it's old code that is keeping for backward compatibility. It's nightmware to proxy(chain) all possible fields via one class, docker-java is tied to api, not to CLI. So just remove redundant chain for new code.

Copy link
Contributor Author

@rnacher rnacher Jun 12, 2018

Choose a reason for hiding this comment

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

OK. I understood it!
What do you think about adding a @deprecated annotation to all these "old" methods, to avoid coding in this unwanted way? Maybe @silvestre (#1052) and I would not have done the same!

Copy link
Member

Choose a reason for hiding this comment

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

I thought i documented it somewhere. In future methods will be just removed.

@KostyaSha
Copy link
Member

and remove extra new lines 👍

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.

3 participants