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

Let kubectl run follow rules for -- #13917

Merged

Conversation

feihujiang
Copy link
Contributor

Fixes #13004

@feihujiang
Copy link
Contributor Author

@smarterclayton @bgrant0607 Could you please review this PR?

@k8s-bot
Copy link

k8s-bot commented Sep 14, 2015

GCE e2e build/test failed for commit b7896da1ff484097fe9cf5a3c87b16dc25e2add3.

@@ -106,6 +107,23 @@ func Run(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cob
return cmdutil.UsageError(cmd, "NAME is required for run")
}

// Let kubectl run follow rules for `--`
var commandAndCustomArgs []string
Copy link
Contributor

Choose a reason for hiding this comment

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

Hrm - this should be implemented by Cobra automatically. Maybe I misunderstand what this is trying to fix?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nm, I reminded myself. There may be a more succint way to fix this

  1. kubectl run -p POD should have zero args
  2. kubectl exec POD should have zero args
  3. kubectl run POD COMMAND should have 1 arg
  4. kubectl run -p POD COMMAND should have 1 arg

If you use SetInterspersed(true) on the cobra.Command object, does that give you the correct behavior in all of these cases? (you might have to grab arg[0] for case 3 and shorten args to args[1:])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This commit doesn't fix these cases, it fixes #13004 . And run command hasn't -p operation.

@k8s-github-robot k8s-github-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 14, 2015
@k8s-github-robot
Copy link

Labelling this PR as size/S

@feihujiang
Copy link
Contributor Author

@smarterclayton This commit fixes #13004 you posted, that is "kubectl run --restart=Never --image=gcr.io/google_containers/busybox --command -- sleep 600
should either error (no name) or make up a name and set command to ["sleep", "600"]. It does neither, turning sleep into the pod name and making command 600. " I understood the bug is that -- isn't effective, -- couldn't seperate between the name and ... Did I get your point in #13004?

@feihujiang
Copy link
Contributor Author

@k8s-bot test this please

@k8s-bot
Copy link

k8s-bot commented Sep 15, 2015

GCE e2e build/test failed for commit b7896da1ff484097fe9cf5a3c87b16dc25e2add3.

@eparis
Copy link
Contributor

eparis commented Sep 15, 2015

I'm trying to understand what we believe the 'syntax' is. These things work today:

  1. kubectl run --image=busybox --command mycontainer echo "hello there"
  2. kubectl run --image=busybox --command mycontainer -- echo "hello there"
  3. kubectl run --image=busybox --command -- mycontainer echo "hello there"

But this patch will break 1 and 3...

@bgrant0607
Copy link
Member

--command was added by #12571, which was a 1.1-alpha release, so backward compatibility is not a concern. We should fix the command to be what we want it to be before we cut 1.1 -- so ASAP.

@bgrant0607
Copy link
Member

Could we just eliminate --command and just rely on --?

@bgrant0607
Copy link
Member

cc @kubernetes/kubectl

@bgrant0607
Copy link
Member

kubectl run mycontainer --image=busybox -- echo -e "\ahello there"

@bgrant0607
Copy link
Member

Nevermind about --command. I see that's a bool. That's fine.

kubectl run mycontainer --image=busybox --command -- echo -e "\ahello there"

@feihujiang
Copy link
Contributor Author

@bgrant0607 --command isn't problem, the problem is that -- is useless now, we can't separate NAME and cmd arg1 ... argN, for example, If miss mycontainer, kubectl run --image=busybox --command -- echo -e "\ahello there", echo would become the name.

@bgrant0607
Copy link
Member

@eparis #13004 proposed that your (3) should not work. It's also fine by me if (1) does not work -- that we require --. But we should be consistent with exec:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/exec.go#L56

How does exec not suffer the same problem?

@feihujiang
Copy link
Contributor Author

@bgrant0607 The exec has the same problem, I point it out in #13004

@feihujiang
Copy link
Contributor Author

If we have the conclusion, I'd like to fix the same problem in exec.

@feihujiang
Copy link
Contributor Author

@k8s-bot test this please

@k8s-bot
Copy link

k8s-bot commented Sep 16, 2015

GCE e2e build/test failed for commit b7896da1ff484097fe9cf5a3c87b16dc25e2add3.

@feihujiang
Copy link
Contributor Author

@k8s-bot test this again please

@k8s-bot
Copy link

k8s-bot commented Sep 16, 2015

GCE e2e build/test failed for commit b7896da1ff484097fe9cf5a3c87b16dc25e2add3.

@eparis
Copy link
Contributor

eparis commented Sep 16, 2015

