Commit Graph

84 Commits

Author SHA1 Message Date
Jordan Liggitt 3aa0552959 Switch TableGenerator/TableConvertor interfaces to metav1
Kubernetes-commit: 36eb250cbb441984260ded6f7abeb796974031c3
2019-11-26 13:13:25 -05:00
wojtekt ca6e794c60 Eliminate couple unnecessary conversions
Kubernetes-commit: 067d173266303c5c9a4281e962d3662c34a78053
2019-11-12 14:19:14 +01:00
wojtekt ba8f49cc73 Ensure conversions are registered for metainternalversion codecs
Kubernetes-commit: 54163527a69a8c868b87d301876559495220d1b0
2019-09-11 16:30:08 +02:00
haoshuwei 5bce489f18 fix some ineffassigns
Signed-off-by: haoshuwei <haoshuwei24@gmail.com>

Kubernetes-commit: aaed9daf9b44757e767d93bd45d1bb0412c00243
2019-09-09 18:52:17 +08:00
Dr. Stefan Schimanski fc05a0cd5b endpoints: fix admission test types
Kubernetes-commit: 420f010f8798a8938ff4332ca53bbac8a8e09c01
2019-09-09 08:36:52 +02:00
Di Xu d9e587908f populate object name for admission attributes when CREATE
Kubernetes-commit: 34cab8f80a9104be7fe5d8a5a22c3207dab46268
2017-09-28 14:59:34 +08:00
Jordan Liggitt 0c706a033c Plumb context to admission Admit/Validate
Kubernetes-commit: 61774cd7176cae0c0324d23ab20e6c6b3038153f
2019-08-19 10:48:08 -04:00
xuyasong 394b8d269a staging file fix lint error: receiver name should not be an underscore and rename
Kubernetes-commit: 162b14eca339851aae03725b980acad2c91222c4
2019-07-05 12:49:02 +08:00
Clayton Coleman 72566fea6c Replace HTTP compression with an inline handler
The previous HTTP compression implementation functioned as a filter, which
required it to deal with a number of special cases that complicated the
implementation.

Instead, when we write an API object to a response, handle only that one
case. This will allow a more limited implementation that does not impact
other code flows.

Also, to prevent excessive CPU use on small objects, compression is
disabled on responses smaller than 128Kb in size.

Kubernetes-commit: 4ed2b9875d0498b5c577095075bda341e96fcec2
2019-05-04 17:36:36 -04:00
Jordan Liggitt 6562ecd83a Add GetResourceMapper to admission ObjectInterfaces
Kubernetes-commit: 92f735042e1cae38afe74364c036489fb7a81973
2019-05-13 11:24:20 -04:00
Chao Xu 5c9333e4d3 Run deleteValidation at the storage layer so that it will be retried on
conflict.

Adding unit test verify that deleteValidation is retried.

adding e2e test verifying the webhook can intercept configmap and custom
resource deletion, and the existing object is sent via the
admissionreview.OldObject.

update the admission integration test to verify that the existing object
is passed to the deletion admission webhook as oldObject, in case of an
immediate deletion and in case of an update-on-delete.

Kubernetes-commit: 7bb4a3bace048cb9cd93d0221a7bf7c4accbf6be
2019-04-09 13:49:16 -07:00
yue9944882 019679ce23 Cherrypicking #66535
validate deletion admission object

backward compatibility: add validation for direct storage delete calls

apply nil validation to existing tests

revert behavior changes in deleteCollection call

fixes validation on wiring graceful deletion

remove nil validation check

continue admission check on not found error

Kubernetes-commit: 34c4a6e05767e6c6211b88ccc653f2b07021906a
2018-07-24 12:24:59 +08:00
Clayton Coleman 196c34b775 PartialObjectMetadataList should nest values, not pointers for Items
Typo during setting up PartialObjectMetadataList, it should be a slice
of `PartialObjectMetadata`, not a slice of `*PartialObjectMetadata`.

Kubernetes-commit: f25efd12e63f1d7db5f29fe28831ad0126200c0b
2019-05-13 14:13:00 -04:00
Clayton Coleman 1394d8d85c API server should offer metav1 Table/Partial transforms
Now that internal types are equivalent, allow the apiserver to serve
metav1 and metav1beta1 depending on the client. Test that in the
apiserver integration test and ensure we get the appropriate responses.

Register the metav1 type in the appropriate external locations.

Kubernetes-commit: 33a3e325f754d179b25558dee116fca1c67d353a
2019-05-04 16:55:49 -04:00
Andrew Kim ef71315b08 update import of generic featuregate code from k8s.io/apiserver/pkg/util/feature -> k8s.io/component-base/featuregate
Kubernetes-commit: c91913924543e1d29f3f3d51354701df9df75def
2019-03-04 12:46:52 -05:00
Clayton Coleman f2b20f65e2 Set list meta on PartialObjectMetadataList during transform
Kubernetes-commit: 6801ce990a48196d871f6b46e1a08938025ce7c5
2019-03-24 21:29:20 -04:00
Clayton Coleman dd5dd7ec7e Add benchmark for naive endpoint Get so we can measure it
Baseline:

```
BenchmarkGet-12          	  100000	    119635 ns/op	   20110 B/op	     206 allocs/op
BenchmarkWatchHTTP-12    	  100000	     65761 ns/op	    7296 B/op	     139 allocs/op
```

Kubernetes-commit: 2e1506558ac2c82e83cbef469a6e1e845cfc9235
2019-03-21 20:45:19 -04:00
Clayton Coleman 8d7b330c4c Support Table and PartialObjectMetadata on watch
Clean up the code paths that lead to objects being transformed and output with negotiation.
Remove some duplicate code that was not consistent. Now, watch will respond correctly to
Table and PartialObjectMetadata requests. Add unit and integration tests.

When transforming responses to Tables, only the first watch event for a given type will
include the columns. Columns will not change unless the watch is restarted.

Add a volume attachment printer and tighten up table validation error cases.

Disable protobuf from table conversion because Tables don't have protobuf because they
use `interface{}`

Kubernetes-commit: 3230a0b4fd14a6166f8362d4732e199e8779c426
2018-11-28 23:50:12 -05:00
Mehdy Bohlool 87b5ac0c06 Add ObjectInterfaces to Admission and Validation
Kubernetes-commit: 513a87c7b25aa58f84fafe0dc170cee4c76e481b
2019-02-16 12:27:24 -08:00
Jordan Liggitt 80029a760c Deprecate and remove use of alpha metadata.initializers field, remove IncludeUninitialized options
Kubernetes-commit: 17aa60686ebe5fd04b4fe6f442dc36a8d70b6730
2019-01-17 09:19:28 -05:00
Antoine Pelisse ab5f00eec9 dry-run: Promote from Alpha to Beta
Also remove the test that used to check that the dry-run flag is
forbidden.

Kubernetes-commit: 5dca8e00e6d5501480244b8fd3e8aca54830042a
2018-10-10 15:44:23 -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 ebfb60793e Update the InputStream tests
Kubernetes-commit: ab25c40ceb8af9da74f2cb5cc498ed4d4a0afb9b
2018-08-13 17:35:00 -07:00
yue9944882 d7eae80a4e cleaning up
Kubernetes-commit: a6b781935eb833144c3459f791a3a12cfebc66ee
2018-07-24 15:04:28 +08:00
David Eads cb5cac48ee make package name match all the import aliases
Kubernetes-commit: d3bd0eb1d5cefc25e4476d8dc086ebd90439ef4e
2018-08-01 10:01:32 -04: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 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
Antoine Pelisse 7d9df7dc93 apiserver: Fail if dry-run query param is specified
Kubernetes-commit: 98613924ea282ef70a6f9a14dda11e854fe02c28
2018-05-11 14:59:47 -07:00
David Eads b7f90743d0 remove rootscopedkinds from groupmeta
Kubernetes-commit: 8ae62517da5eff6d6bad21badfd39ee88463ad42
2018-04-30 13:27:01 -04:00
David Eads 0d65d340ea remove versioning interface
Kubernetes-commit: e2fc5cf259463f896213afdef15d58ef9a91eb35
2018-04-25 10:55:17 -04:00
Jordan Liggitt 91142e772a Collapse onto request scope convertor
Kubernetes-commit: 2c1a689952ec34e3f9ecb7bcd1772c3fa35c9597
2018-04-26 16:21:38 -04:00
David Eads 14e43f49d6 rest mappings cannot logically be object converters
Kubernetes-commit: 6900f8856f8cd9a6c94a156b9e4a9fee0c16f807
2018-04-24 18:31:41 -04:00
xuzhonghu 4133c302ad remove useless alwaysAdmit in apiserver test
Kubernetes-commit: e1bcca681d856d68ac54f2fd26a075d79c05d2a9
2018-04-25 16:37:08 +08:00
Mike Danese cd0258b4d7 replace request.Context with context.Context
Kubernetes-commit: 54fd2aaefd11e12a3ecb6d1a1326f04cdc8ea1a3
2018-04-24 08:10:34 -07:00
David Eads 5ac4802a22 remove confusing flexibility for metadata interpretation
Kubernetes-commit: 0710f72c65ad23e7a3726b345898ef4aaaac26fa
2018-04-23 10:23:01 -04:00
Jordan Liggitt 25758bf0f8 Remove request context mapper
Kubernetes-commit: 8ea88a5092c767fc3141512db924fd0435f7670e
2018-04-18 11:12:15 -04:00
Antoine Pelisse cfda35d9c1 apiserver: move patch tests to their own file
Kubernetes-commit: 8341c48b1b1cd459f4265bf747baca62f33eea34
2018-04-18 10:54:35 -07:00
Clayton Coleman 7b21554cfc Make Service storage a wrapper around other storages
The registry abstraction is unnecessary and adds direct coupling to the
core types. By using a wrapper, we carry through the default
implementations of the non-mutating operations. The DeleteCollection
method is explicitly patched out since it cannot be correctly
implemented on the storage currently.

As a result, TableConvertor is now exposed.

A few other minor refactorings

* Corrected the case of some variables
* Used functions instead of methods for several helper methods
* Removed the legacy Deleter - service was the only remaining consumer

Kubernetes-commit: 110b064d630ca39220696225dd597e7d33b95f4f
2018-02-04 22:38:39 -05: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
Clayton Coleman f688fbc3b2 Promote v1alpha1 meta to v1beta1
No code changes, just renames

Kubernetes-commit: d07a608607e1f4d252003c17cd615652574a0823
2018-01-30 13:30:57 -05:00
Jordan Liggitt d57da4670b Add tests for accept content-type fallback
Kubernetes-commit: 39721a2811045f93cf05822246ab3098d7d8ea59
2017-12-12 01:52:30 -05:00
yanxuean 48fc8a399d missing format args in apiserver/pkg/endpoints
Signed-off-by: yanxuean <yan.xuean@zte.com.cn>

Kubernetes-commit: 08b0883734ab39b3b789c225b14e62f5c25be660
2017-11-23 09:52:56 +08:00
Clayton Coleman 9f9cf56bb6 Table printers and server generation should always copy ListMeta
Tables should be a mapping from lists, so if the incoming object has
these add them to the table. Allows paging over server side tables.
Add tests on the generic creater and on the resttest compatibility.

Kubernetes-commit: d2a62fd42234a96cbab2dbcf402c168c59b41784
2017-11-15 21:01:49 -05:00
Clayton Coleman 089e209aad Guarantee that status errors have a kind set
Some errors are invoked outside of negotiation. These errors should
still have a kind and apiVersion (which is only set by structured
encoders, not always availabe). Ensure that all errors by default get a
status kind and version set.

Kubernetes-commit: a1e44fc69bf0faeb47e6d2ebfc2709bbc3f17221
2017-11-15 21:02:34 -05: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
Dr. Stefan Schimanski 3eeded3a29 admission: wire create+update validation func into kube registries
Kubernetes-commit: 2452afffe09e1ced9487e5a701beb1443a92b741
2017-10-24 15:33:28 +02:00
Jordan Liggitt 198ca9b2e0 Use GVK from storage in API registration
Kubernetes-commit: 5913fccada6097c984b168ab15c243a8b20876e5
2017-10-27 04:29:04 -04:00
Dr. Stefan Schimanski 3cfc602704 apimachinery: mechanical removal of ObjectCopier plumbing
Kubernetes-commit: 509df603b18d356777176953e5d160b6f3d0bba9
2017-10-06 13:30:12 +02:00