Commit Graph

96 Commits

Author SHA1 Message Date
Wojciech Tyczyński 38d7003d33 Remove selflink setting from apiserver
Kubernetes-commit: 0a674d3ed92ce6384e2e8018ca63cf2925474146
2022-01-13 15:29:21 +01:00
Abu Kashem 450b7e8f12 rename audit Checker interface
Kubernetes-commit: 27f150351475adaef416bd893403e7066b70d33a
2021-03-24 13:07:21 -04:00
tanjing2020 4785d0d3e4 fix staticcheck failures on vendor/k8s.io/apiserver/pkg/endpoints
Kubernetes-commit: c38a06bca6bb360caf9bc679ba19a5a4be662bd1
2020-12-11 14:23:30 +08:00
Abu Kashem 026eb846a4 apiserver: plumb context with request deadline
- as soon as a request is received by the apiserver, determine the
  timeout of the request and set a new request context with the deadline.
- the timeout filter that times out non-long-running requests should
  use the request context as opposed to a fixed 60s wait today.
- admission and storage layer uses the same request context with the
  deadline specified.

we use the default timeout enforced by the apiserver:
- if the user has specified a timeout of 0s, this implies no timeout on the user's part.
- if the user has specified a timeout that exceeds the maximum deadline allowed by the apiserver.

Kubernetes-commit: e416c9e574c49fd0190c8cdac58322aa33a935cf
2020-11-26 23:53:20 -05:00
David Eads 67507290ad finish removal of exportoptions
Kubernetes-commit: 37cc89ed8d5194f288bc9f9633e6142647631a07
2021-01-22 09:21:56 -05:00
Jordan Liggitt cec339c07a Revert "plumb context with request deadline"
This reverts commit 83f869ee1350da1b65d508725749fb70d0f535f2.

Kubernetes-commit: afd92b3b3ea8fa8e3dbe2521d6ce213c809d25c7
2020-11-19 18:15:04 -05:00
Abu Kashem 46e3e4810e plumb context with request deadline
- as soon as a request is received by the apiserver, determine the
timeout of the request and set a new request context with the deadline.
- the timeout filter that times out non-long-running requests should
use the request context as opposed to a fixed 60s wait today.
- admission and storage layer uses the same request context with the
deadline specified.

Kubernetes-commit: 83f869ee1350da1b65d508725749fb70d0f535f2
2020-10-30 16:30:05 -04:00
Chao Xu cfa0865e12 Collect storage versions as ResourceInfo when installing API endpoints.
Co-authored-by: Haowei Cai <haoweic@google.com>

Kubernetes-commit: 369475681679e1cb68c23c3355542599a3c0e1e3
2020-02-24 15:35:14 -08:00
wojtekt 14d59e2950 Stop setting SelfLink in kube-apiserver.
Kubernetes-commit: 2539912a2245a53f6612100a32af96dd71a2ad4f
2019-07-26 15:48:37 +02:00
Gaurav Singh c9bcb3fdcc TestCreateInvokeAdmissionControl: remove unnecessary goroutine in sequential processing
Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>

Kubernetes-commit: 06547556390a3cc86865c0c3fb579b0ca53a9b1b
2020-07-10 19:19:17 -04:00
wojtekt 59604ff55c Not rely on default conversions in apiserver test
Kubernetes-commit: 8c59c2133cabe70039f67986383a3598c174e546
2020-02-11 14:53:17 +01:00
danielqsj 76c4ab8bb5 unify alias of api errors under pkg and staging
Kubernetes-commit: 5bc0e26c1902e7e28abfc828de19a2dbb3e492c2
2019-11-12 16:26:59 +08:00
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