Commit Graph

31 Commits

Author SHA1 Message Date
hangaoshuai ca5f87b89a Refactor hard code in rest_test.go
Kubernetes-commit: de1f2c8310fbefbbc6ac38ce6ca2dd90d781b5f5
2018-05-08 15:42:06 +08:00
Jordan Liggitt 050d3a3aa4 Fix govet error
Kubernetes-commit: f6b08d6d76be65239e3775b52bf99fa81fec667b
2018-04-26 16:10:29 -04:00
Jordan Liggitt 68ff1d00ce Add tests for resourceVersion precondition failures on patch
Kubernetes-commit: b526532c8abf3cbd4442f364377cb7c7f42f199e
2018-04-25 22:44:46 -04:00
Jordan Liggitt aa2276ee48 collapse patch conflict retry onto GuaranteedUpdate
builds on #62868

1. When the incoming patch specified a resourceVersion that failed as a precondition,
the patch handler would retry uselessly 5 times. This PR collapses onto GuaranteedUpdate,
which immediately stops retrying in that case.

2. When the incoming patch did not specify a resourceVersion, and persisting to etcd
contended with other etcd updates, the retry would try to detect patch conflicts with
deltas from the first 'current object' retrieved from etcd and fail with a conflict error
in that case. Given that the user did not provide any information about the starting version
they expected their patch to apply to, this does not make sense, and results in arbitrary
conflict errors, depending on when the patch was submitted relative to other changes made
to the resource. This PR changes the patch application to be performed on the object retrieved
from etcd identically on every attempt.

fixes #58017
SMP is no longer computed for CRD objects

fixes #42644
No special state is retained on the first attempt, so the patch handler correctly handles
the cached storage optimistically trying with a cached object first

Kubernetes-commit: fbd6f3808480d27a83643e82a11c217601b76cbc
2018-04-24 21:55:06 -04:00
Daniel Smith c8a994aada Refactor the patch handler for readability
This is the combination of a series of changes which individually don't
make any behavioral changes. The original commits are preserved in my
own fork in the refactor-patch-complete branch, as when squashed this is
impossible to review.

This turned a big function with lots of parameters and closures into an
object with multiple functions, fewer closures and more well documented
state transitions.

Kubernetes-commit: 349a99b80e7e6c0c92218c814ae0858fd71609fc
2018-04-18 16:59:17 -07:00
Mike Danese cd0258b4d7 replace request.Context with context.Context
Kubernetes-commit: 54fd2aaefd11e12a3ecb6d1a1326f04cdc8ea1a3
2018-04-24 08:10:34 -07:00
Cao Shufeng 4741d69bc6 trace patch operations
Just like `update`, `create`, `get` and `delete` operations.

Kubernetes-commit: 534eb3dfbd734dd44357e97dcb10fdf3b1ce5880
2018-01-05 11:09:51 +08:00
Dr. Stefan Schimanski 204da0b2db apiserver: add validating admission tests
- in endpoint tests
- in generic registry
- in patch handler
- in admission chain

Kubernetes-commit: c558d2a3517fafdb704edd2c00b6df6738786959
2017-11-07 10:40:43 +01:00
Cao Shufeng 35655c329b [trival]remove duplicated code from unit test
Kubernetes-commit: acb90b6547e0d8304a0f75bf21b9769c5186cf5d
2017-11-05 15:02:41 +08:00
Dr. Stefan Schimanski 441ac63056 admission: complete plumbing of validation admission
Kubernetes-commit: 74b4223ab80fa3bbf326ac1073ef28f0b8daa304
2017-10-24 14:08:34 +02:00
Nikhita Raghunath eb855aac8e Fix error for strategic merge patch of custom resources
We need the go struct tags `patchMergeKey` and `patchStrategy`
for fields that support a strategic merge patch. For native
resources, we can easily figure out these tags since we know
the fields.

Because custom resources are decoded as Unstructured and
because we're missing the metadata about how to handle
each field in a strategic merge patch, we can't find the
go struct tags. Hence, we can't easily  do a strategic merge
for custom resources.

So we should fail fast and return an error.

Kubernetes-commit: 79349c93bddcc1125a9d6ea4528c6d63b172f083
2017-10-07 17:29:19 +05:30
Nikhita Raghunath 6f448f398c apiserver: return 4xx for invalid patch
Add interpretPatchError to return appropriate http code
(400 or 422) according to the error type.

We add this function in apiserver because we don't want
to mention the http code in apimachinery. The apimachinery
code is also used in kubectl. The client should not return
a server error.

Add a test to validate the http error code and error message.

