Skip to content

when a pod fails to allocate partial resources, leading to UnexpectedAdmissionError #130172

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

novahe
Copy link
Contributor

@novahe novahe commented Feb 14, 2025

When m.devicesToAllocate fails, it is necessary to reset m.allocatedDevices to avoid generating stale data.

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #130145

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 14, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @novahe. 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 /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.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 14, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: novahe
Once this PR has been reviewed and has the lgtm label, please assign yujuhong for approval. For more information see the Code Review Process.

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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 14, 2025
@ffromani
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 15, 2025
@novahe
Copy link
Contributor Author

novahe commented Feb 15, 2025

/test pull-kubernetes-e2e-gce

@novahe
Copy link
Contributor Author

novahe commented Feb 16, 2025

@ffromani PTAL

@ffromani
Copy link
Contributor

/triager accepted
/priority important-longterm

Thanks for the fix! I have 2 major concerns:

  1. (I) still need to do a full review of the devicemanager codebase if there are still misuses of this map
  2. do we have tests (existing or new) covering this change?

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 16, 2025
@novahe novahe closed this Feb 17, 2025
@novahe novahe reopened this Feb 18, 2025
@novahe novahe force-pushed the fix-unexpected-admission-error branch from 61ae346 to 00215e8 Compare February 18, 2025 18:00
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 18, 2025
@novahe novahe changed the title when a pod fails to allocate partial resources, leading to UnexpectedAdmissionError, when a pod fails to allocate partial resources, leading to UnexpectedAdmissionError Feb 18, 2025
@novahe
Copy link
Contributor Author

novahe commented Feb 18, 2025

/triager accepted /priority important-longterm

Thanks for the fix! I have 2 major concerns:

  1. (I) still need to do a full review of the devicemanager codebase if there are still misuses of this map
  2. do we have tests (existing or new) covering this change?

Hi @ffromani , I’ve tried to create a scenario for the bug. Please take a look when you have time.

@novahe novahe force-pushed the fix-unexpected-admission-error branch from 00215e8 to f961c55 Compare February 19, 2025 11:27
@novahe
Copy link
Contributor Author

novahe commented Feb 19, 2025

/test pull-kubernetes-e2e-kind

@novahe novahe force-pushed the fix-unexpected-admission-error branch from 75dfe73 to dbf9a25 Compare March 5, 2025 14:05
@ffromani
Copy link
Contributor

ffromani commented Mar 5, 2025

thanks @novahe the code fix per se makes sense to me. Wil carefully review the testcase.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 3, 2025
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 3, 2025
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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-sigs/prow repository.

@github-project-automation github-project-automation bot moved this from Needs Reviewer to Done in SIG Node: code and documentation PRs Aug 2, 2025
@SergeyKanzhelev
Copy link
Member

/reopen

@ffromani this seems to be a useful fix. Will you have time to review?

@k8s-ci-robot k8s-ci-robot reopened this Aug 2, 2025
@k8s-ci-robot
Copy link
Contributor

@SergeyKanzhelev: Reopened this PR.

In response to this:

/reopen

@ffromani this seems to be a useful fix. Will you have time to review?

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-sigs/prow repository.

@k8s-ci-robot
Copy link
Contributor

@novahe: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-typecheck dbf9a25 link true /test pull-kubernetes-typecheck
pull-kubernetes-unit dbf9a25 link true /test pull-kubernetes-unit
pull-kubernetes-linter-hints dbf9a25 link false /test pull-kubernetes-linter-hints
pull-kubernetes-unit-windows-master dbf9a25 link false /test pull-kubernetes-unit-windows-master
pull-kubernetes-e2e-gce dbf9a25 link true /test pull-kubernetes-e2e-gce
pull-kubernetes-verify dbf9a25 link true /test pull-kubernetes-verify

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-sigs/prow repository. I understand the commands that are listed here.

@bart0sh bart0sh moved this from Triage to Needs Reviewer in SIG Node: code and documentation PRs Aug 12, 2025
Comment on lines +1441 to +1448
tmpDir, err := os.MkdirTemp("", "checkpoint")
as.NoError(err)
defer func(path string) {
err := os.RemoveAll(path)
if err != nil {
t.Fatalf("Fail to remove tmpdir: %v", err)
}
}(tmpDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tmpDir, err := os.MkdirTemp("", "checkpoint")
as.NoError(err)
defer func(path string) {
err := os.RemoveAll(path)
if err != nil {
t.Fatalf("Fail to remove tmpdir: %v", err)
}
}(tmpDir)
tmpDir := t.TempDir()

Preferred: true,
}
testManager, err := getTestManager(tmpDir, func() []*v1.Pod { return []*v1.Pod{} }, testResources)
as.NoError(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
as.NoError(err)
require.NoError(err)

@@ -851,6 +851,9 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
}
allocDevices, err := m.devicesToAllocate(podUID, contName, resource, needed, devicesToReuse[resource])
if err != nil {
m.mutex.Lock()
m.allocatedDevices = m.podDevices.devices()
m.mutex.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

There are 2 more identical pieces of code in this function. Would it make sense to use defer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

Pod Allocate failed due to requested number of devices unavailable for nvidia.com/gpu. Requested:1, Available: 0, which is unexpected
6 participants