So git log (and other git like commands) don't allow 3) to work either. I don't mind if we 'break' that, the way that @feihujiang did.

I personally don't love breaking 1) and think it should continue to work. If the consensus is to force -- all the time I won't jump up and down and scream and scream and scream.

@feihujiang seems like it might be useful if cobra stored len(args) when -- was located. Let me write that quickly...

@eparis
Copy link
Contributor

eparis commented Sep 16, 2015

something like: eparis/pflag@b25fea9

@eparis
Copy link
Contributor

eparis commented Sep 16, 2015

along with eparis/cobra@edde52e

@smarterclayton
Copy link
Contributor

I don't like forcing -- either

On Sep 16, 2015, at 11:02 AM, Eric Paris notifications@github.com wrote:

So git log (and other git like commands) don't allow 3) to work either. I
don't mind if we 'break' that, the way that @feihujiang
https://github.com/feihujiang did.

I personally don't love breaking 1) and think it should continue to work.
If the consensus is to force -- all the time I won't jump up and down and
scream and scream and scream.

@feihujiang https://github.com/feihujiang seems like it might be useful
if cobra stored len(args) when -- was located. Let me write that quickly...


Reply to this email directly or view it on GitHub
#13917 (comment)
.

@smarterclayton
Copy link
Contributor

Sorry for the assign spam, bad github UI on mobile.

LGTM

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Nov 18, 2015

GCE e2e build/test failed for commit d1c47c0e79bacc276ad5717dc009df1644fcb4cc.

@feihujiang
Copy link
Contributor Author

@k8s-bot test this please

@k8s-bot
Copy link

k8s-bot commented Nov 18, 2015

GCE e2e test build/test passed for commit d1c47c0e79bacc276ad5717dc009df1644fcb4cc.

@feihujiang
Copy link
Contributor Author

@k8s-bot test this please

@feihujiang
Copy link
Contributor Author

I tested this PR locally, and all tests of unit/integration passed. I don't know why Jenkins unit/integration failing. Who could post the result of Jenkins unit/integration for me? I couldn't get it. Thanks very much.

@k8s-bot
Copy link

k8s-bot commented Nov 18, 2015

GCE e2e build/test failed for commit d1c47c0e79bacc276ad5717dc009df1644fcb4cc.

@feihujiang
Copy link
Contributor Author

I rebased, and found the error.

@janetkuo
Copy link
Member

e2e failure:

22:44:38 Summarizing 1 Failure:
22:44:38 
22:44:38 [Fail] Probing container [It] with readiness probe should not be ready before initial delay and never restart [Conformance] 
22:44:38 /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/test/e2e/container_probe.go:57

unit/integration failure:

22:27:30 FAIL   k8s.io/kubernetes/pkg/kubectl/cmd [build failed]
...
22:30:48 !!! Error in ./hack/test-go.sh:239
22:30:48   'return ${rc}' exited with status 2
22:30:48 Call stack:
22:30:48   1: ./hack/test-go.sh:239 main(...)
22:30:48 Exiting with status 1

@feihujiang feihujiang force-pushed the kubectlRunFollowRules branch from d1c47c0 to 4d2333b Compare November 18, 2015 07:02
@k8s-github-robot
Copy link

PR changed after LGTM, removing LGTM.

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 18, 2015
@k8s-bot
Copy link

k8s-bot commented Nov 18, 2015

GCE e2e test build/test passed for commit 4d2333b.

@feihujiang
Copy link
Contributor Author

@smarterclayton I rebased this PR (use fake.CreateHTTPClient), please review again. @janetkuo thanks.

@feihujiang
Copy link
Contributor Author

@smarterclayton Could you please review this PR, this PR is delayed a lot. Thanks!

@smarterclayton smarterclayton added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 20, 2015
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Nov 20, 2015

GCE e2e test build/test passed for commit 4d2333b.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Nov 20, 2015
@k8s-github-robot k8s-github-robot merged commit 21095ea into kubernetes:master Nov 20, 2015
@feihujiang feihujiang deleted the kubectlRunFollowRules branch November 24, 2015 07:03
jtslear added a commit to jtslear/origin that referenced this pull request Oct 3, 2016
* Removes a todo item from the list
* Test coverage provided by kubernetes/kubernetes#13917
* closes openshift#8620
jtslear added a commit to jtslear/origin that referenced this pull request Oct 3, 2016
* Removes a todo item from the list
* Test coverage provided by kubernetes/kubernetes#13917
* closes openshift#8620
jtslear added a commit to jtslear/origin that referenced this pull request Oct 4, 2016
* Removes a todo item from the list
* Test coverage provided by kubernetes/kubernetes#13917
* closes openshift#8620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.