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

Refactor PV scheduling library into a separate package #75434

Merged
merged 3 commits into from
May 4, 2019

Conversation

cofyc
Copy link
Member

@cofyc cofyc commented Mar 18, 2019

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

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 by persistentvolume and volume scheduling packages.

  • 0423f9fd097a97e20402cc133893c9798f9b5a51: Extract testing VolumeReactor into a separate package pkg/controller/volume/persistentvolume/testing
    • because volume scheduling need this testing utility too
  • 6c6140c995f16bb9e82f7546e4c2224008212b04
    • Extract utilities into a separate package pkg/controller/volume/persistentvolume/util
    • Refactor PV scheduling library into separate package pkg/controller/volume/scheduling
  • 6ea9a2513987757b6f1a1ff2a71f1c485c9a1a39: Update scheduler to use new volume scheduling library

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 18, 2019
@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 18, 2019
@cofyc cofyc force-pushed the fix56098 branch 2 times, most recently from 738daf1 to de3bb0d Compare March 18, 2019 06:00
@maicohjf
Copy link

maicohjf commented Mar 18, 2019

Set configuration context $ kubectl config use-context k8s
List all PVs sorted by name, saving the full kubectl output to /opt/KUCC000/my_volumes . Use
kubectl s own functionally for sorting the output, and do not manipulate it any further.
Question weight 3%

$kubectl get pv --all-namespaces --sort-by="metadata.name" >>
/opt/KUCC000/my_volumes or
$kubectl get pv --all-namespaces --sort-by="spec.capacity.storage" >>
/opt/KUCC000/my_volumes

@@ -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
Copy link
Member Author

@cofyc cofyc Mar 18, 2019

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.

Copy link
Member Author

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")},
Copy link
Member Author

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"
Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -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"
Copy link
Member Author

@cofyc cofyc Mar 18, 2019

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.

@cofyc cofyc changed the title WIP: Refactor PV scheduling library into separate package Refactor PV scheduling library into separate package Mar 18, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 18, 2019
@cofyc
Copy link
Member Author

cofyc commented Mar 18, 2019

/assign @msau42

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 24, 2019
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 24, 2019
@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 21, 2019
@k8s-ci-robot
Copy link
Contributor

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.

@cofyc
Copy link
Member Author

cofyc commented Apr 25, 2019

hi, @deads2k @mikedanese @ixdy
Changes under pkg/controller/volume had been approved by @msau42 already, but this PR modified pkg/controller/BUILD because a new package is added, I need your approval, could you do me a favor?

@msau42
Copy link
Member

msau42 commented Apr 25, 2019

/lgtm
/priority important-soon

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 25, 2019
@cofyc
Copy link
Member Author

cofyc commented Apr 26, 2019

cc @derekwaynecarr ask for approval on pkg/controller/BUILD which is modified by a new package under pkg/controller/volume.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 1, 2019
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 2, 2019
To fix scheme issue, use k8s.io/client-go/kubernetes/scheme instead of
legacyscheme.
@cofyc
Copy link
Member Author

cofyc commented May 2, 2019

resolved some conflicts with #75848, no code change

@cofyc
Copy link
Member Author

cofyc commented May 2, 2019

/retest

1 similar comment
@cofyc
Copy link
Member Author

cofyc commented May 2, 2019

/retest

@cofyc
Copy link
Member Author

cofyc commented May 2, 2019

@msau42 rebased without code change, please LGTM again

@cofyc
Copy link
Member Author

cofyc commented May 3, 2019

cc @liggitt ask for approval on pkg/controller/BUILD which is modified by a new package under pkg/controller/volume. Thanks!

@msau42
Copy link
Member

msau42 commented May 3, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 3, 2019
@cofyc
Copy link
Member Author

cofyc commented May 4, 2019

cc @thockin ask for an approval on pkg/controller because BUILD file is modified by a new package under pkg/controller/volume. Thanks!

@mikedanese
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /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 4, 2019
@k8s-ci-robot k8s-ci-robot merged commit ef550e6 into kubernetes:master May 4, 2019
@cofyc cofyc deleted the fix56098 branch May 4, 2019 07:18
@cofyc
Copy link
Member Author

cofyc commented May 4, 2019

@mikedanese Thanks!

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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor PV scheduling library into separate package
7 participants