-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Refactor PV scheduling library into a separate package #75434
Conversation
738daf1
to
de3bb0d
Compare
Set configuration context $ kubectl config use-context k8s $kubectl get pv --all-namespaces --sort-by="metadata.name" >> |
@@ -107,6 +107,8 @@ pkg/controller/volume/events | |||
pkg/controller/volume/expand | |||
pkg/controller/volume/persistentvolume | |||
pkg/controller/volume/persistentvolume/options | |||
pkg/controller/volume/persistentvolume/testing | |||
pkg/controller/volume/scheduling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code of testing
and scheduling
package is extracted from pkg/controller/volume/persistentvolume
and has some lint failures. I didn't fix them because I don't want to make this PR too complicated. I will fix them in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow up issue: #77084
// Inject error to the first | ||
// kubeclient.PersistentVolumes.Create() call. All other calls | ||
// will succeed. | ||
{"create", "persistentvolumes", errors.New("Mock creation error")}, | ||
{Verb: "create", Resource: "persistentvolumes", Error: errors.New("Mock creation error")}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These key fields are required if we composite a public struct from another package, otherwise composite literal uses unkeyed fields
is emitted by go vet
.
// NotSupportedProvisioner is a special provisioner name which can be set | ||
// in storage class to indicate dynamic provisioning is not supported by | ||
// the storage. | ||
NotSupportedProvisioner = "kubernetes.io/no-provisioner" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These constants are duplicated from persistentvolume
. A lot of places use private copy in persistentvolume
, I can update them to use constants in this shared package in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/scheduler/scheduler_test.go
Outdated
@@ -38,7 +38,8 @@ import ( | |||
clientcache "k8s.io/client-go/tools/cache" | |||
"k8s.io/client-go/tools/record" | |||
"k8s.io/kubernetes/pkg/api/legacyscheme" | |||
"k8s.io/kubernetes/pkg/controller/volume/persistentvolume" | |||
_ "k8s.io/kubernetes/pkg/apis/core/install" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why I import this package explicitly is because we need to register core API types (e.g. v1.Pod used in this file) into legacyscheme.Scheme
. In old code, it is registered implicitly in k8s.io/kubernetes/pkg/controller/volume/persistentvolume
.
Another way is to use k8s.io/client-go/kubernetes/scheme
which registers all non-internal API types by default.
/assign @msau42 |
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. |
hi, @deads2k @mikedanese @ixdy |
/lgtm |
cc @derekwaynecarr ask for approval on |
To fix scheme issue, use k8s.io/client-go/kubernetes/scheme instead of legacyscheme.
resolved some conflicts with #75848, no code change |
/retest |
1 similar comment
/retest |
@msau42 rebased without code change, please LGTM again |
cc @liggitt ask for approval on pkg/controller/BUILD which is modified by a new package under pkg/controller/volume. Thanks! |
/lgtm |
cc @thockin ask for an approval on pkg/controller because BUILD file is modified by a new package under pkg/controller/volume. Thanks! |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cblecker, cofyc, Huang-Wei, mikedanese, 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 |
@mikedanese Thanks! |
What type of PR is this?
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #56098
Special notes for your reviewer:
The refactoring is basically simple, but lots of code need to be extracted into shared places (
testing
,util
) to be used bypersistentvolume
and volumescheduling
packages.pkg/controller/volume/persistentvolume/testing
pkg/controller/volume/persistentvolume/util
pkg/controller/volume/scheduling
Does this PR introduce a user-facing change?: