-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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
Fix csi attach limit #67731
Fix csi attach limit #67731
Conversation
/sig storage |
Create a new predicate to count CSI volumes
0d33b5c
to
31cdc1b
Compare
|
||
for _, vol := range volumes { | ||
// CSI volumes can only be used as persistent volumes | ||
if vol.PersistentVolumeClaim != nil { |
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.
can be optimized to:
if vol.PersistentVolumeClaim == nil {
continue
}
31cdc1b
to
e4c9bae
Compare
/sig storage |
e4c9bae
to
d19fb19
Compare
} | ||
|
||
pvName := pvc.Spec.VolumeName | ||
if pvName == "" { |
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.
Add a TODO here that this is not going to work with late binding
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.
added
|
||
// Package nodeupdater includes internal functions used to add/delete labels to | ||
// kubernetes nodes for corresponding CSI drivers | ||
package nodeupdater // import "k8s.io/kubernetes/pkg/volume/csi/nodeupdater" |
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.
cc @verult
You guys are both renaming/refactoring this file. Please sync up.
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.
yeah I will address this when I rebase against #67684
if labelErr != nil { | ||
return labelErr | ||
} | ||
node = addMaxAttachLimitToNode(node, driverName, maxLimit) |
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.
Does this need to be feature gated?
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.
ditto
pkg/volume/util/attach_limit_test.go
Outdated
// When driver is longer than 39 chars | ||
csiLimitKeyLonger := GetCSIAttachLimitKey("com.amazon.kubernetes.eks.ec2.ebs/csi-driver") | ||
fmt.Println(csiLimitKeyLonger) | ||
if !v1helper.IsAttachableVolumeResourceName(v1.ResourceName(csiLimitKeyLonger)) { |
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.
Should you check for the expected hash in this test?
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.
fixed.
return c.attachableLimitPredicate | ||
} | ||
|
||
func (c *CSIMaxVolumeLimitChecker) attachableLimitPredicate( |
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.
Could we not have reused the existing MaxPD predicate and just define a new filter for CSI?
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.
tests?
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.
May be - we can, but it will be ugly because underlying data structures are different. The existing MaxPD* predicates filter volumes based on hardcoded type. For example - "how many EBS volumes are attached to the node", but since there can be multiple CSI volumes on a node, the CSI predicate has to count - "How many volumes of each type are attached to the node" and same thing applies to uniqueness check and etc.
At some point - I would like to consolidate all the predicates in one when AttachLimit
feature becomes GA, because then all the volume limits will come from node itself and we can remove these older and hardcoded predicates.
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 the explanation, it makes sense to keep them separate for now
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.
added some tests too btw
/cc |
d19fb19
to
11cc5e9
Compare
4dc54ef
to
7710dd6
Compare
volumes []v1.Volume, namespace string, result map[string]string) error { | ||
|
||
for _, vol := range volumes { | ||
// CSI volumes can only be used as persistent volumes |
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.
Do we need to revisit this for inline csi volumes?
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 not 100% sure yet but I thought plan was to keep inline CSI volumes non-attachable. cc @vladimirvivien is that still true?
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.
discussed this offline. The handling of inline CSI volumes is out of scope for this PR. Currently inline CSI volumes are being proposed as an alpha feature.
pvc, err := c.pvcInfo.GetPersistentVolumeClaimInfo(namespace, pvcName) | ||
|
||
if err != nil { | ||
glog.Errorf("Unable to look up PVC info for %s/%s", namespace, pvcName) |
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.
These messages have the potential to spam the logs if a pod spec is not constructed correctly. Can these logs be changed to Info at level 4?
@@ -26,4 +31,25 @@ const ( | |||
AzureVolumeLimitKey = "attachable-volumes-azure-disk" | |||
// GCEVolumeLimitKey stores resource name that will store volume limits for GCE node | |||
GCEVolumeLimitKey = "attachable-volumes-gce-pd" |
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.
Do the in-tree limit keys need to be changed to be compatible with the csi driver equivalent?
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.
You mean - once migration happens? I think we will stick to the plan of carrying around a map for in-tree plugins when we start shipping those.
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.
Yes, I mean, now that this is going beta, we need to support these limits keys for two releases. So there will be a period of time where we'll need some in-tree volume key to csi translation function
/test pull-kubernetes-integration |
7710dd6
to
fdf8a5e
Compare
/lgtm |
/retest |
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
The changes to the scheduler look fine to, but I am not familiar with the details of CSI volume operations. My assumption is that that part is checked by the SIG storage folks.
@@ -488,6 +488,10 @@ func (c *configFactory) invalidatePredicatesForPv(pv *v1.PersistentVolume) { | |||
invalidPredicates.Insert(predicates.MaxAzureDiskVolumeCountPred) | |||
} | |||
|
|||
if pv.Spec.CSI != nil && utilfeature.DefaultFeatureGate.Enabled(features.AttachVolumeLimit) { |
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 don't want to hold this PR, but please send a follow-up PR to add tests for these invalidation cases.
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.
okay sure.
{"name": "MaxEBSVolumeCount"}, | ||
{"name": "MaxGCEPDVolumeCount"}, | ||
{"name": "MaxAzureDiskVolumeCount"}, | ||
{"name": "MaxCSIVolumeCountPred"}, |
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: fix the indentation
fdf8a5e
to
fc61620
Compare
/priority critical-urgent |
/approve |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bsalamat, eparis, gnufied, msau42 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 |
Automatic merge from submit-queue (batch tested with PRs 68161, 68023, 67909, 67955, 67731). If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md. |
Add support for volume limits for CSI.
xref: kubernetes/community#2051