-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Conversation
@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". 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. |
/ok-to-test |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: WanLinghao Assign the PR to them by writing 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 |
|
/unassign |
1fd56b5
to
e8d2365
Compare
@kubernetes/sig-cli-pr-reviews |
/test pull-kubernetes-unit |
/assign cblecker |
pkg/kubectl/cmd/set/set_volume.go
Outdated
|
||
const ( | ||
volumePrefix = "volume-" | ||
storageAnnClass = "volume.beta.kubernetes.io/storage-class" |
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.
No need to import new storageAnnClass
, use api.BetaStorageClassAnnotation
instead.
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.
OK
pkg/kubectl/cmd/set/set_volume.go
Outdated
func (o *VolumeOptions) addVolumeToSpec(spec *api.PodSpec, info *resource.Info, singleResource bool) error { | ||
opts := o.AddOpts | ||
if len(o.Name) == 0 { | ||
var err 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.
Better change to
if o.Name, err := o.getVolumeName(spec, singleResource); err != nil {
return err
}
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.
I think cause o.Name is an existed variable, so your way is not suitable
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.
var err error
if o.Name, err = o.getVolumeName(spec, singleResource); err != nil {
return err
}
did you mean this?
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.
SGTM
return errors.New("either specify --type or --source but not both for --add operation") | ||
} | ||
|
||
if len(a.Type) > 0 { |
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.
I wonder shall we split these checking to separate methods to make it more concise and maintainable.
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.
@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" |
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.
Actually I don't like such a hard-coded way.
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.
@dixudx please make it more clear.Do you mean this function contains too much things?
pkg/kubectl/cmd/set/set_volume.go
Outdated
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/types" | ||
"k8s.io/apiserver/pkg/storage/names" | ||
"k8s.io/kubernetes/pkg/api" |
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.
no internal type
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.
@shiywang I am not clear with version stuff, would please give me some hints, thanks a lot
pkg/kubectl/cmd/set/set_volume.go
Outdated
|
||
apierrs "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/api/meta" | ||
kresource "k8s.io/apimachinery/pkg/api/resource" |
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.
nit: i would prefer just "k8s.io/apimachinery/pkg/api/resource" since there's no upstream dependency anymore.
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.
since this file import another resource package "k8s.io/kubernetes/pkg/kubectl/resource"
pkg/kubectl/cmd/set/set_volume.go
Outdated
} | ||
|
||
func (o *VolumeOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, out, errOut io.Writer) error { | ||
kc, err := f.ClientSet() |
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.
nit: in kubernetes, we can just call it client
pkg/kubectl/cmd/set/set_volume.go
Outdated
if len(o.AddOpts.ClaimName) == 0 { | ||
o.AddOpts.ClaimName = names.SimpleNameGenerator.GenerateName("pvc-") | ||
} | ||
q, err := kresource.ParseQuantity(o.AddOpts.ClaimSize) |
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.
ditto, kresource
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.
+1
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" |
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.
this should be removed, use versioned api
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.
use "k8s.io/client-go/kubernetes/typed/core/v1" replacing "k8s.io/kubernetes/pkg/api"?
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.
@zjj2wry since I am still not clear with this version stuff
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.
api rep: k8s.io/api...
api maybe in: k8s.io/api/core/v1
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.
@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
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.
yes, will fix all set command :), and it is in process
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.
@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
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.
it's being actively worked on in #54554
@WanLinghao I would prefer not adding this until that PR is in
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.
@liggitt OK, I will wait for this and rebase then
@WanLinghao this PR lgtm when your fix small nits. |
@WanLinghao: The following test failed, say
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
19327f2
to
87d22e0
Compare
@liggitt PTAL |
@zjj2wry do you know who can help push this, thanks |
@liggitt PTAL thanks |
/retest |
Haven't look at the code closely, but I'm happy this PR doesn't introduce bad dependency. |
@liggitt are you ok with this patch? if so , when it can be merged. |
@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. |
@dixudx OK,thanks |
/unassign |
@smarterclayton @liggitt PTAL |
[MILESTONENOTIFIER] Milestone Removed From Pull Request Important: This pull request was missing labels required for the v1.10 milestone for more than 3 days: kind: Must specify exactly one of |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
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: