Commit Graph

144 Commits

Author SHA1 Message Date
Jordan Liggitt dba666528b Allow specifying the hub group-version for a handler
Kubernetes-commit: 0e9b06df0f21b421ff69fd455d4542883d61e8c3
2018-10-22 10:14:52 -04:00
Jordan Liggitt b758170bd7 Inline patch#toUnversioned
Kubernetes-commit: 870d121d5e8033a72c62ef3a64939f0eacab6798
2018-10-22 10:01:27 -04:00
Cao Shufeng be442e0127 return 400 status when invalid json patch passed to apiserver
Kubernetes-commit: 1248f569917511c37501b6ef6bbb215ce87353dc
2018-09-11 14:11:39 +08:00
jennybuckley 008018b080 fix typo in dry run disabled error
Kubernetes-commit: 5253c7f414a686e8bcf721655b7ffe26e81765b4
2018-09-12 14:43:18 -07:00
Antoine Pelisse 35d83292e2 dry-run: Allow dry-run flag to pass through if alpha enabled
Kubernetes-commit: 5f364a0b84669a2dc086a35292db088b912d1c3c
2018-06-28 08:59:58 -07:00
Tim Allclair 2390bdcec0 Cleanup apiserver errors
Kubernetes-commit: 0a68e906ed79669912ad3f4cf22f72b6669d343f
2018-07-03 15:21:42 -07:00
Tristan Burgess 753c6a1ccc 50342: Establish '406 Not Acceptable' response for protobuf serialization 'errNotMarshalable'
- Added metav1.Status() that enforces '406 Not Acceptable' response if
    protobuf serialization is not fully supported for the API resource type.
     - JSON and YAML serialization are supposed to be more completely baked
    in, so serialization involving those, and general errors with seralizing
    protobuf, will return '500 Internal Server Error'.
	- If serialization failure occurs and original HTTP status code is
    error, use the original status code, else use the serialization failure
    status code.
     - Write encoded API responses to intermediate buffer
     - Use apimachinery/runtime::Encode() instead of
    apimachinery/runtime/protocol::Encode() in
    apiserver/endpoints/handlers/responsewriters/writers::SerializeObject()
     - This allows for intended encoder error handling to fully work, facilitated by
    apiserver/endpoints/handlers/responsewriters/status::ErrorToAPIResponse() before officially
    writing to the http.ResponseWriter
     - The specific part that wasn't working by ErrorToAPIResponse() was the
    HTTP status code set. A direct call to
    http.ResponseWriter::WriteHeader(statusCode) was made in
    SerializeObject() with the original response status code, before
    performing the encode. Once this
    method is called, it can not again update the status code at a later
    time, with say, an erro status code due to encode failure.
     - Updated relevant apiserver unit test to reflect the new behavior
    (TestWriteJSONDecodeError())
     - Add build deps from make update for protobuf serializer

50342: Code review suggestion impl
 - Ensure that http.ResponseWriter::Header().Set() is called before http.ResponseWriter::WriteHeader()
    - This will avert a potential issue where changing the response media type to text/plain wouldn't work.
    - We want to respond with plain text if serialization fails of the original response, and serialization also fails for the resultant error response.

50342: wrapper for http.ResponseWriter
  - Prevent potential performance regression caused by modifying encode to use a buffer instead of streaming
    - This is achieved by creating a wrapper type for http.ResponseWriter that will use WriteHeader(statusCode) on the first
    call to Write(). Thus, on encode success, Write() will write the original statusCode. On encode failure, we pass control
    onto responsewriters::errSerializationFatal(), which will process the error to obtain potentially a new status code, depending
    on whether or not the original status code was itself an error.

50342: code review suggestions
  - Remove historical note from unit test comment
  - Don't export httpResponseWriterWithInit type (for now)

Kubernetes-commit: bcdf3bb64333ce12f15b1beebef48f554d69027f
2018-08-06 19:18:36 -04:00
Yu-Ju Hong 6b85aed1d6 apiserver: pass the parent request context when creating InputStream
This ensures that request cancellation will be propagated properly to
the client used to create the stream. Without this fix, the apiserver
and the kubelet may leak resources (e.g., goroutine, inotify watches).
One such example is that if user run `kubectl logs -f <container that
don't produce new logs)` and then enter ctrl-c, both kubelet and
apiserver will hold on to the connection and resources indefinitely.

Kubernetes-commit: 31d1607a514b62ef46452e402f5438d827314b98
2018-08-13 16:34:49 -07:00
Jordan Liggitt 5558d0c5ce Make the request attributes clearer in forbidden messages
Kubernetes-commit: 4e0a3b557e235ad354f6dfb4567d2a20ebde403a
2018-08-09 15:51:52 -04:00
Chao Xu e1ccfa4e7d Remove rest.ConnectRequest.
Make apiserver pass connectRequest.Options directly to the admission layer. All
the information in rest.ConnectRequest is present in admission attributes.

Kubernetes-commit: 355691d310803ea3a0cd8ff284a39ead38857602
2018-07-30 18:35:51 -07:00
jennybuckley 4dcfdb8ab8 Explicitly disable dry run for connect
Kubernetes-commit: 702937ac8614a05d3168c6565bea8a3347883dc0
2018-07-11 11:45:24 -07:00
jennybuckley 91278157f6 Support dry run in admission plugins
Kubernetes-commit: adafb1365e2b9f6c422c437e916e22a4fe1c2e3a
2018-08-06 10:37:44 -07:00
Clayton Coleman b605717f7d Make the timeout error more specific so users can find it
This makes the error consistent with the timeout filter and also helps
the user understand that they requested a specific timeout.

Kubernetes-commit: 8a2d037bc51c97758c0a68f2726f104953846cd5
2018-07-25 12:50:39 -04:00
Antoine Pelisse 026601bbf1 dry-run: Add DryRunTrue value
Kubernetes-commit: e99651b34bf94fdead5a8827abe0fc98159cd16d
2018-07-09 15:52:16 -07:00
yue9944882 3b41cc363d fixes operation for "create on update"
remove create-on-update logic for quota controller

review: add more error check

remove unused args

revert changes in patch.go

use hasUID to judge if it's a create-on-update

Kubernetes-commit: ccb1ec7a3695082326fe60ec06890f91004dc043
2018-06-28 16:35:15 +08:00
Clayton Coleman 2b9b0922e8 Make conversion function names match expected values
Kubernetes-commit: ba95744bc56970ccc67e51589122911bfdb5425a
2018-07-03 16:06:44 -04:00
xuzhonghu cbadd11a32 remove useless codec param from strategicPatchObject
Kubernetes-commit: 43baa697aac69a0d88edad77f8fe2ef3896c2996
2018-07-17 11:33:53 +08:00
Antoine Pelisse cc843478d7 dry-run: Create new options for Update/Create and pass it along
Kubernetes-commit: 03b1e14101a73706980b559b4b7069ea956c80bd
2018-06-14 09:14:59 -07:00
Jordan Liggitt 453662ac63 change field selector conversion registration to be strongly typed
Kubernetes-commit: f51ba20cddeb44be355a79718a8274c272efc1e4
2018-07-03 15:47:20 -04:00
jennybuckley 900791d3ac Add additional authorization check for create-on-update
Kubernetes-commit: cc5c17e554a4d8f802043b337ca0787ec0ce7475
2018-07-03 11:20:16 -07:00
jennybuckley 621e8af54b Allow override AllowCreateOnUpdate with new argument to Update
Kubernetes-commit: d10e08fc897f6b5e60ce2aa8420bd2ea536e18b8
2018-06-28 14:24:51 -07:00
Mikhail Mazurskiy 0f7bbcadfb Add missing error handling in schema-related code
Kubernetes-commit: bfe313d5f351dfae086a85a97e7103183173e5b5
2018-06-03 14:59:58 +10:00
Clayton Coleman 9a797b9333 Print type information when unknown watch error
Got

```
E0628 00:23:07.106285       1 watch.go:274] unable to encode watch object: expected pointer, but got invalid kind
```

on a production system and had no way to debug what type was being sent.

Kubernetes-commit: 307849baef076d8ee61a3b9649f9260a765f7ac0
2018-06-27 20:34:48 -04:00
Jordan Liggitt 1f9c7bdd99 Quiet verbose apiserver logs
Kubernetes-commit: 862f8567bb4b1d4e9f63330cf3a516af61ae7cc5
2018-06-11 22:32:46 -04:00
Cao Shufeng 167894cc94 Log policy name from pod security policy
Kubernetes-commit: 241422879d81ac7f8d7874d55c53df73e35d91b0
2018-04-15 10:20:10 +08:00
Guoliang Wang 704926d8fc HandleError include the type of the error object
Kubernetes-commit: f2cb23ad6a14169f5e2a82c5d3b1bd6ebc1074a5
2018-05-25 13:59:05 +08:00
jennybuckley f87486fed9 Expose openapi schema to handlers
Kubernetes-commit: dee088586a76b876c473418efba8190be7fa6b26
2018-05-24 09:55:19 -07:00
wojtekt 6d795842cd Requires single name for list and watch
Kubernetes-commit: f344c5c0621b3e187ade02a6858bccb2c2d641bd
2018-05-06 15:15:32 +02:00
Dr. Stefan Schimanski c4d743d011 apiextensions: only create patch reference object for smp path
Kubernetes-commit: 9745d6c11927686d99b80af45e4a631e155ebf80
2018-05-15 19:35:05 +02:00
wojtekt 27dca16e75 Track number of registered watchers in apiserver
Kubernetes-commit: bdd9492da0c992e532c5e5d07cae3b68c9b7b78f
2018-05-14 11:22:10 +02:00
Antoine Pelisse 7d9df7dc93 apiserver: Fail if dry-run query param is specified
Kubernetes-commit: 98613924ea282ef70a6f9a14dda11e854fe02c28
2018-05-11 14:59:47 -07:00
hangaoshuai ca5f87b89a Refactor hard code in rest_test.go
Kubernetes-commit: de1f2c8310fbefbbc6ac38ce6ca2dd90d781b5f5
2018-05-08 15:42:06 +08:00
Jordan Liggitt 91142e772a Collapse onto request scope convertor
Kubernetes-commit: 2c1a689952ec34e3f9ecb7bcd1772c3fa35c9597
2018-04-26 16:21:38 -04:00
Jordan Liggitt 050d3a3aa4 Fix govet error
Kubernetes-commit: f6b08d6d76be65239e3775b52bf99fa81fec667b
2018-04-26 16:10:29 -04:00
jennybuckley 56ec7f69aa Remove unnecessary typer from create/update handlers
Kubernetes-commit: 5e23dd0517f493011e7c529464f448d6b2ae9ef7
2018-04-23 12:29:37 -07: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
hzxuzhonghu c3f6af1ec1 avoid calling Handles twice
Kubernetes-commit: 9ce6da671d7035c1f9bcc8db9c7f0c69f9701210
2018-04-21 13:44:14 +08:00
hzxuzhonghu f11d20d5bf fix typo: mutating validating admission should be distinguished
Kubernetes-commit: cd4c71422e41e9dbbc015e8b6c0e1b6b5bb67346
2018-04-21 11:37:36 +08:00
Jordan Liggitt 25758bf0f8 Remove request context mapper
Kubernetes-commit: 8ea88a5092c767fc3141512db924fd0435f7670e
2018-04-18 11:12:15 -04:00
Mengqi Yu c621a422af fix patch conflict detection in apiserver
Kubernetes-commit: ff18af452dafef7fc115512940e0c6250ccf31ca
2018-03-29 16:43:23 -07:00
Kubernetes Publisher 627fa76a8b sync: initially remove files BUILD */BUILD BUILD.bazel */BUILD.bazel 2018-03-15 09:38:17 +00:00
hangaoshuai 8e51703adb remove unused function negotiate() and writeYAML()
Kubernetes-commit: 5f908c226c9df144dfc0e1665381b8ec534a60a4
2018-02-23 14:53:51 +08:00
Mike Danese cee5e95803 remove deprecated /proxy paths
These were depercated in v1.2.

Kubernetes-commit: 7b4722964d21c994e0fdf36c0d7f5b0dc703a9c2
2018-02-14 11:13:54 -08:00
Jeff Grafton 1ab12b2dc8 Autogenerated: hack/update-bazel.sh
Kubernetes-commit: ef56a8d6bb3800ab7803713eafc4191e8202ad6e
2018-02-16 13:43:01 -08:00
Nikhita Raghunath 2cc4871e76 Collect prometheus metrics for custom resources
Since we have a custom handler for apiextensions-apiserver,
we need to record the metrics here.

Kubernetes-commit: 74cd45fb21b349dd037e3bfd844459ca5834cca1
2017-12-28 14:36:31 +05:30
Clayton Coleman f688fbc3b2 Promote v1alpha1 meta to v1beta1
No code changes, just renames

Kubernetes-commit: d07a608607e1f4d252003c17cd615652574a0823
2018-01-30 13:30:57 -05:00
halfcrazy 6f8c3a80da fix typo in package apiserver
Kubernetes-commit: 0da91a8577ddfdeaff985cbb6c0da69d5a2ffc81
2018-02-01 03:04:33 +08:00