Kubernetes-commit: e0a2168ecbf8b4e43f932a32fa55cd55215123cc
2017-10-24 17:26:03 +05:30
Dr. Stefan Schimanski 3cfc602704 apimachinery: mechanical removal of ObjectCopier plumbing
Kubernetes-commit: 509df603b18d356777176953e5d160b6f3d0bba9
2017-10-06 13:30:12 +02:00
Dr. Stefan Schimanski 36b2f4560f deepcopy: add interface deepcopy funcs
- add DeepCopyObject() to runtime.Object interface
- add DeepCopyObject() via deepcopy-gen
- add DeepCopyObject() manually
- add DeepCopySelector() to selector interfaces
- add custom DeepCopy func for TableRow.Cells

Kubernetes-commit: 39d95b9b065fffebe5b6f233d978fe1723722085
2017-07-19 03:49:08 +00:00
Dr. Stefan Schimanski 5c33fc4de4 apimachinery: remove unneeded GetObjectKind() impls
Kubernetes-commit: da3322c2d93671b7cbff9b090dd5e1ce9984130e
2017-07-16 04:08:42 +00:00
Wojciech Tyczynski 1d0b329280 Pass RequestInfo to GenerateLink
Kubernetes-commit: b4018f7da18f1e61e59c5c48cae4178db2714f85
2017-06-13 20:47:27 +00:00
Wojciech Tyczynski d82b8bc329 Pass Context to GenerateLink
Kubernetes-commit: 25f0fe1adb199697565487b9dfacc4ed8ecdccbb
2017-06-13 20:47:27 +00:00
yupengzte e701e40544 format re
Signed-off-by: yupengzte <yu.peng36@zte.com.cn>

Kubernetes-commit: 9eee70656fc411029c91edafdbfa327eb0736528
2017-05-20 17:28:13 +00:00
nikhiljindal 404503d3e6 Updating generic registry to return UID while deleting the object
Kubernetes-commit: 44fc88cecd5ab175fe7907eb7b975f0a00cb2305
2017-05-16 17:27:51 +00:00
Chao Xu e46eb82a82 remove invocation of k8s.io/client-go/pkg/api/install
change import of client-go/api/helper to kubernetes/api/helper

remove unnecessary use of client-go/api.registry

change use of client-go/pkg/util to kubernetes/pkg/util

remove dependency on client-go/pkg/apis/extensions

remove unnecessary invocation of k8s.io/client-go/extension/intsall

change use of k8s.io/client-go/pkg/apis/authentication to v1

Kubernetes-commit: c354076aa41e3cf417b291d5f0eff2b70395ac30
2017-05-13 17:27:42 +00:00
Dr. Stefan Schimanski 21f84e3d21 apiserver: split endpoint tests from client-go
Kubernetes-commit: 67ca42b2d7e9efb5701618fb3d7faa62c53101c5
2017-05-02 20:36:05 +00:00
Anthony Yeh 9841cf11a1 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}}
```

Kubernetes-commit: 1ab6a33db486adc060e1b63eecbdc06aabdde1f6
2017-04-24 20:36:05 +00:00
deads2k d3546820d7 remove go-restful from namer for rest handling
Kubernetes-commit: da27957390b99c3053922e75f220a8b09c20d7f6
2017-04-10 20:35:11 +00:00
Jordan Liggitt fa876f6773 Fix original object mutation on patch retry
Kubernetes-commit: c415e4aeabe5e5514dcdbf2c01c533533c25f4c1
2017-04-06 20:35:16 +00:00
Jordan Liggitt 8543f589d2 Ensure patched objects are defaulted correctly
Kubernetes-commit: 464db160b410b22dba53af6d11fa097f0fa4fd6b
2017-03-18 19:56:09 +00:00
ymqytw 7306f452f2 switch to k8s json to avoid number conversion issue
Kubernetes-commit: b29f4c26d799dca6606b45a0e03f7f931abcdefc
2017-03-18 19:56:09 +00:00
Wojciech Tyczynski 63e29dca6f Use new runtime.Object <-> map[string]interface{} converter 2017-02-27 15:10:34 -05:00
deads2k 1e2d8fe122 remove cycle that snuck into tests 2017-02-23 09:48:09 -05:00
Dr. Stefan Schimanski 73c30cda7e staging/src/*: run gofmt 2017-02-23 09:48:09 -05:00
Dr. Stefan Schimanski a372fcad62 Mechanical fixup imports: pkg/genericapiserver 2017-02-13 07:36:41 -05:00
Dr. Stefan Schimanski f3c3e07241 Mechanical move: pkg/genericapiserver -> k8s.io/apiserver 2017-02-13 07:36:41 -05:00