-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Remove CSINode from scheduler cache. #84017
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahg-g The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
LGTM as (1) CSINodeInfo is not included in the internal snapshot, (2) no particular caching/indexing/filtering logic is needed in the CSI predicate.
/lgtm
/hold
in case @davidz627 has concerns.
AddFunc: sched.onCSINodeAdd, | ||
UpdateFunc: sched.onCSINodeUpdate, |
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.
We can directly put:
AddFunc: sched.SchedulingQueue.MoveAllToActiveQueue(),
UpdateFunc: sched.SchedulingQueue.MoveAllToActiveQueue(),
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.
oh this is what i said elsewhere too
+1 to this
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.
we can't the signature is different, so has to be wrapped somehow (inline or a separate func).
var _ CSINodeInfo = &CachedCSINodeInfo{} | ||
|
||
// CachedCSINodeInfo implements CSINodeInfoInfo | ||
type CachedCSINodeInfo 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.
nit: the API object has been renamed to CSINode
(the Info
is omitted)
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 wanted to be consistent with the other few interfaces defined in the same file (all suffixed with info). I agree we probably don't need any of that, but as I mentioned I would like to keep the code consistent while working on removing all of them completely.
if err := sched.SchedulerCache.AddCSINode(csiNode); err != nil { | ||
klog.Errorf("scheduler cache AddCSINode failed: %v", err) | ||
} | ||
|
||
sched.SchedulingQueue.MoveAllToActiveQueue() | ||
} | ||
|
||
func (sched *Scheduler) onCSINodeUpdate(oldObj, newObj interface{}) { |
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.
why do we keep these stubs here now that they dont' do anything on update? If we want to just maintain sched.SchedulingQueue.MoveAllToActiveQueue()
behavior all callers of these funcs should just call that function directly
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.
we need to wrap them because MoveAllToActiveQueue has a different signature compared to the callbacks AddFunc and UpdateFunc.
AddFunc: sched.onCSINodeAdd, | ||
UpdateFunc: sched.onCSINodeUpdate, |
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.
oh this is what i said elsewhere too
+1 to this
@@ -172,6 +173,18 @@ type CSINodeInfo interface { | |||
GetCSINodeInfo(nodeName string) (*storagev1beta1.CSINode, error) | |||
} | |||
|
|||
var _ CSINodeInfo = &CachedCSINodeInfo{} |
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.
nit: this interface should be renamed to CSINodeGetter
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.
replied in the other comment.
|
||
// CachedCSINodeInfo implements CSINodeInfoInfo | ||
type CachedCSINodeInfo struct { | ||
storagev1beta1listers.CSINodeLister |
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.
why even wrap this one interface inside this struct, why not just use the CSINodeLister
interface directly
this comment superscedes others
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 am planning a cleanup PR for all "listers/getters" the scheduler defines, so lets do that there. What I wanted to do in this PR is just cleanup the cache and maintain the existing interface that other parts of the code depend on (and hence I had to define this interface temporarily).
/test pull-kubernetes-e2e-gce-100-performance |
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.
/lgtm with a nit.
@@ -37,6 +37,7 @@ import ( | |||
utilfeature "k8s.io/apiserver/pkg/util/feature" | |||
corelisters "k8s.io/client-go/listers/core/v1" | |||
storagelisters "k8s.io/client-go/listers/storage/v1" | |||
storagev1beta1listers "k8s.io/client-go/listers/storage/v1beta1" |
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.
nit: the alias naming is inconsistent in this file. Some are <name><version> such as storagev1
, some are the reverse such as v1helper
, and this one seems to be a combination. Not sure if there is a common standard in k8s but we should at least make it consistent 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.
done. I followed the "<version><name>" pattern.
LGTM based on comment replies. Sounds like this is the first step to a larger refactor |
Indeed, we will likely remove most lister wrappers we have defined in the scheduler. |
/lgtm |
/hold |
/hold cancel |
4f0c272
to
efaed0d
Compare
/hold |
@Huang-Wei can you please take a quick look, had to rebase |
/hold cancel |
/lgtm |
/retest Review the full test history for this PR. Silence the bot with an |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Remove CSINodeInfo from scheduler cache. CSINodeInfo should be read directly from informer cache. Having in the scheduler cache consumes memory and adds no value.
Which issue(s) this PR fixes:
Part of #83922
/priority important-soon
/assign @liu-cong