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

gpusInUse info error when kubelet restarts #46087

Merged

Conversation

tianshapjq
Copy link
Contributor

@tianshapjq tianshapjq commented May 19, 2017

What this PR does / why we need it:
In my test, I found 2 errors in the nvidia_gpu_manager.go.

  1. the number of activePods in gpusInUse() equals to 0 when kubelet restarts. It seems the Start() method was called before pods recovery which caused this error. So I decide not to call gpusInUse() in the Start() function, just let it happen when new pod needs to be created.
  2. the container.ContainerID in line 242 returns the id in format of "docker://<container_id>", this will make the client failed to inspect the container by id. We have to erase the prefix of "docker://".

Special notes for your reviewer:

Release note:

Avoid assigning the same GPU to multiple containers.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 19, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @tianshapjq. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note-label-needed labels May 19, 2017
@tianshapjq
Copy link
Contributor Author

@vishh could you verify this? thx :)

@@ -101,8 +102,7 @@ func (ngm *nvidiaGPUManager) Start() error {
if err := ngm.discoverGPUs(); err != nil {
return err
}
// It's possible that the runtime isn't available now.
ngm.allocated = ngm.gpusInUse()

Choose a reason for hiding this comment

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

I'm -1 on this. If containers recover and continue using GPUs, then allocatable will be wrong for the node.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but as the PR described, the number of activePods always remains 0 in the Start() function. And as the ngm.allocated has been initialized, it takes no chance to get the right data anymore.
If we don't erase this line from code, we have to call the Start() function late after the pods have been recovered so the activePods will not be 0 in the gpusInUse() function.

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 tried to figure out the right place to call Start() function, but seems pods' synchronization is done by the statusManager concurrently, which means there is no explicit checkpoint to tell if the pods have been recovered. So, if we can not get the right info of active pods in gpusInUse(), the initialization of ngm.allocated will never be right when kubelet restarts.

Choose a reason for hiding this comment

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

Ok. I suppose things should suss themselves out in the unit & e2e tests. I think this should be helped a bit once checkpoints are added with #43240.

@@ -239,7 +239,7 @@ func (ngm *nvidiaGPUManager) gpusInUse() *podGPUs {
var containersToInspect []containerIdentifier
for _, container := range pod.Status.ContainerStatuses {
if containers.Has(container.Name) {
containersToInspect = append(containersToInspect, containerIdentifier{container.ContainerID, container.Name})
containersToInspect = append(containersToInspect, containerIdentifier{strings.Replace(container.ContainerID, "docker://", "", 1), container.Name})

Choose a reason for hiding this comment

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

I'm very surprised that this would not happen by default. @yujuhong Is this a subtle bug from dockertools -> dockershim ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, the code has always been like that.

@vishh
Copy link
Contributor

vishh commented May 20, 2017

@tianshapjq Thanks for the PR. Can you extend test/e2e_node/gpus.go to reproduce the issues this PR is trying to fix? I'd appreciate if you can unit tests as well.

@tianshapjq
Copy link
Contributor Author

@vishh ok, I will do it~

@vishh
Copy link
Contributor

vishh commented May 22, 2017 via email

@vishh
Copy link
Contributor

vishh commented May 22, 2017

@k8s-bot ok to test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 22, 2017
@vishh vishh added this to the v1.7 milestone May 22, 2017
@vishh vishh added the kind/bug Categorizes issue or PR as related to a bug. label May 22, 2017
@vishh vishh added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels May 22, 2017
@k8s-github-robot k8s-github-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 22, 2017
@vishh vishh assigned cmluciano and vishh and unassigned tmrts and Random-Liu May 22, 2017
@tianshapjq
Copy link
Contributor Author

@vishh anything wrong with my commit?

@cmluciano
Copy link

I think we need some e2e to prove out this logic @tianshapjq

@tianshapjq
Copy link
Contributor Author

@cmluciano I am working on it.

@vishh
Copy link
Contributor

vishh commented May 30, 2017

cc @mindprince

@tianshapjq
Copy link
Contributor Author

@cmluciano I considered to create a new e2e test in such scene: 1. node should contain at least 2 gpu cards; 2. create a pod requesting one gpu card; 3. restart kubelet; 4. create another pod to request one gpu card; 5. these two pods should not be assigned the same gpu card. How do you think about this?
And still something I did not figure out: how to restart kubelet? Does the function createConfigMap() and updateConfigMap() restart the kubelet in somewhere?

@cmluciano
Copy link

@tianshapjq I took a stab at this in #46644

@tianshapjq
Copy link
Contributor Author

@cmluciano @vishh I am woking on the e2e test in gpus.go, is there any method to get the devices of a container in pod? cause I want to check if two pods assigned the same gpu card when Kubelet restarts, but seems no attribute to expose these info.

@cmluciano
Copy link

@tianshapjq I'm not sure if this exists or not. We only have available GPUs in the current suite.

@grodrigues3
Copy link
Contributor

Looks like this is a bugfix (intended to go in for code freeze). If there was an issue filed for the bug, @tianshapjq please reference it in the PR body.

Otherwise, @vishh the change looks small enough that you can approve this PR going in with no issue via (/approve no-issue)

@tianshapjq
Copy link
Contributor Author

@grodrigues3 there is no issue for this pr, I just created this pr directly. Do I need to create one?

@vishh
Copy link
Contributor

vishh commented Jun 7, 2017

/approve no-issue

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 7, 2017
@vishh
Copy link
Contributor

vishh commented Jun 7, 2017

I'm waiting on @mindprince to validate this PR with #46644

@rohitagarwal003
Copy link
Member

/retest

@rohitagarwal003
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

@mindprince: changing LGTM is restricted to assignees, and only kubernetes org members may be assigned issues.

In response to this:

/lgtm
/approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@vishh vishh assigned vishh and unassigned pmorie and timstclair Jun 7, 2017
@vishh
Copy link
Contributor

vishh commented Jun 7, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 7, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mindprince, tianshapjq, vishh

Associated issue requirement bypassed by: vishh

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jun 7, 2017

@tianshapjq: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-federation-e2e-gce f3b9874 link @k8s-bot pull-kubernetes-federation-e2e-gce test this

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@rohitagarwal003
Copy link
Member

/retest

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 45877, 46846, 46630, 46087, 47003)

@k8s-github-robot k8s-github-robot merged commit 56baaaa into kubernetes:master Jun 8, 2017
@vishh vishh mentioned this pull request Jun 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.