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

Add QueueingHintFn for pvc events in VolumeRestriction plugin #125280

Merged

Conversation

HirazawaUi
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes Part of #118893

Special notes for your reviewer:

For review purposes, I splitd #119405.
this PR for adding QueueingHintFn for pvc events in VolumeRestriction plugin.

Does this PR introduce a user-facing change?

kube-scheduler implements scheduling hints for the VolumeRestriction plugin.
Scheduling hints allow the scheduler to retry scheduling Pods that were previously rejected by the VolumeRestriction plugin if a new pvc added, and the pvc belongs to pod.

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


@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/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 2, 2024
@k8s-ci-robot
Copy link
Contributor

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 2, 2024
@HirazawaUi
Copy link
Contributor Author

/cc @sanposhiho

@k8s-ci-robot k8s-ci-robot requested a review from sanposhiho June 2, 2024 14:15
@HirazawaUi
Copy link
Contributor Author

/retest


pvcs := sets.New[string]()

for _, volume := range pod.Spec.Volumes {
Copy link
Member

@AxeZhan AxeZhan Jun 3, 2024

Choose a reason for hiding this comment

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

We should only check volumes which can be rejected by volumeRestriction.

func needsRestrictionsCheck(v v1.Volume) bool {
return v.GCEPersistentDisk != nil || v.AWSElasticBlockStore != nil || v.RBD != nil || v.ISCSI != nil
}

I think that means we should only check these 4 types of volumes and pvc with readWriteOncePod accessmode?

And since we only cares PVC in this function, I think we should only do insertion in L365, if this pvc is a readWriteOncePod pvc.

Copy link
Member

@AxeZhan AxeZhan Jun 3, 2024

Choose a reason for hiding this comment

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

The current code will function correctly. However, the purpose of QHInt is to allow the plugin to determine if a previously rejected pod can potentially pass through it again. If the PVC has not been created, it will not be rejected by VolumeRestriction (I'm not sure but maybe volume_binding?). Although adding this check will not make the performance faster, I believe we should maintain consistent behavior.

Sorry, I checked the code. And we DO check this in code:

pvc, err := pl.pvcLister.PersistentVolumeClaims(pod.Namespace).Get(volume.PersistentVolumeClaim.ClaimName)
if err != nil {
return nil, err
}

So never mind. Let's keep the behavior for now😅.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your careful review :)

@@ -326,10 +328,50 @@ func (pl *VolumeRestrictions) EventsToRegister() []framework.ClusterEventWithHin
{Event: framework.ClusterEvent{Resource: framework.Node, ActionType: framework.Add}},
// Pods may fail to schedule because the PVC it uses has not yet been created.
// This PVC is required to exist to check its access modes.
{Event: framework.ClusterEvent{Resource: framework.PersistentVolumeClaim, ActionType: framework.Add | framework.Update}},
{Event: framework.ClusterEvent{Resource: framework.PersistentVolumeClaim, ActionType: framework.Add | framework.Update},
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 safe to remove the PVC's update event? The current Hint function will always ignore the event. After reading the plugin implementation, no update event registered makes sense to me.

I'd like to hear about others' opinions. @sanposhiho @AxeZhan

Related to #122158

Copy link
Member

Choose a reason for hiding this comment

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

The access modes can not be changed after a pvc is created.

Copy link
Member

@carlory carlory Jun 4, 2024

Choose a reason for hiding this comment

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

Unlike node events, the scheduler never ignore the creation event of a pvc.

// MaxPDVolumeCountPredicate: add/update PVC will affect counts of PV when it is bound.

Copy link
Member

Choose a reason for hiding this comment

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

I'm +1 for removing update event, since related changes to the PVC spec are blocked by immutability protection.

Not sure why we added it first, the comments said it's a future-proof, need opinions from reviewers of #103082

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

/cc @jsafrane @xing-yang

Can you take a look?

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/kubernetes/kubernetes/pull/103082/files#r661392954

The question is whether anything has changed since that comment was made, whether any change to the PVC spec or status could cause a Pod to schedule.

ping @jsafrane @xing-yang

Copy link
Member

Choose a reason for hiding this comment

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

The only PVC field that this filter uses is Spec.AccessModes and it's indeed immutable:

allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), fmt.Sprintf("spec is immutable after creation except resources.requests and volumeAttributesClassName for bound claims\n%v", specDiff)))

/approve
/hold cancel

Copy link
Member

Choose a reason for hiding this comment

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

Please remove Update, given, that, effectively, it doesn't matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed, after this PR merge we close #122158 as we no longer need it.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 15, 2024
@HirazawaUi HirazawaUi force-pushed the add-pvc-events-queueinghintfn branch from 676888d to d500e99 Compare June 15, 2024 16:04
@HirazawaUi HirazawaUi force-pushed the add-pvc-events-queueinghintfn branch from d500e99 to 6c10218 Compare June 17, 2024 14:33
Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

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

Thanks for all the fix, my /lgtm for it will come after the decision in https://github.com/kubernetes/kubernetes/pull/125280/files#r1625269171.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 21, 2024
@HirazawaUi HirazawaUi force-pushed the add-pvc-events-queueinghintfn branch from 6c10218 to 0fbf3e8 Compare June 23, 2024 13:37
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 23, 2024
@HirazawaUi
Copy link
Contributor Author

Thanks for all the fix, my /lgtm for it will come after the decision in https://github.com/kubernetes/kubernetes/pull/125280/files#r1625269171.

We can discuss this separately in #122158 :)

@HirazawaUi HirazawaUi force-pushed the add-pvc-events-queueinghintfn branch from 0fbf3e8 to 32ee19c Compare July 9, 2024 11:38
@HirazawaUi
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jul 11, 2024
@HirazawaUi
Copy link
Contributor Author

@sanposhiho Do you think we can add lgtm to it now.

@HirazawaUi HirazawaUi force-pushed the add-pvc-events-queueinghintfn branch from 32ee19c to cd13be8 Compare July 12, 2024 16:25
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.

/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 Jul 12, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 3a56488ff4c2912f8f6b7c6090d0a5ce08893e2e

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, HirazawaUi, jsafrane

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

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/feature Categorizes issue or PR as related to a new feature. 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.

7 participants