-
Notifications
You must be signed in to change notification settings - Fork 41.7k
refactor(kubelet/cpumanager): move fake manager to fakemanager subpackage and returning concrete type #135220
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
base: master
Are you sure you want to change the base?
Conversation
|
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 Once the patch is verified, the new status will be reflected by the 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. |
|
/release-note-none |
|
/retest |
|
@SergeyKanzhelev @ffromani |
|
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. |
ffromani
left a comment
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.
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. | |||
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.
no need to bump the copyright year especially for trivial changes
| */ | ||
|
|
||
| package cpumanager | ||
| package fakemanager |
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.
I'd rename this fake and let the importers do the rename, e.g.
import (
fakecpumanager "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/fake"
)
| type ( | ||
| Manager = cpumanager.Manager | ||
| Policy = cpumanager.Policy | ||
| ActivePodsFunc = cpumanager.ActivePodsFunc | ||
| RuntimeService = cpumanager.RuntimeService | ||
| ) |
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.
aliases are likely a good idea 👍
| RuntimeService = cpumanager.RuntimeService | ||
| ) | ||
|
|
||
| type FakeManager struct { |
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.
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{} |
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.
this should be private to avoid confusion about exported names
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.
Renamed the struct from FakeManager to manager to make it private
| func NewFakeManager(logger logr.Logger) *FakeManager { | ||
| logger = klog.LoggerWithName(logger, "cpu.fake") | ||
| return &fakeManager{ | ||
| return &FakeManager{ | ||
| logger: logger, | ||
| state: state.NewMemoryState(logger), | ||
| } |
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.
this change should sit in its own separate commit
| type RuntimeService interface { | ||
| UpdateContainerResources(ctx context.Context, id string, resources *runtimeapi.ContainerResources) error |
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.
this is a bit unexpected but indeed necessary and should be harmless
|
/triage accepted |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: priyansh3006 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 |
774739d to
3d6c4e2
Compare
|
@ffromani Thanks for looking into this and I Appreciate the quick response Commit 1: Return concrete type from NewFakeManager
Commit 2: Move fake manager to dedicated subpackage
Commit 3: Update imports for fake subpackage
|
|
@priyansh3006: The following tests failed, say
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. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
fakemanagersubpackage,following the client-go pattern for better code organization and separation of concerns.
Key changes:
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.