Commit Graph

3612 Commits (042b5642b9926267e470fb0a2c0dd2df19eb6c6a)

Author SHA1 Message Date
Mikhail Mazurskiy b28a83a4cf
Migrate to GetControllerOf from meta/v1 package 2017-08-06 22:41:58 +10:00
Kubernetes Submit Queue 5490273951 Merge pull request #48553 from superbrothers/fix-kubectl-42
Automatic merge from submit-queue

Fix a bug that --flag=val causes completion error in zsh

**What this PR does / why we need it**:
This PR fixes a bug that flag of syntax like --flag=val causes completion error in zsh.

```
kubectl --namespace=foo g__handle_flag:25: bad math expression: operand expected at end of string
```

This problem is due to [dynamic scope](https://en.wikipedia.org/wiki/Scope_(computer_science)#Dynamic_scoping) of shell variables. If a variable is declared as local to a function, that scope remains until the function returns.

In kubectl completion zsh, `declare -A flaghash` in __start_kubectl() is replaced with `__kubectl_declare -A flaghash` by __kubectl_convert_bash_to_zsh(). As a result of it, flaghash is declared in __kubectl_declare(), and it can not access to flaghash declared in __kubectl_declare() from __handle_flag(). Therefore an error occurs in __handle_flag().

The following is the minimum reproduction code.

```sh
#!/usr/bin/env zsh

set -e

__kubectl_declare() {
    builtin declare "$@"
}

__handle_flag() {
    local flagname="--namespace="
    local flagval="kube-system"

    flaghash[${flagname}]=${flagval}

    echo "flaghash[${flagname}]=${flaghash[${flagname}]}"
}

__handle_word() {
    __handle_flag
}

__start_kubectl() {
    __kubectl_declare -A flaghash

    __handle_word
}

__start_kubectl

#
# $ zsh reproduction.zsh
# __handle_flag:4: bad math expression: operand expected at end of string
#

# __start_kubectl {
#
#     __kubectl_declare {
#
#         builtin declare -A flaghash
#
#     }
#
#     __handle_word {
#
#         __handle_flag {
#
#             # It is unable to access flaghash declared in __kubectl_declare from here
#             flaghash[${flagname}]=${flagval}
#
#         }
#
#     }
# }
```

The following is the fixed code.
```sh
#!/usr/bin/env zsh

set -e

__handle_flag() {
    local flagname="--namespace="
    local flagval="kube-system"

    flaghash[${flagname}]=${flagval}

    echo "flaghash[${flagname}]=${flaghash[${flagname}]}"
}

__handle_word() {
    __handle_flag
}

__start_kubectl() {
    builtin declare -A flaghash

    __handle_word
}

__start_kubectl

#
# $ zsh fixed.zsh
# flaghash[--namespace=]=kube-system
#

# __start_kubectl {
#
#     builtin declare -A flaghash
#
#     __handle_word {
#
#         __handle_flag {
#
#             # It is able to access flaghash declared in __start_kubectl from here :)
#             flaghash[${flagname}]=${flagval}
#
#         }
#
#     }
# }
```
https://gist.github.com/superbrothers/0ede4292f6d973f93e54368e227a4902

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*:
fixes kubernetes/kubectl#42

**Special notes for your reviewer**:
@mengqiy

**Release note**:

```release-note
NONE
```
2017-08-06 02:45:49 -07:00
Kubernetes Submit Queue deb5c77ce1 Merge pull request #49843 from alrs/kubectl-rolling_updater-swallowed-error
Automatic merge from submit-queue (batch tested with PRs 48487, 49009, 49862, 49843, 49700)

fix swallowed error in kubectl rolling_updater

This fixes a swallowed error in kubectl. 

AddDeploymentKeyToReplicationController() is already tested, but there was an error that was not being exposed.

```release-note
NONE
```
2017-08-04 23:40:07 -07:00
Kubernetes Submit Queue eeb72d7892 Merge pull request #49862 from dixudx/kubectl_run_labels
Automatic merge from submit-queue (batch tested with PRs 48487, 49009, 49862, 49843, 49700)

add label examples for kubectl run

**What this PR does / why we need it**:

Add `--labels` examples for kubectl run

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
xref #49854

**Special notes for your reviewer**:
/cc @ahmetb 

**Release note**:

```release-note
add examples for kubectl run --labels
```
2017-08-04 23:40:05 -07:00
Antoine Pelisse a1d0384e82 openapi: Remove cache mechanism
The cache will be removed and replaced with HTTP Etag caching instead.
This patch is simply removing the existing mechanism.
2017-08-04 14:36:32 -07:00
Kubernetes Submit Queue 5d24a2c199 Merge pull request #49300 from tklauser/syscall-to-x-sys-unix
Automatic merge from submit-queue

Switch from package syscall to golang.org/x/sys/unix

**What this PR does / why we need it**:

The syscall package is locked down and the comment in https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24 advises to switch code to use the corresponding package from golang.org/x/sys. This PR does so and replaces usage of package syscall with package golang.org/x/sys/unix where applicable. This will also allow to get updates and fixes
without having to use a new go version.

In order to get the latest functionality, golang.org/x/sys/ is re-vendored. This also allows to use Eventfd() from this package instead of calling the eventfd() C function.

**Special notes for your reviewer**:

This follows previous works in other Go projects, see e.g. moby/moby#33399, cilium/cilium#588

**Release note**:

```release-note
NONE
```
2017-08-03 04:02:12 -07:00
Kubernetes Submit Queue 6579b2e4d1 Merge pull request #50018 from tcharding/kubectl-delete
Automatic merge from submit-queue (batch tested with PRs 50000, 49954, 49943, 50018, 49607)

Remove extraneous white space

**What this PR does / why we need it**:

Output from command `kubectl delete --help` contains extraneous whitespace. While we are at it, paragraph in multi-paragraph section has shorter line lengths, text looks better if all paragraphs have similar line lengths.

**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**:

White space only. This PR is outward facing but so trivial I don't think it needs a release note. I'm new around here, if this assumption is incorrect please tell me. Thanks.

**Release note**:

```release-note
NONE
```
2017-08-02 20:07:53 -07:00
Kubernetes Submit Queue 84e0326eb1 Merge pull request #49782 from supereagle/update-generated-deepcopy
Automatic merge from submit-queue (batch tested with PRs 50029, 48517, 49739, 49866, 49782)

Update generated deepcopy code

**What this PR does / why we need it**:
In generated deepcopy code, the method names in comments do not match the real method names.

**Which issue this PR fixes**: fixes #49755

**Special notes for your reviewer**:
/assign @sttts @caesarxuchao 


**Release note**:
```release-note
NONE
```
2017-08-02 12:46:57 -07:00
tcharding 496dba08a8 Remove extraneous white space 2017-08-03 00:01:54 +10:00
supereagle a1c880ece3 update generated deepcopy code 2017-07-31 22:33:00 +08:00
Kazuki Suda 3b00b9a5da Fix a bug that --flag=val causes completion error in zsh
Remove __kubectl_declare

`declare -F` is already replaced to `whence -w` by __kubectl_convert_bash_to_zsh().
2017-07-31 23:12:55 +09:00
Di Xu 3d35a0739f add label examples for kubectl run 2017-07-31 15:04:30 +08:00
Lars Lehtonen aa76cc8d7b
fix swallowed error in kubectl rolling_updater 2017-07-29 16:45:34 -07:00
Di Xu ac6ec1a69d rename this file to delete.go to avoid confusion 2017-07-29 03:29:14 +00:00
Kubernetes Submit Queue a2d7dc5b36 Merge pull request #46784 from alexandercampbell/fix-reaper-timeout-bug
Automatic merge from submit-queue

Fix Reaper timeout bug

This PR is an fix to the issue [noticed](https://github.com/kubernetes/kubernetes/pull/46468#discussion_r118589512) in a previous PR.

Previous behavior was to calculate a timeout but then ignore it, using `reaper.timeout` instead.
New behavior is to use the calculated timeout for `waitForStatefulSet`, which is passed to the Scaler.

Thanks to @foxish and @apelisse for pointing me in the right direction.

**Release note**:

```release-note
NONE
```
2017-07-28 15:30:24 -07:00
Kubernetes Submit Queue 8f8b9fa971 Merge pull request #47267 from fabianofranz/kubectl_plugins_v1_part3
Automatic merge from submit-queue (batch tested with PRs 49619, 49598, 47267, 49597, 49638)

Flag support in kubectl plugins

Adds support to flags in `kubectl` plugins. Flags are declared in the plugin descriptor and are passed to plugins through env vars, similar to global flags (which already works).

Fixes https://github.com/kubernetes/kubernetes/issues/49122

**Release note**:

```release-note
Added flag support to kubectl plugins
```
PTAL @monopole @kubernetes/sig-cli-pr-reviews
2017-07-28 05:08:05 -07:00
Kubernetes Submit Queue bc3c5bc0d6 Merge pull request #49146 from apelisse/openapi-new-structure
Automatic merge from submit-queue (batch tested with PRs 49665, 49689, 49495, 49146, 48934)

openapi: refactor into more generic structure

**What this PR does / why we need it**:
Refactor the openapi schema to be a more generic structure that can be
"visited" to get more specific types. Will be used by validation.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: #44589

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```
2017-07-27 21:45:36 -07:00
Alexander Campbell 080e45d775 StatefulSetReaper#Stop: use the timeout we calculate
Previous behavior was to use the Reaper's timeout field for both Scaler
timeouts.
2017-07-27 11:34:32 -07:00
Kubernetes Submit Queue 001ded68e4 Merge pull request #49476 from CaoShuFeng/image-name
Automatic merge from submit-queue (batch tested with PRs 47357, 49514, 49271, 49572, 49476)

enhance kubectl run error message

Before this change:
 $ kubectl run nginx
 error: Invalid image name "": invalid reference format

After this change:
 $ kubectl run nginx
 error: --image is required


**Release note**:
```
NONE
```
2017-07-26 12:03:52 -07:00
Kubernetes Submit Queue d4897e875b Merge pull request #47160 from shashidharatd/fed-internalclientset
Automatic merge from submit-queue (batch tested with PRs 46913, 48910, 48858, 47160)

federation: Stop using and remove federation internalclientset

**What this PR does / why we need it**:
This probably a left over job. We should not be using the internal clientset and instead be using versioned ones as described in #29934

**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
NONE
```

/assign @nikhiljindal 
/cc @kubernetes/sig-federation-misc
2017-07-25 23:00:38 -07:00
Kubernetes Submit Queue 4399fb2b87 Merge pull request #49071 from foxish/foxish-api
Automatic merge from submit-queue (batch tested with PRs 43443, 46193, 49071, 47252)

Add v1beta2.DaemonSet

Depends on https://github.com/kubernetes/kubernetes/pull/48746
Partly implements https://github.com/kubernetes/kubernetes/issues/49135

```release-note
Adding type apps/v1beta2.DaemonSet
```
2017-07-25 21:52:50 -07:00
Cao Shufeng 292b18db1f enhance kubectl run error message
Before this change:
 # kubectl run nginx
 error: Invalid image name "": invalid reference format

After this change:
 # kubectl run nginx
 error: --image is required
2017-07-26 11:24:03 +08:00
Kubernetes Submit Queue 778da50811 Merge pull request #49259 from dixudx/fix_jsonpatch_nil_value_merge
Automatic merge from submit-queue (batch tested with PRs 49259, 49350)

update json-patch to fix nil value issue when creating mergepatch

**What this PR does / why we need it**:
When [creating a patch for merge](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/annotate.go#L255), nil value will be considered as different value. This has been fixed and merged in [evanphx/json-patch #45](https://github.com/evanphx/json-patch/pull/45).

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #49044

**Special notes for your reviewer**:
/cc @MikeSpreitzer @mengqiy 

**Release note**:

```release-note
Fix nil value issue when creating json patch for merge
```
2017-07-25 20:01:27 -07:00
shashidharatd d51ae181a5 Auto generated files 2017-07-26 06:22:30 +05:30
shashidharatd dbbcb568d4 Converted usage of federation internal clientset to versioned clientset 2017-07-26 06:20:08 +05:30
Kubernetes Submit Queue 9350afd772 Merge pull request #48976 from supereagle/cleanup-api-package
Automatic merge from submit-queue (batch tested with PRs 48976, 49474, 40050, 49426, 49430)

Remove duplicated import and wrong alias name of api package

**What this PR does / why we need it**:

**Which issue this PR fixes**: fixes #48975

**Special notes for your reviewer**:
/assign @caesarxuchao

**Release note**:
```release-note
NONE
```
2017-07-25 12:14:38 -07:00
foxish ca38850ab1 DS: kubectl changes 2017-07-25 11:47:57 -07:00
Antoine Pelisse 064f806424 openapi: refactor into more generic structure
Refactor the openapi schema to be a more generic structure that can be
"visited" to get more specific types.
2017-07-25 11:45:29 -07:00
Di Xu 2235d8d6cc update related files 2017-07-25 12:56:50 +08:00
Kubernetes Submit Queue 0e94e9439f Merge pull request #49438 from zhangxiaoyu-zidif/delete-err-def-for-drain
Automatic merge from submit-queue (batch tested with PRs 48911, 49475, 49438, 49362, 49274)

Delete redundant err definition

**What this PR does / why we need it**:
Delete redundant err definition
line 642 has its definition and initialization, so line 641 is redundant.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
NONE

**Special notes for your reviewer**:
NONE

**Release note**:

```release-note
NONE
```
2017-07-24 20:39:18 -07:00
Kubernetes Submit Queue 8c58bb6ed3 Merge pull request #49088 from xiangpengzhao/get-crd
Automatic merge from submit-queue (batch tested with PRs 48636, 49088, 49251, 49417, 49494)

Add customresourcedefinition and its shortcut in "kubectl get"

**What this PR does / why we need it**:
Add customresourcedefinition and its shortcut in "kubectl get" help info.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #48927

**Special notes for your reviewer**:
/cc @orangedeng 

**Release note**:

```release-note
NONE
```
2017-07-24 19:30:35 -07:00
supereagle adc0eef43e remove duplicated import and wrong alias name of api package 2017-07-25 10:04:25 +08:00
Eric Paris 7c531ecc13 Do not spin forever if kubectl drain races with other removal
In https://github.com/kubernetes/kubernetes/pull/47450 we stopped
returning an error if a pod disappeared before we could remove it.
Instead we just continue to spin forever. Return "success" if a pod
disappeared before we actually removed it.

https://bugzilla.redhat.com/1473777
bug 1473777
2017-07-22 13:39:01 -04:00
zhangxiaoyu-zidif 1b785d09d4 Delete redundant err definition 2017-07-22 16:19:32 +08:00
Kubernetes Submit Queue 1dbe09b1f6 Merge pull request #49326 from deads2k/cli-16-all
Automatic merge from submit-queue

add cronjobs to all

Categories were added to the discovery API, but the `kubectl` plumbing didn't make it.  We *did* make `kubectl all` gate on discovery information, so it can least be a superset.  

`cronjobs` are user resources, so I've added them to the list.

@kubernetes/sig-cli-misc 

```release-note
added cronjobs.batch to all, so kubectl get all returns them.
```
2017-07-21 23:18:58 -07:00
Kubernetes Submit Queue c1c7193b4d Merge pull request #46514 from ravisantoshgudimetla/scheduler_taints_refactor
Automatic merge from submit-queue (batch tested with PRs 49420, 49296, 49299, 49371, 46514)

Refactoring taint functions to reduce sprawl

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #45060

**Special notes for your reviewer**:
@gmarek @timothysc @k82cn @jayunit100 - I moved some fn's to helpers and some to utils. LMK, if you are ok with this change.

**Release note**:

```release-note
NONE
```
2017-07-21 22:23:24 -07:00
Kubernetes Submit Queue 22cc294364 Merge pull request #46598 from xiangpengzhao/fix-kubectl-version
Automatic merge from submit-queue (batch tested with PRs 46210, 48607, 46874, 46598, 49240)

Make "kubectl version" json format output more readable.

**What this PR does / why we need it**:
##39858 adds a flag --output to `kubectl version`, but the json format output is displayed in one line. It's not so readable. This PR fixes it.

and

- adds a shorthand for `output`
- ~~refactors that: if `--short` is specified, `--output` will be ignored~~

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #43750

**Special notes for your reviewer**:
/cc @php-coder @alejandroEsc 

**Release note**:

```release-note
NONE
```
2017-07-21 17:00:21 -07:00
deads2k 1477b407c7 add cronjobs to all 2017-07-21 10:56:26 -04:00
Tobias Klauser 4a69005fa1 switch from package syscall to x/sys/unix
The syscall package is locked down and the comment in [1] advises to
switch code to use the corresponding package from golang.org/x/sys. Do
so and replace usage of package syscall with package
golang.org/x/sys/unix where applicable.

  [1] https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24

This will also allow to get updates and fixes for syscall wrappers
without having to use a new go version.

Errno, Signal and SysProcAttr aren't changed as they haven't been
implemented in /x/sys/. Stat_t from syscall is used if standard library
packages (e.g. os) require it. syscall.SIGTERM is used for
cross-platform files.
2017-07-21 12:14:42 +02:00
ymqytw 9b393a83d4 update godep 2017-07-20 11:03:49 -07:00
ymqytw 3dfc8bf7f3 update import 2017-07-20 11:03:49 -07:00
Kubernetes Submit Queue 6d534b38e8 Merge pull request #48253 from CaoShuFeng/serviceaccount
Automatic merge from submit-queue (batch tested with PRs 49218, 48253, 48967, 48460, 49230)

allow impersonate serviceaccount in cli

We can impersonate four kinds of resources according to the code:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/endpoints/filters/impersonation.go#L83

**Release note**:

```
allow impersonate serviceaccount in cli
```
Fixes: https://github.com/kubernetes/kubernetes/issues/48260
2017-07-19 20:05:32 -07:00
ravisantoshgudimetla b01a1c3881 Build files generated 2017-07-19 18:36:12 -04:00
ravisantoshgudimetla 9dbf1a5644 Refactoring taints to reduce sprawl 2017-07-19 18:36:07 -04:00
Kubernetes Submit Queue 575cbdf7d4 Merge pull request #45012 from xiangpengzhao/fix-delete-svc
Automatic merge from submit-queue

Remove service on termination when exec 'kubectl run' command with flags "--rm" and "--expose"

**What this PR does / why we need it**:
As the title says and issue #40504 mentioned.
cc @tanapoln

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #40504 

**Special notes for your reviewer**:
Related to: #44915

**Release note**:

```release-note
NONE
```
2017-07-19 07:59:34 -07:00
Kubernetes Submit Queue d74ac3785e Merge pull request #48950 from alexandercampbell/kubectl-deduplicate-deployment-generators
Automatic merge from submit-queue (batch tested with PRs 49120, 46755, 49157, 49165, 48950)

kubectl: deduplicate deployment generators

**What this PR does / why we need it**: See the description on https://github.com/kubernetes/kubectl/issues/44

**Which issue this PR fixes**: fixes https://github.com/kubernetes/kubectl/issues/44

**Special notes for your reviewer**: Yes, the lines added and removed are about the same. This is because I added 20+ lines of docstrings. Check the diff. You'll see I deleted a lot of duplicated logic :)

**Release note**:

```release-note
NONE
```
2017-07-19 00:06:29 -07:00
Kubernetes Submit Queue 882f838a0d Merge pull request #49134 from deads2k/cli-14-tolerate-missing-template
Automatic merge from submit-queue (batch tested with PRs 49055, 49128, 49132, 49134, 49110)

make sure that the template param is the right type before using it

The CLI should attempt to make sure that the flags it uses conform to expectations instead of unconditionally killing a process.  This allows for possible re-use of the printing stack.
2017-07-18 21:54:23 -07:00
Kubernetes Submit Queue 8337bd028d Merge pull request #49132 from deads2k/cli-01-union-category
Automatic merge from submit-queue (batch tested with PRs 49055, 49128, 49132, 49134, 49110)

add a union category expander

Adds a union category expander for use when we need to combined hardcoded and non-hardcoded options.
2017-07-18 21:54:22 -07:00
Kubernetes Submit Queue 32580b89b1 Merge pull request #48871 from wanghaoran1988/do_not_close_stdin
Automatic merge from submit-queue (batch tested with PRs 48914, 48535, 49099, 48935, 48871)

do not close os.Stdin manually

**What this PR does / why we need it**:
We don't need close os.Stdin manually, it will block our read from stdin after finish the visit.
**Special notes for your reviewer**:

**Release note**:
```
None
```
2017-07-18 21:04:28 -07:00
Kubernetes Submit Queue 7bd44a21be Merge pull request #48481 from fabianofranz/apply_protect_against_nil_panic
Automatic merge from submit-queue (batch tested with PRs 48481, 48256)

Protect against nil panic in apply

**What this PR does / why we need it**: `kubectl apply` has a potential panic (actually verified in OpenShift in https://github.com/openshift/origin/issues/15017) where a `patcher` calls the `runDelete` function with a nil `resource.RESTClient`, but under some conditions the client is required by that function.

**Release note**:

```release-note
NONE
```

@pwittrock @kubernetes/sig-cli-bugs
2017-07-18 18:19:17 -07:00