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

CSI migration doesn't count inline volumes for attach limit #107787

Merged
merged 1 commit into from May 12, 2022

Conversation

Jiawei0227
Copy link
Contributor

@Jiawei0227 Jiawei0227 commented Jan 26, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

CSI volume predicate should count inline volumes for migrated plugins. Currently it is not handled in the csi predicates.
This could lead to failures when there is a pod uses inline volume being scheduled to a node that already meets its maximum volume limit.

Which issue(s) this PR fixes:

Fixes # #100474

Special notes for your reviewer:

Testing:

  • Unit tests
  • E2E tests by inspecting logs added to the CSI volume predicate.

Does this PR introduce a user-facing change?

Fix a bug where CSI migration doesn't count inline volumes for attach limit.

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


/sig storage
/sig scheduler
/assign @msau42

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/storage Categorizes an issue or PR as relevant to SIG Storage. labels Jan 26, 2022
@k8s-ci-robot
Copy link
Contributor

@Jiawei0227: The label(s) sig/scheduler cannot be applied, because the repository doesn't have them.

In response to this:

Previsouly, when kube-scheduler schedule a pod, it does
not take inline intree volume into account when CSI
migration is enabled. This could lead to failures where
pod scheduled to a node but volume attachment fails.

What type of PR is this?

/kind bug

What this PR does / why we need it:

CSI volume predicate should count inline volumes for migrated plugins. Currently it is not handled in the csi predicates.
This could lead to failures when there is a pod uses inline volume being scheduled to a node that already meets its maximum volume limit.

Which issue(s) this PR fixes:

Fixes # #100474

Special notes for your reviewer:

Testing:

  • Unit tests
  • E2E tests by inspecting logs added to the CSI volume predicate.

Does this PR introduce a user-facing change?

Fix a bug where CSI migration doesn't count inline volumes for attach limit.

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


/sig storage
/sig scheduler
/assign @msau42

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jan 26, 2022
@k8s-ci-robot
Copy link
Contributor

@Jiawei0227: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Jan 26, 2022
@k8s-ci-robot k8s-ci-robot added the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Jan 26, 2022
@Jiawei0227
Copy link
Contributor Author

/cc @dobsonj @jsafrane
/sig scheduling

@Jiawei0227
Copy link
Contributor Author

/retest

1 similar comment
@Jiawei0227
Copy link
Contributor Author

/retest

@Jiawei0227 Jiawei0227 force-pushed the volumelimit branch 3 times, most recently from 37d9096 to a442d7f Compare January 29, 2022 08:41
Copy link
Member

@msau42 msau42 left a comment

Choose a reason for hiding this comment

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

Just one comment. Otherwise LGTM

pkg/scheduler/framework/plugins/nodevolumelimits/csi.go Outdated Show resolved Hide resolved
Copy link
Member

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

How come sig-storage is not an OWNER of this plugin. We did it for others, so consider sending a separate PR to do that.

pkg/scheduler/framework/plugins/nodevolumelimits/csi.go Outdated Show resolved Hide resolved
@Jiawei0227 Jiawei0227 force-pushed the volumelimit branch 2 times, most recently from b1bc50a to 84de6a5 Compare March 16, 2022 06:20
@msau42
Copy link
Member

msau42 commented Mar 17, 2022

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 17, 2022
@msau42
Copy link
Member

msau42 commented Mar 17, 2022

/assign @alculquicondor

@Jiawei0227
Copy link
Contributor Author

Gentle ping. Any update on this?

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 5, 2022
Copy link
Member

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

Looking better.

@msau42 still good?

