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

Migrate RemovePodsHavingTooManyRestarts to plugin #902

Conversation

binacs
Copy link
Member

@binacs binacs commented Aug 6, 2022

No description provided.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 6, 2022
@binacs binacs force-pushed the binacs/migrate-removepodshavingtoomanyrestarts-to-plugin branch from 05dbfdc to 17402cd Compare August 6, 2022 07:25
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 6, 2022
@binacs binacs force-pushed the binacs/migrate-removepodshavingtoomanyrestarts-to-plugin branch from 17402cd to cb972b5 Compare August 9, 2022 00:30
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 9, 2022
@@ -41,6 +42,14 @@ func ValidateRemoveFailedPodsArgs(args *componentconfig.RemoveFailedPodsArgs) er
)
}

// ValidateRemovePodsHavingTooManyRestartsArgs validates RemovePodsHavingTooManyRestarts arguments
func ValidateRemovePodsHavingTooManyRestartsArgs(args *componentconfig.RemovePodsHavingTooManyRestartsArgs) error {
return errorsAggregate(
Copy link
Contributor

Choose a reason for hiding this comment

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

The validation is missing check for PodRestartThreshold:

	if args == nil || args.PodRestartThreshold < 1 {
		return fmt.Errorf("PodsHavingTooManyRestarts threshold not set")
	}

IncludingInitContainers: tooManyRestartsParams.IncludingInitContainers,
}
if err := validation.ValidateRemovePodsHavingTooManyRestartsArgs(args); err != nil {
klog.V(1).ErrorS(err, "unable to validate plugin arguments", "pluginName", removefailedpods.PluginName)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/removefailedpods/removepodshavingtoomanyrestarts

}

if restarts < tooManyRestartsArgs.PodRestartThreshold {
errs = append(errs, fmt.Errorf("pod's restarts %v is excluded", restarts))
Copy link
Contributor

Choose a reason for hiding this comment

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

There's at most a single error. No need to store the error into an array:

var err error
...
err = fmt.Errorf("pod's restarts %v is excluded", restarts)
...
return err

will do as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

s/"pod's restarts %v is excluded"/"number of container restarts (%v) not exceeding the threshold"

nodes: []*v1.Node{node1},
expectedEvictedPodCount: 0,
nodeFit: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

This line can be omitted, false is the default value for nodeFit. The same for other lines.


// Run RemovePodsHavingTooManyRestarts strategy
t.Log("Running RemovePodsHavingTooManyRestarts strategy")
plugin.(framework.DeschedulePlugin).Deschedule(ctx, nodes)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/nodes/workerNodes

defer close(stopCh)

nodeList, err := clientSet.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
if err != nil {
t.Errorf("Error listing node with %v", err)
}

nodes, workerNodes := splitNodesAndWorkerNodes(nodeList.Items)
nodes, _ := splitNodesAndWorkerNodes(nodeList.Items)
Copy link
Contributor

Choose a reason for hiding this comment

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

It is still important to run the plugin over worker nodes only. Some of the control plane pod containers may get restarted too many times and evicted by the descheduler. Changing the assumption about the master nodes being protected against eviction and making the debugging step more complicated.

@ingvagabund
Copy link
Contributor

@BinacsLee thank You for helping us with the migration to plugins. It's great to see improvements in the code.

@binacs binacs force-pushed the binacs/migrate-removepodshavingtoomanyrestarts-to-plugin branch from cb972b5 to 1a05724 Compare August 9, 2022 11:55
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 9, 2022
@binacs
Copy link
Member Author

binacs commented Aug 9, 2022

hi @ingvagabund , thanks for your review! I have fixed the code, PTAL. :)

@binacs binacs force-pushed the binacs/migrate-removepodshavingtoomanyrestarts-to-plugin branch from 1a05724 to 3dbe0bf Compare August 9, 2022 11:58
@ingvagabund
Copy link
Contributor

ingvagabund commented Aug 9, 2022

@BinacsLee thank You for addressing the comments. Would you please rebase the PR as well?

@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 9, 2022
@binacs binacs force-pushed the binacs/migrate-removepodshavingtoomanyrestarts-to-plugin branch from 3dbe0bf to ca270db Compare August 9, 2022 13:35
@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 9, 2022
@binacs
Copy link
Member Author

binacs commented Aug 9, 2022

@ingvagabund sure, rebase done. PTAL

@binacs
Copy link
Member Author

binacs commented Aug 9, 2022

sorry, will fix the test soon

@binacs binacs force-pushed the binacs/migrate-removepodshavingtoomanyrestarts-to-plugin branch from ca270db to 3a9c897 Compare August 9, 2022 13:44
@@ -57,3 +57,13 @@ type RemovePodsViolatingNodeAffinityArgs struct {
LabelSelector *metav1.LabelSelector
NodeAffinityType []string
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object line

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks a lot! pull-descheduler-verify-master can be passed 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.

All tests passed :)

@binacs binacs force-pushed the binacs/migrate-removepodshavingtoomanyrestarts-to-plugin branch from 3a9c897 to d798e7d Compare August 9, 2022 14:07
@ingvagabund
Copy link
Contributor

/approve
/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ingvagabund

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 Aug 9, 2022
@k8s-ci-robot k8s-ci-robot merged commit ccfaeb2 into kubernetes-sigs:master Aug 9, 2022
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. 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.

3 participants