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 new command kubectl set volume #54284

Closed
wants to merge 1 commit into from

Conversation

WanLinghao
Copy link
Contributor

@WanLinghao WanLinghao commented Oct 20, 2017

What this PR does / why we need it:
#21648
Moved from OpenShift to Kubenetes.
Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Release note:

Add 'kubectl set volume' command for setting volume in containers for resources embedding pod templates

@k8s-ci-robot
Copy link
Contributor

@WanLinghao: Adding do-not-merge/release-note-label-needed because the release note process has not been followed.

One of the following labels is required "release-note", "release-note-action-required", or "release-note-none".
Please see: https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#write-release-notes-if-needed.

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.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 20, 2017
@CaoShuFeng
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 20, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: WanLinghao
We suggest the following additional approver: pwittrock

Assign the PR to them by writing /assign @pwittrock in a comment when ready.

Associated issue: 21648

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@mkumatag
Copy link
Member

api.Codecs moved to legacyscheme.Codecs part of #53984, so you may need to fix the import path to build the code.

@cblecker
Copy link
Member

/unassign
Please reassign back if you need hack/ approval once this has been reviewed by a sig-cli reviewer :)

@0xmichalis
Copy link
Contributor

@kubernetes/sig-cli-pr-reviews

@k8s-ci-robot k8s-ci-robot added the sig/cli Categorizes an issue or PR as relevant to SIG CLI. label Oct 27, 2017
@WanLinghao
Copy link
Contributor Author

/test pull-kubernetes-unit

@WanLinghao
Copy link
Contributor Author

/assign cblecker


