Commit Graph

854 Commits (43cb024402e6992418b2197228889633b82ddb75)

Author SHA1 Message Date
deads2k 0da5be47cf prevent panic on setting nil deletion timestamp 2017-05-01 11:11:41 -04:00
Ricky Pai a76ada8d5a generated files 2017-04-28 22:55:47 -07:00
Kubernetes Submit Queue 55f802b72a Merge pull request #44196 from xiangpengzhao/cmd-cleanup
Automatic merge from submit-queue

Delete "hard-coded" default value in flags usage.

**What this PR does / why we need it**:
Some flags of kubernetes components have "hard-coded" default values in their usage info. In fact, [pflag pkg](https://github.com/kubernetes/kubernetes/blob/master/vendor/github.com/spf13/pflag/flag.go#L602-L608) has already added a string `(default value)` automatically in the usage info if the flag is initialized. Then we don't need to hard-code the default value in usage info. After this PR, if we want to update the default value of a flag, we only need to update the flag where it is initialized. `pflag` will update the usage info for us. This will avoid inconsistency.

For example:
Before
```
kubelet -h
...
--node-status-update-frequency duration                   Specifies how often kubelet posts node status to master. Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod in nodecontroller. Default: 10s (default 10s)
...
```

After
```
kubelet -h
...
--node-status-update-frequency duration                   Specifies how often kubelet posts node status to master. Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod in nodecontroller. (default 10s)
...
```

**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**:
This PR doesn't delete some "hard-coded" default values because they are not explicitly initialized. We still need to hard-code them to give users friendly info.

```
--allow-privileged                                        If true, allow containers to request privileged mode. [default=false]
```

**Release note**:

```release-note
None
```
2017-04-28 21:28:09 -07:00
Kubernetes Submit Queue ce01882e32 Merge pull request #43301 from deads2k/agg-27-add-conditions
Automatic merge from submit-queue (batch tested with PRs 44044, 44766, 44930, 45109, 43301)

add APIService conditions

Adds conditions to the APIServiceStatus struct and fixes up generators that appear to have slipped.

The first condition is "ServiceAvailable" which will provide the status currently derived in the discovery handler that decides about whether to expose the version in discovery.

@kubernetes/sig-api-machinery-pr-reviews @liggitt @ncdc
2017-04-28 17:49:13 -07:00
Kubernetes Submit Queue 90d5fbca94 Merge pull request #44961 from mikedanese/fix-clone
Automatic merge from submit-queue (batch tested with PRs 45033, 44961, 45021, 45097, 44938)

replace CloneTLSConfig() with (*tls.Config).Clone()
2017-04-28 13:16:40 -07:00
Kubernetes Submit Queue d4ece0abc3 Merge pull request #37499 from fabianofranz/kubectl_plugins
Automatic merge from submit-queue

kubectl binary plugins

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

Introduces the ability to extend `kubectl` by adding third-party plugins that will be exposed through `kubectl`.

Plugins are executable commands written in any language. To be included as a plugin, a binary or script file has to

1. be located under one of the supported plugin path locations:
1.1 `~/.kubectl/plugins` dir
1.2. one or more directory set in the `KUBECTL_PLUGINS_PATH` env var
1.3. the `kubectl/plugins` dir under one or more directory set in the `XDG_DATA_DIRS` env var, which defaults to `/usr/local/share:/usr/share`
2. in any of the plugin path above, have a subfolder with the plugin file(s)
3. in the subfolder, contain at least a `plugin.yaml` file that describes the plugin

Example:

```
$ cat ~/.kube/plugins/myplugin/plugin.yaml
name: "myplugin"
shortDesc: "My plugin's short description"
command: "echo Hello plugins!"

$ kubectl myplugin
Hello plugins!
```

~~In case the plugin declares `tunnel: true`, the plugin engine will pass the `KUBECTL_PLUGIN_API_HOST` env var when calling the plugin binary. Plugins can then access the Kube REST API in "http://$KUBECTL_PLUGIN_API_HOST/api" using the same context currently in use by `kubectl`.~~

Test plugins are provided in `pkg/kubectl/plugins/examples`. Just copy (or symlink) the files to `~/.kube/plugins` to test.

**Which issue this PR fixes**:

Related to the discussions in the proposal document: https://github.com/kubernetes/kubernetes/pull/30086 and https://github.com/kubernetes/community/pull/122.

**Release note**:
```release-note
Introduces the ability to extend kubectl by adding third-party plugins. Developer preview, please refer to the documentation for instructions about how to use it.
```
2017-04-28 12:23:59 -07:00
Kubernetes Submit Queue 9fbefe3b97 Merge pull request #44350 from deads2k/server-17-watch
Automatic merge from submit-queue (batch tested with PRs 44868, 44350)

build external watch event so simple encoders can encode

`kube-apiserver` clients require a specific serialization of `watch.Event` to function properly.  There is no reason to allow flexibility of serialization at this point since no client would able to understand a different encoding.

I found this which trying to use a simple, unstructured json encoder and the clients kept choking on watches because it serialized without the proper json tags.

@kubernetes/sig-api-machinery-pr-reviews
2017-04-28 11:41:34 -07:00
Kubernetes Submit Queue 2315008ea6 Merge pull request #44489 from CaoShuFeng/SelfLinkPathPrefix
Automatic merge from submit-queue

Fix PathPrefix for subresources

before this change:
$ curl -s http://172.16.116.128:8080/api/v1/nodes/kubenet-02/status | grep selfLink
    "selfLink": "/api/v1/nodes/{name}/status/kubenet-02/status",
after this change:
$ curl -s http://172.16.116.128:8080/api/v1/nodes/kubenet-02/status | grep selfLink
    "selfLink": "/api/v1/nodes/kubenet-02/status",

related to:
#44462

**Release note**:

```NONE
```
2017-04-28 10:50:09 -07:00
deads2k afc5ae1539 generated 2017-04-28 11:28:37 -04:00
deads2k b5f0e3d07e add APIService status conditions 2017-04-28 10:47:29 -04:00
Kubernetes Submit Queue 8787b13d75 Merge pull request #43922 from cezarsa/spdy-fix
Automatic merge from submit-queue

prevent corrupted spdy stream after hijacking connection

This PR fixes corner case in spdy stream code where some bytes would never arrive at the server.

Reading directly from a hijacked connection isn't safe because some data may have already been read by the server before `Hijack` was called. To ensure all data will be received it's safer to read from the returned `bufio.Reader`. This problem seem to happen more frequently when using Go 1.8.
This is described in https://golang.org/pkg/net/http/#Hijacker:

> // The returned bufio.Reader may contain unprocessed buffered
   // data from the client.

I came across this while debugging a flaky test that used code from the `k8s.io/apimachinery/pkg/util/httpstream/spdy` package. After filling the code with debug logs and long hours running the tests in loop in the hope of catching the error I finally caught something weird.

The first word on the first spdy frame [read by the server here](b625085230/vendor/github.com/docker/spdystream/spdy/read.go (L148)) had the value `0x03000100`. See, the first frame to arrive on the server was supposed to be a control frame indicating the creation of a new stream, but all control frames need the high-order bit set to 1, which was not the case here, so the saver mistakenly assumed this was a data frame and the stream would never be created. The correct value for the first word of a SYN_STREAM frame was supposed to be `0x80030001` and this lead me on the path of finding who had consumed the first 1 byte prior to the frame reader being called and finally finding the problem with the Hijack call.

I added a new test to try stressing this condition and ensuring that this bug doesn't happen anymore. However, it's quite ugly as it loops 1000 times creating streams on servers to increase the chances of this bug happening. So, I'm not sure whether it's worth it to keep this test or if I should remove it from the PR. Please let me know what you guys think and I'll be happy to update this.

Fixes #45093 #45089 #45078 #45075 #45072 #45066 #45023
2017-04-28 07:40:03 -07:00
Fabiano Franz 2b178ad608 Basic support for kubectl plugins 2017-04-28 01:34:07 -03:00
Mike Danese 6c6dbec1e2 replace CloneTLSConfig() with (*tls.Config).Clone() 2017-04-27 19:51:36 -07:00
Kubernetes Submit Queue b2d714a7ca Merge pull request #44888 from caesarxuchao/clean-deepcopy-init
Automatic merge from submit-queue

Prepare for move zz_generated_deepcopy.go to k8s.io/api

This is in preparation to move deep copies to with the types to the types repo (see https://github.com/kubernetes/gengo/pull/47#issuecomment-296855818). The init() function is referring the `SchemeBuilder` defined in the register.go in the same packge, so we need to revert the dependency.

This PR depends on https://github.com/kubernetes/gengo/pull/49, otherwise verification will fail.
2017-04-27 18:48:28 -07:00
Kubernetes Submit Queue 8efb5c9957 Merge pull request #44983 from caesarxuchao/easy-remove-client-go-api-scheme
Automatic merge from submit-queue (batch tested with PRs 45052, 44983, 41254)

Non-controversial part of #44523

For easier review of #44523, i extracted the non-controversial part out to this PR.
2017-04-27 17:14:04 -07:00
Chao Xu d0b94538b9 make it possible to move SchemeBuilder with zz_generated.deepcopy.go 2017-04-27 16:57:29 -07:00
Kubernetes Submit Queue 14a557b1a2 Merge pull request #44346 from mikedanese/build-static
Automatic merge from submit-queue (batch tested with PRs 41106, 44346, 44929, 44979, 45027)

bazel: statically link dockerized components
2017-04-27 12:11:00 -07:00
Chao Xu 958903509c bazel 2017-04-27 09:41:53 -07:00
Chao Xu 3fa7b7824a easy changes 2017-04-27 09:41:53 -07:00
Kubernetes Submit Queue 2e7cc0222d Merge pull request #44935 from yifan-gu/fix_poll
Automatic merge from submit-queue (batch tested with PRs 44940, 44974, 44935)

apimachinery/pkg/util/wait: Fix potential goroutine leak in pollInternal().

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

Without the change, the wait function wouldn't exit until the timeout
happens, so if the timeout is set to a big value and the Poll() is run
inside a loop, then the total goroutines will increase indefinitely.

This PR fixes the issue by closing the stop channel to tell the wait function
to exit immediately if condition is true or any error happens.
2017-04-26 20:34:14 -07:00
Kubernetes Submit Queue c446132a97 Merge pull request #44974 from caesarxuchao/remove-client-go-api-listers
Automatic merge from submit-queue (batch tested with PRs 44940, 44974, 44935)

Remove import of internal api package in generated external-versioned listers

Follow up of https://github.com/kubernetes/kubernetes/pull/44523

One line change in cmd/libs/go2idl/lister-gen/generators/lister.go, and simple changes in pkg/apis/autoscaling/v2alpha1/register.go, other changes are generated.

The internal api package will be eliminated from client-go, so these imports should be removed. Also, it's more correct to report the versioned resource in the error.
2017-04-26 20:34:13 -07:00
Kubernetes Submit Queue 904b020756 Merge pull request #43469 from enisoc/has-conflicts
Automatic merge from submit-queue

Fix mergepatch.HasConflicts().

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

This fixes some false negatives:

* If a map had multiple entries, only the first was checked.
* If a list had multiple entries, only the first was checked.

**Which issue this PR fixes**:

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```
2017-04-26 18:32:33 -07:00
Kubernetes Submit Queue 433aec11c8 Merge pull request #44531 from pwittrock/kubectl-openapi
Automatic merge from submit-queue

OpenAPI support for kubectl

Support for openapi spec in kubectl.

Includes:
- downloading and caching openapi spec to a local file
- parsing openapi spec into binary serializable datastructures (10x faster load times 600ms -> 40ms)
- caching parsed openapi spec in memory for each command

```release-note
NONE
```
2017-04-26 16:59:17 -07:00
Chao Xu ee61ffb4b1 bazel 2017-04-26 14:41:10 -07:00
Chao Xu 0bac9b6aaa update list-gen to not import internal package in external listers 2017-04-26 14:41:09 -07:00
Andy Goldstein fc2128c8d8 Update bazel 2017-04-26 09:45:19 -04:00
Andy Goldstein 715d5d9c91 Add redirect support to SpdyRoundTripper
Add support for following redirects to the SpdyRoundTripper. This is
necessary for clients using it directly (e.g. the apiserver talking
directly to the kubelet) because the CRI streaming server issues a
redirect for streaming requests.

Also extract common logic for following redirects.
2017-04-26 09:45:19 -04:00
Cao Shufeng dde1221839 Fix PathPrefix for subresources 2017-04-26 14:51:19 +08:00
Kubernetes Submit Queue d03ca66367 Merge pull request #41636 from luxas/bump_go_18
Automatic merge from submit-queue (batch tested with PRs 41287, 41636, 44881, 44826)

Bump to go1.8 and remove the edge GOROOT

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

Bumps to go1.8; we get:
 - performance improvements
 - build time improvements
 - the possibility to remove the hacky edge-GOROOT for arm and ppc64le that must use go1.8
 - all other awesome features that are included in go1.8: https://golang.org/doc/go1.8

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

**Special notes for your reviewer**:

@ixdy Please push the image ASAP so we can see if this passes all tests

**Release note**:

```release-note
Upgrade go version to v1.8
```
cc @ixdy @bradfitz @jessfraz @wojtek-t @timothysc @spxtr @thockin @smarterclayton @bprashanth @gmarek
2017-04-25 17:56:40 -07:00
Kubernetes Submit Queue fd3171b3a8 Merge pull request #41287 from whitlockjc/webhook-tests
Automatic merge from submit-queue (batch tested with PRs 41287, 41636, 44881, 44826)

apiserver: add pkg/util/webhook tests

This commit adds tests for pkg/util/webhooks.  The purpose of this was not only for better code coverage but also to alleviate the need for consumers to write their own tests for core functionality.

**Reasoning**

While working on the generic webhook admission plugin for https://github.com/kubernetes/community/pull/132, I found out that there are no tests for `staging/k8s.io/apiserver/pkg/util/webhook` and I also noticed that various places in the k8s sources were also replicating the same core tests that could/should be handled in `staging/k8s.io/apiserver/pkg/util/webhook`:

* `staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook_test.go`
* `staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook_test.go`
* `plugin/pkg/admission/imagepolicy/admission_test.go`
* _possibly more..._

That's what this PR does, adds tests for `staging/k8s.io/apiserver/pkg/util/webhook` so that consumers no longer have to worry about testing client configuration issues, TLS issues, etc. just to use `staging/k8s.io/apiserver/pkg/util/webhook`.

cc @cjcullen
2017-04-25 17:56:38 -07:00
Yifan Gu 3d0391864e apimachinery/pkg/util/wait: Fix potential goroutine leak in pollInternal().
Without the change, the wait function wouldn't exit until the timeout
happens, so if the timeout is set to a big value and the Poll() is run
inside a loop, then the total goroutines will increase indefinitely.

This PR fix the issue by closing the stop channel to tell the wait function
to exit immediately if condition is true or any error happens.
2017-04-25 17:24:40 -07:00
Lucas Käldström 50af2e84ab
Update the staging directory 2017-04-26 00:32:00 +03:00
Lucas Käldström f32e6d8a89
Update protobuf 2017-04-25 23:50:31 +03:00
Kubernetes Submit Queue e1adcc2367 Merge pull request #44583 from mikedanese/go1.8
Automatic merge from submit-queue

bump bazel build to go1.8.1 and remove invalid unit tests

part of https://github.com/kubernetes/kubernetes/issues/38228

I firmly believe that unit tests that check error strings are incorrect unit tests. If we care about what type of error is returned, we need to use public error types. Anywhere we are using generic errors, we don't care other then that we saw an error.
2017-04-25 13:32:28 -07:00
Kubernetes Submit Queue f4eed2477d Merge pull request #44491 from NickrenREN/volume-MountOptionAnnotation
Automatic merge from submit-queue (batch tested with PRs 44601, 44842, 44893, 44491, 44588)

Define const annotation variable once

We do not need to define the const annotation var twice in pkg/volume and pkg/volume/validation


**Release note**:
```release-note
NONE
```
2017-04-25 12:51:39 -07:00
Mike Danese e48a4f0af7 fix various bad tests 2017-04-25 11:23:33 -07:00
Phillip Wittrock 21e239fb82 kubectl OpenAPI bazel updates 2017-04-25 10:45:50 -07:00
Phillip Wittrock 212c2a3a72 kubectl OpenAPI support 2017-04-25 10:45:49 -07:00
Phillip Wittrock 70704196be kubectl OpenAPI godeps updates 2017-04-25 10:44:56 -07:00
Kubernetes Submit Queue cd380b580b Merge pull request #44462 from deads2k/server-21-selflink
Automatic merge from submit-queue (batch tested with PRs 42477, 44462)

fix cluster scoped self-link

Might fix #37622, definitely fixes the cluster-scoped resource problem.  Looks like it was just a typo when compared against  https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/endpoints/installer.go#L451

@adohe @DirectXMan12
2017-04-25 10:25:46 -07:00
Kubernetes Submit Queue 1fd19f7fa2 Merge pull request #42477 from jsafrane/v1-2-new-api
Automatic merge from submit-queue (batch tested with PRs 42477, 44462)

Use storage.v1 instead of v1beta1

storage.v1beta1 was used to work around GKE which did not expose v1. Now that GKE is updated, we can switch everything to v1.

This is simple sed v1beta1 -> v1 + enabled a new test + changed preference of exposed interfaces in `storage/install/install.go`.

@msau42, PTAL and let me know when GKE is updated with storage v1 API and this PR can be actually merged.

@kubernetes/sig-storage-pr-reviews 

```release-note
NONE
```
2017-04-25 10:25:44 -07:00
deads2k 5746d876e3 fix cluster scoped self-link 2017-04-25 11:23:18 -04:00
Jan Safranek cde2746821 Regenerate everything 2017-04-25 15:34:46 +02:00
Liam White 0bdfb7ae13 Increase code coverage for pkg/api/resource
Signed-off-by: Liam White <liamwhite@uk.ibm.com>
2017-04-25 08:12:11 +01:00
Kubernetes Submit Queue c3ec845ab6 Merge pull request #44862 from liggitt/icc-namespace-override
Automatic merge from submit-queue

Stop treating in-cluster-config namespace as an override

Fixes #44835

The namespace of an in-cluster config should behave like the namespace specified in a kubeconfig file... it should be used as the default namespace, but be able to be overridden by namespaces specified in yaml files passed to `kubectl create -f`.

```release-note
Restored the ability of kubectl running inside a pod to consume resource files specifying a different namespace than the one the pod is running in.
```
2017-04-24 19:22:42 -07:00
Jeremy Whitlock d15dba7e8b apiserver: add pkg/util/webhook tests
This commit adds tests for pkg/util/webhooks.  The purpose of this was
not only for better code coverage but also to alleviate the need for
consumers to write their own tests for core functionality.
2017-04-24 16:13:17 -06:00
Kubernetes Submit Queue a9454baba4 Merge pull request #44788 from enisoc/patch-numeric
Automatic merge from submit-queue

PATCH: Fix erroneous meaningful conflict for numeric values.

The wrong json package was used, resulting in patches being unmarshaled with numbers as float64 rather than int64. This in turn confused `HasConflicts()` which expects numeric types to match.

The end result was false positives of meaningful conflicts, such as:

```
there is a meaningful conflict (firstResourceVersion: "8517", currentResourceVersion: "8519"):
 diff1={"metadata":{"resourceVersion":"8519"},"spec":{"replicas":0},"status":"conditions":null,"fullyLabeledReplicas":null,"replicas":0}}
, diff2={"spec":{"replicas":0}}
```

This is branched from a discussion on https://github.com/kubernetes/kubernetes/pull/43469.

```release-note
Fix false positive "meaningful conflict" detection for strategic merge patch with integer values.
```
2017-04-24 12:11:29 -07:00
Jordan Liggitt 1305559abb
Stop treating in-cluster-config namespace as an override 2017-04-24 14:33:02 -04:00
Kubernetes Submit Queue 7e42d3848e Merge pull request #44492 from CaoShuFeng/namer
Automatic merge from submit-queue (batch tested with PRs 44837, 44779, 44492)

remove duplicate code from restful namer

The deleted codes have the same logic with function ObjectName.

**Release note**:

```release-note
```
2017-04-24 07:56:02 -07:00
Kubernetes Submit Queue c90faa8071 Merge pull request #44779 from enj/enj/r/etcd_default_name_copy
Automatic merge from submit-queue (batch tested with PRs 44837, 44779, 44492)

Default ObjectNameFunc for all REST Stores

All `Store`s in Kubernetes follow the same logic for determining the name of an object.  This change makes it so that `CompleteWithOptions` defaults the `ObjectNameFunc` if it is not specified.  Thus a user does not need to remember to use `ObjectMeta.Name`.  Using the wrong field as the name can lead to an object which has a name that bypasses normal object name validation.

Signed-off-by: Monis Khan <mkhan@redhat.com>

cc @liggitt @soltysh for review

**Release note**:

```
NONE
```
2017-04-24 07:55:59 -07:00