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

kubelet: refactor kubecontainer.Pod, remove PodStatus from it. #12880

Merged
merged 1 commit into from Aug 21, 2015

Conversation

yifan-gu
Copy link
Contributor

Related to #12619
Remove the PodStatus in kubecontainer.Pod.

@yifan-gu
Copy link
Contributor Author

/cc @yujuhong @dchen1107

@k8s-bot
Copy link

k8s-bot commented Aug 18, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

func (r *runtime) GetPodStatus(pod *api.Pod) (*api.PodStatus, error) {
pods, err := r.GetPods(true)
unitNames, err := listUnitFiles()
Copy link
Contributor

Choose a reason for hiding this comment

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

Listing all unit files on every GetPodStatus() call seems very expensive considering that we poll for Pod Status periodically as of now. Are there any alternatives to this approach? Inotify or cache unit files relevant to a pod, etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vishh Thanks for catching, yes, this involes a bunch of calls to stat. I will add a TODO here to optimize later. (e.g. list unit files at the first time when kubelet starts, and record every creation of the unit file names later, we just need the names here.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are welcome :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Docker is in the similar boat as it has to do to docker ps -a to list all containers in order to achieve this. Hopefully adding the runtime pod cache would solve this problem :)

@vishh
Copy link
Contributor

vishh commented Aug 18, 2015

ok to test

@vishh
Copy link
Contributor

vishh commented Aug 18, 2015

@yifan-gu: LGTM except for the one comment.

@k8s-bot
Copy link

k8s-bot commented Aug 18, 2015

GCE e2e build/test passed for commit 31e6ec8ab2da50d387a655f62bd0172342dd5156.

@yifan-gu
Copy link
Contributor Author

@yujuhong Any feedback on the this? Note I am not adding ContainerStatus in kubecontainer.Container here, nor the PodIP in kubecontainer.Pod as AFAICS they are included in the PodStatus. But maybe you have some specific reason to add ContainerStatus in kubecontainer.Container?

@k8s-bot
Copy link

k8s-bot commented Aug 18, 2015

GCE e2e build/test passed for commit 69f796f.

@yujuhong
Copy link
Contributor

@yifan-gu, my email setting for github is messed up, so I didn't get the notification. I will look at this asap. Thanks!

@yujuhong
Copy link
Contributor

@yujuhong Any feedback on the this? Note I am not adding ContainerStatus in kubecontainer.Container here, nor the PodIP in kubecontainer.Pod as AFAICS they are included in the PodStatus. But maybe you have some specific reason to add ContainerStatus in kubecontainer.Container?

@yifan-gu, I don't necessary want the ContainerStatus here, but I'd like Pod to include all the information necessary for kubelet to generate api.PodStatus by itself.
That way, if we implement a runtime pod cache, whenever there is a change in the pod/container state, we will inspect the container and update the cache entry. Kubelet can always look at the cache and figure out the api.PodStatus itself, without having to ask individual runtimes.

In this case, I think you are right not to include ContainerStatus directly, but maybe we can think about adding fields like FinishedAt, ExitCode, etc. Another great reason to do this is that we can GC the container after we update the cache so that we don't have to keep so many containers around.

@yujuhong
Copy link
Contributor

Removing PodStatus from Pod is always good. This PR LGTM as it is. We can talk about whether we want to add extra fields later :)
Thanks!

@yifan-gu
Copy link
Contributor Author

@yujuhong Thanks for the heading up. I am thinking that can we let pleg manage and cache the []podstatus? Maybe we can add things that are missing (podID, podName, podNamespace for PodStatus, and container hash for ContainerStatus) ?

Then we can possibly remove the kubecontainer.Pod and related stuff. (The reason they exist mostly is because previously we wanted to implement the runtime-agnostic interfaces quickly, without bothering changing the api objects)

@yifan-gu
Copy link
Contributor Author

Anyway, would like to get this merged as my following rkt patches will depend on this :)

@yujuhong yujuhong added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 20, 2015
@yujuhong
Copy link
Contributor

@yujuhong Thanks for the heading up. I am thinking that can we let pleg manage and cache the []podstatus? Maybe we can add things that are missing (podID, podName, podNamespace for PodStatus, and container hash for ContainerStatus) ?

Then we can possibly remove the kubecontainer.Pod and related stuff. (The reason they exist mostly is because previously we wanted to implement the runtime-agnostic interfaces quickly, without bothering changing the api objects)

I think there are still merits of keeping kubeocntainer.Pod and types alike because the pod cache would be cleaner and it'd be easier to interface with other internal components. api.PodStatus has too many things that doesn't make sense for the underlying runtime. We'll also not be subject to how api.PodStatus is defined in this case :)

saad-ali added a commit that referenced this pull request Aug 21, 2015
kubelet: refactor kubecontainer.Pod, remove PodStatus from it.
@saad-ali saad-ali merged commit a90b67f into kubernetes:master Aug 21, 2015
@yifan-gu yifan-gu deleted the pod_status branch August 21, 2015 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants