Skip to content
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

Merged
merged 3 commits into from
Sep 5, 2018
Merged

Conversation

gnufied
Copy link
Member

@gnufied gnufied commented Aug 22, 2018

Add support for volume limits for CSI.

xref: kubernetes/community#2051

Add support for volume attach limits for CSI volumes

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 22, 2018
@k8s-ci-robot k8s-ci-robot requested review from msau42 and rootfs August 22, 2018 22:18
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 22, 2018
@gnufied
Copy link
Member Author

gnufied commented Aug 22, 2018

/sig storage

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Aug 22, 2018
@gnufied gnufied force-pushed the fix-csi-attach-limit branch from 0d33b5c to 31cdc1b Compare August 22, 2018 23:36
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 22, 2018

for _, vol := range volumes {
// CSI volumes can only be used as persistent volumes
if vol.PersistentVolumeClaim != nil {
Copy link
Member

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
}

@gnufied gnufied force-pushed the fix-csi-attach-limit branch from 31cdc1b to e4c9bae Compare August 23, 2018 11:50
@gnufied
Copy link
Member Author

gnufied commented Aug 23, 2018

/sig storage

@gnufied gnufied force-pushed the fix-csi-attach-limit branch from e4c9bae to d19fb19 Compare August 23, 2018 17:00
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. 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. labels Aug 23, 2018
}

pvName := pvc.Spec.VolumeName
if pvName == "" {
Copy link
Member

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

Copy link
Member Author

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"
Copy link
Member

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.

Copy link
Member Author

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)
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

ditto

// 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)) {
Copy link
Member

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?

Copy link
Member Author

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(
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

tests?

Copy link
Member Author

@gnufied gnufied Sep 4, 2018

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.

Copy link
Member

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

Copy link
Member Author

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

@verult
Copy link
Contributor

verult commented Aug 24, 2018

/cc

@k8s-ci-robot k8s-ci-robot requested a review from verult August 24, 2018 17:23
@jsafrane jsafrane added this to the v1.12 milestone Aug 28, 2018
@gnufied gnufied force-pushed the fix-csi-attach-limit branch from d19fb19 to 11cc5e9 Compare September 4, 2018 22:21
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 4, 2018
@gnufied gnufied force-pushed the fix-csi-attach-limit branch from 4dc54ef to 7710dd6 Compare September 4, 2018 22:36
volumes []v1.Volume, namespace string, result map[string]string) error {

for _, vol := range volumes {
// CSI volumes can only be used as persistent volumes
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member Author

@gnufied gnufied Sep 4, 2018

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)
Copy link
Member

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"
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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

@gnufied
Copy link
Member Author

gnufied commented Sep 5, 2018

/test pull-kubernetes-integration
/test pull-kubernetes-e2e-gce-100-performance
/test pull-kubernetes-kubemark-e2e-gce-big

@gnufied gnufied force-pushed the fix-csi-attach-limit branch from 7710dd6 to fdf8a5e Compare September 5, 2018 00:04
@msau42
Copy link
Member

msau42 commented Sep 5, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 5, 2018
@gnufied
Copy link
Member Author

gnufied commented Sep 5, 2018

/retest

Copy link
Member

@bsalamat bsalamat left a 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) {
Copy link
Member

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.

Copy link
Member Author

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"},
Copy link
Member

Choose a reason for hiding this comment

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

nit: fix the indentation

@gnufied gnufied force-pushed the fix-csi-attach-limit branch from fdf8a5e to fc61620 Compare September 5, 2018 16:29
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 5, 2018
@gnufied
Copy link
Member Author

gnufied commented Sep 5, 2018

/priority critical-urgent

@k8s-ci-robot k8s-ci-robot added the priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. label Sep 5, 2018
@eparis
Copy link
Contributor

eparis commented Sep 5, 2018

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 5, 2018
@eparis
Copy link
Contributor

eparis commented Sep 5, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 5, 2018
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

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.

@k8s-github-robot k8s-github-robot merged commit ca43f00 into kubernetes:master Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants