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
Conversation
/cc @yujuhong @dchen1107 |
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() |
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.
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?
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.
@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.)
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.
Ok. Thanks!
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.
You are welcome :)
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.
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 :)
ok to test |
@yifan-gu: LGTM except for the one comment. |
GCE e2e build/test passed for commit 31e6ec8ab2da50d387a655f62bd0172342dd5156. |
@yujuhong Any feedback on the this? Note I am not adding |
GCE e2e build/test passed for commit 69f796f. |
@yifan-gu, my email setting for github is messed up, so I didn't get the notification. I will look at this asap. Thanks! |
@yifan-gu, I don't necessary want the ContainerStatus here, but I'd like In this case, I think you are right not to include ContainerStatus directly, but maybe we can think about adding fields like |
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 :) |
@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) |
Anyway, would like to get this merged as my following rkt patches will depend on this :) |
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 :) |
kubelet: refactor kubecontainer.Pod, remove PodStatus from it.
Related to #12619
Remove the PodStatus in kubecontainer.Pod.