const (
volumePrefix = "volume-"
storageAnnClass = "volume.beta.kubernetes.io/storage-class"
Copy link
Member

Choose a reason for hiding this comment

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

No need to import new storageAnnClass, use api.BetaStorageClassAnnotation instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

func (o *VolumeOptions) addVolumeToSpec(spec *api.PodSpec, info *resource.Info, singleResource bool) error {
opts := o.AddOpts
if len(o.Name) == 0 {
var err error
Copy link
Member

Choose a reason for hiding this comment

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

Better change to

if o.Name, err := o.getVolumeName(spec, singleResource); err != nil {
	return err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think cause o.Name is an existed variable, so your way is not suitable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

var err error
if o.Name, err = o.getVolumeName(spec, singleResource); err != nil {
	return err
}

did you mean this?

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

return errors.New("either specify --type or --source but not both for --add operation")
}

if len(a.Type) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder shall we split these checking to separate methods to make it more concise and maintainable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dixudx OK

func (a *AddVolumeOptions) Validate(isAddOp bool) error {
if isAddOp {
if len(a.Type) == 0 && (len(a.ClaimName) > 0 || len(a.ClaimSize) > 0) {
a.Type = "persistentvolumeclaim"
Copy link
Member

Choose a reason for hiding this comment

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

Actually I don't like such a hard-coded way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dixudx please make it more clear.Do you mean this function contains too much things?

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api"
Copy link
Contributor

Choose a reason for hiding this comment

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

no internal type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shiywang I am not clear with version stuff, would please give me some hints, thanks a lot


apierrs "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
kresource "k8s.io/apimachinery/pkg/api/resource"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: i would prefer just "k8s.io/apimachinery/pkg/api/resource" since there's no upstream dependency anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since this file import another resource package "k8s.io/kubernetes/pkg/kubectl/resource"

}

func (o *VolumeOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, out, errOut io.Writer) error {
kc, err := f.ClientSet()
Copy link
Contributor

@shiywang shiywang Oct 30, 2017

Choose a reason for hiding this comment

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

nit: in kubernetes, we can just call it client

if len(o.AddOpts.ClaimName) == 0 {
o.AddOpts.ClaimName = names.SimpleNameGenerator.GenerateName("pvc-")
}
q, err := kresource.ParseQuantity(o.AddOpts.ClaimSize)
Copy link
Contributor

@shiywang shiywang Oct 30, 2017

Choose a reason for hiding this comment

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

ditto, kresource

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@shiywang
Copy link
Contributor

shiywang commented Oct 30, 2017

just had a glance, will take a deeper look tomorrow morning

"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api"
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be removed, use versioned api

Copy link
Contributor Author

Choose a reason for hiding this comment

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

use "k8s.io/client-go/kubernetes/typed/core/v1" replacing "k8s.io/kubernetes/pkg/api"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zjj2wry since I am still not clear with this version stuff

Copy link
Contributor

Choose a reason for hiding this comment

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

api rep: k8s.io/api...
api maybe in: k8s.io/api/core/v1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zjj2wry Is it a new move still on pushing? I notice that file in same package like set_env.go, set_image.go still use "k8s.io/kubernetes/pkg/api".
since connections between them exist, if use core/v1 in set_volume.go. then it is necessary that we should use the same in this whole package

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, will fix all set command :), and it is in process

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zjj2wry so would mind if I just ignore this right now and fix it after other set command?
by the way , are there any PR that focus on this? please tell me so I can keep in track

Copy link
Member

Choose a reason for hiding this comment

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

it's being actively worked on in #54554

@WanLinghao I would prefer not adding this until that PR is in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liggitt OK, I will wait for this and rebase then

@zjj2wry
Copy link
Contributor

zjj2wry commented Nov 14, 2017

@WanLinghao this PR lgtm when your fix small nits.

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Nov 15, 2017

@WanLinghao: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-gce-gpu 1fd56b503cf4498dbbfdd9bea98609c4e063f443 link /test pull-kubernetes-e2e-gce-gpu

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.

…umes

	modified:   docs/.generated_docs
	new file:   docs/man/man1/kubectl-set-volumes.1
	new file:   docs/user-guide/kubectl/kubectl_set_volumes.md
	modified:   hack/make-rules/test-cmd-util.sh
	modified:   pkg/kubectl/cmd/set/set.go
	new file:   pkg/kubectl/cmd/set/set_volume_test.go
	new file:   pkg/kubectl/cmd/set/set_volume.go
	modified:   pkg/kubectl/cmd/set/BUILD
@WanLinghao
Copy link
Contributor Author

@zjj2wry @Kargakis ready

@WanLinghao
Copy link
Contributor Author

@liggitt PTAL

@WanLinghao
Copy link
Contributor Author

@zjj2wry do you know who can help push this, thanks

@WanLinghao
Copy link
Contributor Author

@liggitt PTAL thanks

@zjj2wry
Copy link
Contributor

zjj2wry commented Nov 21, 2017

/retest
@kubernetes/sig-cli-pr-reviews

@mengqiy
Copy link
Member

mengqiy commented Nov 22, 2017

Haven't look at the code closely, but I'm happy this PR doesn't introduce bad dependency.

@liggitt liggitt added this to the v1.10 milestone Nov 22, 2017
@WanLinghao
Copy link
Contributor Author

@liggitt are you ok with this patch? if so , when it can be merged.

@dixudx
Copy link
Member

dixudx commented Nov 24, 2017

@WanLinghao Code freeze now for v1.9 release. And this is not a must-fix issue for v1.9.

Since it has already been labeled for v1.10, please be patient to wait for the end of release v1.9.

Thanks for your contribution.

@WanLinghao
Copy link
Contributor Author

@dixudx OK,thanks

@cblecker
Copy link
Member

cblecker commented Dec 3, 2017

/unassign

@WanLinghao
Copy link
Contributor Author

@smarterclayton @liggitt PTAL

@thockin
Copy link
Member

thockin commented Mar 5, 2018

This change is Reviewable

@k8s-github-robot
Copy link

[MILESTONENOTIFIER] Milestone Removed From Pull Request

@WanLinghao @ericchiang

Important: This pull request was missing labels required for the v1.10 milestone for more than 3 days:

kind: Must specify exactly one of kind/bug, kind/cleanup or kind/feature.
priority: Must specify exactly one of priority/critical-urgent, priority/important-longterm or priority/important-soon.

Help

@k8s-github-robot k8s-github-robot removed this from the v1.10 milestone Mar 6, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 4, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 4, 2018
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. milestone/removed release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. 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.