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

Change the scheduler plugins FactoryAdapter function to use context parameter to pass logger #116884

Conversation

mengjiao-liu
Copy link
Member

@mengjiao-liu mengjiao-liu commented Mar 23, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

  • Change the scheduler plugins new function to pass logger parameter
  • Migrated pkg/scheduler/framework/plugins/nodevolumelimits to use contextual logging

Which issue(s) this PR fixes:

Part of #91633 (comment)

Special notes for your reviewer:

Follow the suggestion of #116842 (comment), instead of passing the logger using handle.Logger(), we pass the context.
Doing so changes the parameters passed in to initialize New function, and some other plugins parameter will also need to be modified.

// file:  pkg/scheduler/framework/runtime/registry.go

// before
func FactoryAdapter(fts plfeature.Features, withFts PluginFactoryWithFts) PluginFactory {
        return func(plArgs runtime.Object, fh framework.Handle) (framework.Plugin, error) {
                 return withFts(plArgs, fh, fts)

// after
// FactoryAdapter can be used to inject context and feature gates for a plugin that needs
// them when the caller expects the older PluginFactory method.
func FactoryAdapter(ctx context.Context, fts plfeature.Features, withFts PluginFactoryWithFts) PluginFactory {
	return func(plArgs runtime.Object, fh framework.Handle) (framework.Plugin, error) {
		return withFts(ctx, plArgs, fh, fts)
	}
}

Some plugins need to pass context during initialization, and the changes are as follows:

	registry := runtime.Registry{
                ...
		selectorspread.Name:                  selectorspread.New,
		nodevolumelimits.AzureDiskName:       runtime.FactoryAdapter(ctx, fts, nodevolumelimits.NewAzureDisk),
                ...
	}

see ef4ac99#diff-b5d92dd0897babb368df8c1aad9e95c957eca378bd46481d6d8501011f722715 for more details.

see #116884 (comment) for the newest change.

Does this PR introduce a user-facing change?

Migrated the nodevolumelimits scheduler plugin to use [contextual logging](https://k8s.io/docs/concepts/cluster-administration/system-logs/#contextual-logging).

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

- [KEP]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/3077-contextual-logging

/sig instrumentation
/wg structured-logging
/area logging
/sig scheduling

#116842 (comment)
The plugins(volumebinding #116803 ,examples/stateful #116885) can use context after waiting for this PR merge.

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/logging labels Mar 23, 2023
@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 23, 2023
@mengjiao-liu
Copy link
Member Author

/test all

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 12, 2023
@mengjiao-liu mengjiao-liu force-pushed the contextual-logging-scheduler-plugin-nodevolumelimits branch from 8beca10 to ef4ac99 Compare June 9, 2023 07:17
@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 9, 2023
@mengjiao-liu
Copy link
Member Author

mengjiao-liu commented Jun 9, 2023

/test all
#116842 (comment) Modify PR to pass the context directly instead of handle.Logger() method.

@bart0sh bart0sh added this to Triage in SIG Node PR Triage Jun 9, 2023
@bart0sh bart0sh moved this from Triage to WIP in SIG Node PR Triage Jun 9, 2023
@mengjiao-liu
Copy link
Member Author

/remove-sig node
/remove-sig storage

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. labels Jun 12, 2023
@SergeyKanzhelev SergeyKanzhelev moved this from Triage to Archive-it in SIG Node CI/Test Board Sep 6, 2023
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 7, 2023
@mengjiao-liu mengjiao-liu force-pushed the contextual-logging-scheduler-plugin-nodevolumelimits branch from 481c394 to c61572d Compare September 7, 2023 02:25
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 7, 2023
@mengjiao-liu
Copy link
Member Author

Rebased to resolve conflicts.

@mengjiao-liu mengjiao-liu force-pushed the contextual-logging-scheduler-plugin-nodevolumelimits branch from c61572d to b19e08a Compare September 7, 2023 03:40
@mengjiao-liu
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 13, 2023
@mengjiao-liu mengjiao-liu force-pushed the contextual-logging-scheduler-plugin-nodevolumelimits branch from b19e08a to b6f57bb Compare September 19, 2023 03:39
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 19, 2023
@mengjiao-liu
Copy link
Member Author

/test pull-kubernetes-node-e2e-containerd

…rameter to pass logger

- Migrated pkg/scheduler/framework/plugins/nodevolumelimits to use contextual logging
- Fix golangci-lint validation failed
- Check for plugins creation err
@mengjiao-liu mengjiao-liu force-pushed the contextual-logging-scheduler-plugin-nodevolumelimits branch from 4c8f7f3 to a7466f4 Compare September 20, 2023 09:53
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 20, 2023
@alculquicondor
Copy link
Member

/lgtm
/approve

Thanks!

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

LGTM label has been added.

Git tree hash: 04b8dcb1b7e657067a9acd906266ffc5414616f8

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, kerthcet, mengjiao-liu

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

@mengjiao-liu
Copy link
Member Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 20, 2023
@k8s-ci-robot
Copy link
Contributor

@mengjiao-liu: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-unit a7466f4 link unknown /test pull-kubernetes-unit

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@mengjiao-liu
Copy link
Member Author

/test pull-kubernetes-unit

@k8s-ci-robot k8s-ci-robot merged commit 89b4153 into kubernetes:master Sep 20, 2023
17 of 18 checks passed
SIG Node PR Triage automation moved this from Needs Approver to Done Sep 20, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Sep 20, 2023
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. area/logging area/test 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/node Categorizes an issue or PR as relevant to SIG Node. 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

8 participants