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

Clean up dockertools/manager.go and add more unit tests #7533

Merged
merged 1 commit into from Apr 30, 2015

Conversation

yujuhong
Copy link
Contributor

This function is part of the container runtime interface, so docker should
support it.

This change also adds some basic unit tests in manager_test.go. We should
start migrating docker specific tests from kubelet_test to manager_test.go.

@yujuhong
Copy link
Contributor Author

/cc @vmarmol, @yifan-gu

Not sure if GetContainers is needed anymore. The current use cases are:

  • kubelet.go: GetContainerInfo
  • container_gc.go

If we decide to remove GetContainers from the Runtime interface, I'd do that and close this PR.

@yifan-gu
Copy link
Contributor

I think we had some discussion on this early, I remember @dchen1107 said the GetContainers is for getting not only kubelet containers, but also all containers so user can introspect the state of the node. So we would probably leave it in the interface IMO.

@yujuhong
Copy link
Contributor Author

@yifan-gu, this PR assumes we are getting only the kubelet containers though. If what we want is to list all containers, I'd have to fix the PR. :)

@vmarmol
Copy link
Contributor

vmarmol commented Apr 29, 2015

I think we'll remove it long-term :) From the two uses, the first we can replace with GetPods (I think). The second uses the Docker API directly. I think for the first version we'll disable GC in the rkt runtime as we understand more how Docker does GC. We can use GetPods there in the future (with an "unknown" pod having other containers not associated with a known pod).

I'm fine going this route for now though. It'll simplify what we have to move when the time comes.

for _, c := range actualContainers {
actual.Insert(c.Name)
}
if !reflect.DeepEqual(expected.List(), actual.List()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

won't these be non-deterministically sorted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yujuhong
Copy link
Contributor Author

@vmarmol, I agree that the use cases can probably be eliminated. I think GetPodStatus will be a better replacement for the first cases since we already have pod full name & uid.

What about the reason that @yifan-gu said? Should we get all containers for users to introspect? If that's the main purpose of the function, then this PR needs to change quite a bit because most of the docker code looks at only k8s containers.

@yifan-gu
Copy link
Contributor

@yujuhong I think we can remove this from the runtime interface for now, leave a TODO and add them later...
/cc @dchen1107

@vmarmol
Copy link
Contributor

vmarmol commented Apr 30, 2015

LGTM.

I don't think we need it for that type of introspection, and if we do I think a better mechanism is the "unknown" pod. We can remove it from the runtime (but can we keep the rest of the refactoring you did? I think that's valuable)

@yifan-gu
Copy link
Contributor

Keep the refacoring + 1

This change refactors the GetPods function and add some basic unit tests.
We should start migrating docker specific tests from kubelet_test to
manager_test.go.
@yujuhong yujuhong changed the title Add GetContainers in docker manager Clean up dockertools/manager.go and add more unit tests Apr 30, 2015
@yujuhong
Copy link
Contributor Author

Updated the commit to remove GetContainers and add a unit test for GetPods instead.

I will remove GetContainers from the Runtime interface in another PR (since it's no longer related to this one).

@vmarmol
Copy link
Contributor

vmarmol commented Apr 30, 2015

LGTM, thanks @yujuhong

@yifan-gu
Copy link
Contributor

LGTM

vmarmol added a commit that referenced this pull request Apr 30, 2015
Clean up dockertools/manager.go and add more unit tests
@vmarmol vmarmol merged commit 037295a into kubernetes:master Apr 30, 2015
@yujuhong yujuhong deleted the get_containers branch May 8, 2015 17:36
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.

None yet

4 participants