pkg/scheduler/framework/plugins/nodevolumelimits/csi.go Outdated Show resolved Hide resolved
@@ -40,10 +40,12 @@ import (
// and perform translations from InTree PV's to CSI
type InTreeToCSITranslator interface {
IsPVMigratable(pv *v1.PersistentVolume) bool
IsInlineMigratable(vol *v1.Volume) bool
Copy link
Member

Choose a reason for hiding this comment

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

So the implementations were already implementing these functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return fmt.Errorf("error looking up provisioner name for volume: %v. Error Msg: %v", vol, err)
}
if !isCSIMigrationOn(csiNode, inTreeProvisionerName) {
klog.V(5).InfoS("CSI Migration of provisioner is not enabled", "provisioner", inTreeProvisionerName)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
klog.V(5).InfoS("CSI Migration of provisioner is not enabled", "provisioner", inTreeProvisionerName)
klog.V(5).InfoS("CSI Migration is not enabled for provisioner", "provisioner", inTreeProvisionerName)

But also, we probably need more context. Any other keys that would be useful? We should at least have the pod.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

// Do translation for the in-tree volume.
translatedPV, err := pl.translator.TranslateInTreeInlineVolumeToCSI(&vol, pod.Namespace)
if err != nil || translatedPV == nil {
return fmt.Errorf("Cannot convert volume(%v) from inline to csi.", vol)
Copy link
Member

Choose a reason for hiding this comment

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

Error have different rules 😅

https://github.com/golang/go/wiki/CodeReviewComments#error-strings

Suggested change
return fmt.Errorf("Cannot convert volume(%v) from inline to csi.", vol)
return fmt.Errorf("converting volume(%v) from inline to csi: %w", vol, err)

Copy link
Member

Choose a reason for hiding this comment

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

Although you should probably have a different error message for translatedPV == nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

pkg/scheduler/framework/plugins/nodevolumelimits/csi.go Outdated Show resolved Hide resolved
Previsouly, when kube-scheduler schedule a pod, it does
not take inline intree volume into account when CSI
migration is enabled. This could lead to failures where
pod scheduled to a node but volume attachment fails.
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, Jiawei0227, 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-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 10, 2022
@alculquicondor
Copy link
Member

/retest

@msau42
Copy link
Member

msau42 commented May 12, 2022

/lgtm

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 12, 2022
@k8s-triage-robot
Copy link

The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass.

This bot retests PRs for certain kubernetes repos according to the following rules:

  • The PR does have any do-not-merge/* labels
  • The PR does not have the needs-ok-to-test label
  • The PR is mergeable (does not have a needs-rebase label)
  • The PR is approved (has cncf-cla: yes, lgtm, approved labels)
  • The PR is failing tests required for merge

You can:

/retest

@k8s-ci-robot k8s-ci-robot merged commit 8aaea8e into kubernetes:master May 12, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone May 12, 2022
@b0b0haha
Copy link

It seems the non-csi predicate will count the in-line volume if csi migrate not enabled ,just as the code below:
https://github.com/Jiawei0227/kubernetes/blob/9d01f0bf52891d777078daafcd146b6eea1c98eb/pkg/scheduler/framework/plugins/nodevolumelimits/csi.go#L169-L180
image

but the code in non-csi predicate don't deal with the in-line volume case.
https://github.com/Jiawei0227/kubernetes/blob/9d01f0bf52891d777078daafcd146b6eea1c98eb/pkg/scheduler/framework/plugins/nodevolumelimits/non_csi.go#L298

Could you show me where it handle the in-line volume limit in non-csi predicate?
@Jiawei0227

}
if !isCSIMigrationOn(csiNode, inTreeProvisionerName) {
klog.V(5).InfoS("CSI Migration is not enabled for provisioner", "provisioner", inTreeProvisionerName,
"pod", klog.KObj(pod), "csiNode", csiNode.Name)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible under regular circumstances that csiNode is nil?

Copy link
Member

Choose a reason for hiding this comment

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

csiNode is checked in L96. And the Lister implementation returns not found error

Copy link
Member

Choose a reason for hiding this comment

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

It looks like the error is ignored here:

// TODO: return the error once CSINode is created by default (2 releases)
klog.V(5).InfoS("Could not get a CSINode object for the node", "node", klog.KObj(node), "err", err)

Copy link
Member

Choose a reason for hiding this comment

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

Ah good catch. Yes this could be a problem. We do have logic that's supposed to block the node from being ready until CSINode is created, but there could still be ordering issues with the informers.

Can you open a bug?

Copy link
Contributor

Choose a reason for hiding this comment

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

What does the "2 releases" refer to? Does this mean if we return the error it will break some releases?

Copy link
Member

Choose a reason for hiding this comment

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

It's referring to max supported 2-version skew between the control plane and kubelet. When CSI migration for a plugin is GA in version X, then in version X+2 we can assume that kubelets will be on version X.

However, I think due to #115178, we realize now that autoscaler will encounter a nil CSINode always (because it doesn't simulate CSINode objects). So this comment is obsolete.

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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants