Skip to content

Conversation

@priyansh3006
Copy link

@priyansh3006 priyansh3006 commented Nov 7, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

  • This PR moves the fake CPU manager implementation to a dedicated fakemanager subpackage,
    following the client-go pattern for better code organization and separation of concerns.
  • Returns a concrete type instead of an interface for better testability

Key changes:

  • Create pkg/kubelet/cm/cpumanager/fakemanager/ subpackage
  • Move FakeManager implementation to fakemanager/fake_manager.go
  • Export RuntimeService interface (was runtimeService) for subpackage usage
  • Update NewFakeManager() to return concrete type (*FakeManager) instead of Manager interface

Which issue(s) this PR is related to:

Related to #135110

Special notes for your reviewer:
NONE

Does this PR introduce a user-facing change?
NONE

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

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 7, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @priyansh3006. Thanks for your PR.

I'm waiting for a github.com 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 the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Nov 7, 2025
@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 Nov 7, 2025
@SergeyKanzhelev
Copy link
Member

/release-note-none
/ok-to-test
/priority backlog

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. 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 Nov 7, 2025
@SergeyKanzhelev
Copy link
Member

Fixes #135110

This line in description will close the whole bug. I do not think it is accurate. Please change it to "Related to #135110".

/assign @ffromani

@priyansh3006
Copy link
Author

/retest

@priyansh3006
Copy link
Author

@SergeyKanzhelev @ffromani
About E2E Test Failures :
The RestartAllContainersOnContainerExits feature gate failures in e2e_node tests are pre-existing issues unrelated to this refactoring. These tests fail during initialization before cpumanager even runs. Local testing confirms all cpumanager
tests pass and the refactoring is working correctly.
Is there anything I can do to help resolve the e2e test issue or assist with the review of this PR?

@ffromani
Copy link
Contributor

ffromani commented Nov 9, 2025

test failures seems unrelated indeed. I'll have a look at the PR ASAP. It's unlikely to make the 1.35 cutoff, but that's fine.

Copy link
Contributor

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

thanks for your submission! let's rearrange the commits to make sure each commit is atomic and complete (e.g. not API changes in a commit and fix of the calling sites into another) and let's make sure to record the rationale within the commit message. I can add some suggestions later on

@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2025 The Kubernetes Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to bump the copyright year especially for trivial changes

*/

package cpumanager
package fakemanager
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rename this fake and let the importers do the rename, e.g.

import (
     fakecpumanager "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/fake"
)

Comment on lines +34 to +39
type (
Manager = cpumanager.Manager
Policy = cpumanager.Policy
ActivePodsFunc = cpumanager.ActivePodsFunc
RuntimeService = cpumanager.RuntimeService
)
Copy link
Contributor

Choose a reason for hiding this comment

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

aliases are likely a good idea 👍

RuntimeService = cpumanager.RuntimeService
)

type FakeManager struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

if we rename the package fake, this can just be Manager

func (m *fakeManager) Start(ctx context.Context, activePods ActivePodsFunc, sourcesReady config.SourcesReady, podStatusProvider status.PodStatusProvider, containerRuntime runtimeService, initialContainers containermap.ContainerMap) error {
logger := klog.FromContext(ctx)
logger.Info("Start()")
var _ Manager = &FakeManager{}
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be private to avoid confusion about exported names

Copy link
Author

Choose a reason for hiding this comment

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

Renamed the struct from FakeManager to manager to make it private

Comment on lines 108 to 113
func NewFakeManager(logger logr.Logger) *FakeManager {
logger = klog.LoggerWithName(logger, "cpu.fake")
return &fakeManager{
return &FakeManager{
logger: logger,
state: state.NewMemoryState(logger),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this change should sit in its own separate commit

Comment on lines +46 to 47
type RuntimeService interface {
UpdateContainerResources(ctx context.Context, id string, resources *runtimeapi.ContainerResources) error
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bit unexpected but indeed necessary and should be harmless

@ffromani
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 10, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: priyansh3006
Once this PR has been reviewed and has the lgtm label, please ask for approval from ffromani. 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

@priyansh3006
Copy link
Author

priyansh3006 commented Nov 10, 2025

@ffromani Thanks for looking into this and I Appreciate the quick response
I've reorganized the commits into 3 complete commits as requested:

Commit 1: Return concrete type from NewFakeManager

  • Changed return type to *fakeManager for better testability

Commit 2: Move fake manager to dedicated subpackage

  • Created fake/ subpackage following client-go pattern
  • Renamed struct to manager (private) and made interface check explicit

Commit 3: Update imports for fake subpackage

  • Updated all calling sites to use new subpackage
  • Changed imports to fakecpumanager "...cpumanager/fake"

@k8s-ci-robot
Copy link
Contributor

@priyansh3006: 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-node-e2e-restartallcontainers bce5d6c link false /test pull-kubernetes-node-e2e-restartallcontainers
pull-kubernetes-unit-windows-master 3d6c4e2 link false /test pull-kubernetes-unit-windows-master

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.

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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. 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.

Development

Successfully merging this pull request may close these issues.

4 participants