Commit Graph

499 Commits

Author SHA1 Message Date
Maciej Borsz df684d906a Add 'apiserver_watch_events_total' metric.
We found this metric useful to understand the CPU usage of the
kube-apiserver process.

Kubernetes-commit: 58d3338ddd5e406988fdfaa9019fd7200996c49f
2019-06-05 14:27:09 +02:00
Odin Ugedal 1be6195f27 Fix file permissions for non executable files
Normal files should have permissions 644 by default,
and does not require the last bit to be
executable

Signed-off-by: Odin Ugedal <odin@ugedal.com>

Kubernetes-commit: 35cb87f9cf71776e99a970dfff751cd29ba7ebfb
2019-06-14 21:04:39 +02:00
Sukeesh 8f207390a6 Update doc.go in staging/src/k8s.io/
Kubernetes-commit: c8bd20d1b289eadb6abc20f0868f4a5a6a668035
2019-06-25 22:43:44 +09:00
jennybuckley e67aadb10a Don't dereference nil pointer in conflicts
Kubernetes-commit: c71583a31368d1e4e71cd458d6961d8fec2265f1
2019-06-13 14:42:19 -07:00
zhoulin xie 77ddb0c208 remove redundant words 'the' in comment
Signed-off-by: zhoulin xie <zhoulin.xie@daocloud.io>

Kubernetes-commit: 77ba845e6d2f0cba81993621531ae5915e7c072b
2019-02-13 22:40:34 +08:00
Clayton Coleman dc06278276 CRDs should support watch of protobuf PartialObjectMetadata
Correctly ensure CRDs can be watched using protobuf when transformed to
PartialObjectMetadata. To do this we add a set of serializers allowed to
be used for "normal" requests (that return CRDs) while the serializers
supported by the infrastructure is broader and includes protobuf. During
negotatiation we check for transformation requests and protobuf is
excluded from non-transform requests.

As part of the change, correct an error message when the server returns
a 406 but the client doesn't accept the format to avoid confusing users
who set impossible Accept rules for CRDs (the dynamic client doesn't
support Protobuf, so if the server responds with a protobuf status the
message from the server is lost and the generic error was confusing).

Kubernetes-commit: 89e752add07f443248f66e4798d160f2d7529a19
2019-04-16 23:21:44 -04:00
Chao Xu 74be843d4b generated
Kubernetes-commit: 369314959c1bf096c1d3502f10b28a00c3d12691
2019-05-24 17:46:39 -07:00
Jordan Liggitt 6562ecd83a Add GetResourceMapper to admission ObjectInterfaces
Kubernetes-commit: 92f735042e1cae38afe74364c036489fb7a81973
2019-05-13 11:24:20 -04:00
Jordan Liggitt 054e44a286 make ObjectInterfaces impl generic
Kubernetes-commit: 9071d21e3b1989ffeee4f533406e4fef6bf32aa8
2019-05-13 11:22:11 -04:00
Haowei Cai 7620fd14c0 install deleteoptions in deletecollection endpoints
Kubernetes-commit: 277a7413370e56c98f5dc8633660c5e4ea4df13c
2019-05-13 16:13:13 -07: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
Antoine Pelisse 2d27d30e4d fieldManager: Ignore conversion errors to internal types
Errors on updates are bad because they usually come from controllers and
it's very hard to take actions on them. We also don't want to start
breaking kubernetes clusters if something in a schema happens a way we
didn't foresee (even though we've tried to be diligent and test as much
as possible, these can still happen).

Log an identifiable error when they happen. Ideally people can look in
the logs to find these and report them, or providers can look for these
in logs and make sure they don't happen.

Only conversion to internal types are going to be logged and ignored.

It means that we're still failing for:
- Version conversions. If we can't convert the object from one version
  to another,
- Unions. If we can't normalize the union,
- Invalid MangedFields sent in the object. If something has changed the
  ManagedFields to an invalid value.
- Failure to serialize the manager information, this really shouldn't
  happen.
- Encoding the ManagedFields

Kubernetes-commit: 4e32d183d0257c9f6c7f8342d1f9aa7f28458f2f
2019-05-16 11:07:47 -07:00
Joe Betz 19327df6d5 Pass {Operation}Option to Webhooks
Kubernetes-commit: 140c8c73a64deb102b528109138ca9fb7dbb2392
2019-05-07 13:34:18 -07: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
jennybuckley e999a5ebe2 Treat NoCorrespondingTypeError as MissingVersionError
Kubernetes-commit: 13cb241b1833495c8f195dac96dacf54c0ba4a3a
2019-05-06 15:13:36 -07:00
zuoxiu.jm 7195bbdf3c properly transform decoder error into status error
Kubernetes-commit: 1e65162d44f83d74e9802caf34848abed3eb403c
2018-11-28 16:11:11 +08:00
Haowei Cai 4ff581692b remove TrimSuffix and document buffer size
Kubernetes-commit: 0e61b77826f23cbf835002a9eef5722bb1cfdf53
2019-04-01 11:02:39 -07:00
leigh capili 7762f62741 Refactor loops over SupportedMediaTypes() where mediaType is used to match a single SerializerInfo{}
We have an existing helper function for this:  runtime.SerializerInfoForMediaType()

This is common prep-work for encoding runtime.Objects into JSON/YAML for transmission over the wire or writing to ComponentConfigs.

Kubernetes-commit: 47e52d2981dc2a5c5950042f50688cf24dd92eda
2019-04-04 19:01:01 -06:00
Clayton Coleman e4e8608ba0 Use CodecFactory.WithoutConversion() everywhere
Clarifies that requesting no conversion is part of the codec factory, and
future refactors will make the codec factory less opionated about conversion.

Kubernetes-commit: 7f9dfe58f4cbe1e1b9e80f52addff70bac87bed4
2019-04-03 13:24:37 -04:00
fansong.cfs 73057f16b6 add timeout suuport for watch
Kubernetes-commit: b304a1f96d85cd351a0e22a091e17064d5edb35e
2019-04-03 09:37:48 +08:00
Benjamin Elder 8ad12b3912 Revert "add timeout suuport for watch"
This reverts commit c676e234cc1036a2a1147f2eeef9c89468671330.

Kubernetes-commit: 30a56bab42ab14a3a2ee21f5581b02525d4fd110
2019-04-01 18:39:17 -07:00
Clayton Coleman f2b20f65e2 Set list meta on PartialObjectMetadataList during transform
Kubernetes-commit: 6801ce990a48196d871f6b46e1a08938025ce7c5
2019-03-24 21:29:20 -04:00
fansong.cfs 4d2b8eee69 add timeout suuport for watch
Kubernetes-commit: c676e234cc1036a2a1147f2eeef9c89468671330
2019-03-30 20:07:41 +08:00
Clayton Coleman c8f7d5017d Make RequestScope be a pointer consistently for better memory use
RequestScope is a large struct and causes stack growth when we pass
it by value into multiple stack levels. Avoid the allocations for
this read only struct by passing a pointer.

Kubernetes-commit: 8fede0b18a81a6fb1acc1a48857f482857c25286
2019-03-25 23:33:48 -04:00
Clayton Coleman 8e43494f09 Avoid allocating the watch shim object more than once
We can reset and reuse this object repeatedly without triggering an
allocation.

Kubernetes-commit: 316a87ce7dff525555483eaac962899fd365177d
2019-03-26 23:34:25 -04:00
Clayton Coleman 8541248953 Avoid allocations when building SelfLinks and fast path escape
A self link should only require one allocation, and we should skip
url.PathEscape() except when the path actually needs it.

Add a fuzz test to build random strings and verify them against
the optimized implementation. Add a new BenchmarkWatchHTTP_UTF8 that
covers when we have unicode names in the self link.

```
> before
BenchmarkGet-12          	   10000	    118863 ns/op	   17482 B/op	     130 allocs/op
BenchmarkWatchHTTP-12    	   30000	     38346 ns/op	    1893 B/op	      29 allocs/op

> after
BenchmarkGet-12               	   10000	    116218 ns/op	   17456 B/op	     130 allocs/op
BenchmarkWatchHTTP-12         	   50000	     35988 ns/op	    1571 B/op	      26 allocs/op
BenchmarkWatchHTTP_UTF8-12    	   50000	     41467 ns/op	    1928 B/op	      28 allocs/op
```

Saves 3 allocations in the fast path and 1 in the slow path (the
slow path has to build the buffer and then call url.EscapedPath
which always allocates).

Kubernetes-commit: 389a8436b52db4936b56e08f07984da362c91f6b
2019-03-25 18:06:57 -04:00
Clayton Coleman 78a40897c5 Unify runtime.SerializerInfo with negotiate.AcceptedMediaTypes
There was no reason to have two types and this avoids ~10% of allocations
on the GET code path.

```
BenchmarkGet-12          	  100000	    109045 ns/op	   17608 B/op	     146 allocs/op

BenchmarkGet-12          	  100000	    108850 ns/op	   15942 B/op	     132 allocs/op
```

Kubernetes-commit: 0489d0b1cf139253b82f73b072578073bc5616d6
2019-03-21 21:00:55 -04:00
Clayton Coleman 70165311bb Avoid 3 object creations when no dryRun parameter is provided
These allocations should only occur rarely.

```
BenchmarkGet-12          	  100000	    108013 ns/op	   17732 B/op	     149 allocs/op

BenchmarkGet-12          	  100000	    109045 ns/op	   17608 B/op	     146 allocs/op
```

Kubernetes-commit: 59b4f47b225029068bf015117ada1a06d54fbd59
2019-03-21 20:57:36 -04:00
Clayton Coleman f24566b3c2 Avoid an allocation on all requests when checking for an old user agent
ReplaceAllStrings always allocates, while scanning a relatively short
regex twice is slightly more CPU immediately but less later.

```
BenchmarkGet-12          	  100000	    108824 ns/op	   17818 B/op	     152 allocs/op

BenchmarkGet-12          	  100000	    108013 ns/op	   17732 B/op	     149 allocs/op
```

Kubernetes-commit: 83c41eab1d6f55c9ccf61744bfc345c95d3a0664
2019-03-21 20:48:00 -04:00
Clayton Coleman 9006e59e3b IsListType uses reflection and is expensive for hot paths
IsListType was causing ~100 allocations for a non list object. It is
used in a wide range of code, so perform a more targeted check.

The use of `%#v` in a hot return path for `fmt.Errorf()` was the main
victim.

Replace `%#v` with a typed error and create a cache of types that are
lists with a bounded size (probably not necessary, but safer).

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

BenchmarkGet-12          	  100000	    109085 ns/op	   17831 B/op	     152 allocs/op
BenchmarkWatchHTTP-12    	  200000	     33966 ns/op	    1913 B/op	      30 allocs/op
```

Kubernetes-commit: 58fb665646aa4c1b63f1322a50e3af7a60e39886
2019-03-21 20:43:26 -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
jennybuckley aabe804197 Fix int/float apply bug
Kubernetes-commit: 10259c959e9f20668659f7e20251a217b51c6355
2019-03-11 23:07:21 -07:00
Aaron Prindle a595f8c602 Added version check between patch and live object in server side apply
What is the problem being solved?
https://github.com/kubernetes/kubernetes/pull/75135
Currently version compatibility is not being checked in server side apply between the patch object and the live object.  This is causing a merge that will error to be run and the apiserver returns a 500 error.  The request should fail if the apiVersion provided in the object is different from the apiVersion in the url, but it should fail before trying to merge, and be a 4xx error. Probably a bad request error.

Why is this the best approach?
The approach of serializing the patch byte array and then checking for version equality with the already serialized live object is the simplest and most straightforward solution.

Kubernetes-commit: d5bd17cda0c134e5ef5c03c3eac79a9ce4e18003
2019-03-07 16:52:26 -08:00
Chao Xu d99ef88606 Expose storage version hash
Kubernetes-commit: 3b618af0d435628feedf06f97bd1c69340d07d95
2019-01-14 19:31:25 -08:00
jennybuckley 2deaad0322 Fix version converter
Kubernetes-commit: f9e57744d3e760b1473cb22e655d20c254af03b6
2019-03-07 17:44:21 -08:00
Antoine Pelisse 46d98f52ff Add "fieldManager" to flag to PATCH/CREATE/UPDATE
And add a corresponding flag in kubectl (for apply), even though the
value is defaulted in kubectl with "kubectl".

The flag is required for Apply patch-type, and optional for other PATCH,
CREATE and UPDATE (in which case we fallback on the user-agent).

Kubernetes-commit: eb904d8fa89da491f400614f99458ed3f0d529fb
2019-02-16 20:16:11 -08:00
jennybuckley 638c313e5b Feature-gate the APPLY metric value
Kubernetes-commit: 6e512eb8758fb32878d7baa33daf3c49561086c0
2019-03-07 15:14:43 -08:00
jennybuckley 4a5bf1da2a use utilsets.NewString
Kubernetes-commit: 077dd28df4025c69b89e75b0f32cb0954401ec80
2019-03-07 14:20:10 -08:00
jennybuckley ac3850113b handle validation errors correctly
Kubernetes-commit: 51b75460aa356a6b07cd5d727cc3ad6c00a13f20
2019-03-06 15:57:18 -08:00
jennybuckley 7624354bd9 Track dry-run and apply in metrics
Kubernetes-commit: 4ac0116a5d826d97cc839dca55e3351ef68f2db1
2019-03-06 14:30:04 -08:00
Kevin Wiesmüller a2d254807d fix handling of nil times in managedFields sorting
Kubernetes-commit: 186761efee887cee019bc92a85b3207474b42185
2019-03-07 00:02:52 +00:00
Haowei Cai ac8e3dd3bb apiserver: make endpoint webservice builder helpers public
Kubernetes-commit: 5a971f045364ae12608b2acef1e69acef0805d18
2019-03-04 08:14:41 -08:00
jennybuckley 55fa47be3a add IsMissingVersionError
Kubernetes-commit: db0562bdbd4ffe17459025fdc10c7bf318dfbc01
2019-03-04 17:29:11 -08:00
jennybuckley 0b311f9745 Update conversion code
Kubernetes-commit: bad7599f06cde17e9b4a51087cd0a84836b29c11
2019-03-04 16:30:37 -08:00
Kevin Wiesmüller e08e8cdb33 change managedFields sort order to oldest first
Kubernetes-commit: 4394bf779800710e67beae9bddde4bb5425ce039
2019-03-05 07:45:08 +01:00
Kevin Wiesmüller 64d9391709 cleanup sort implementation
Kubernetes-commit: 081ccdc75e4646a6b619f16852adb9ce2b4c43d4
2019-03-02 12:07:19 +01:00
Kevin Wiesmüller 8f6431c490 implement sorting of managedFields
Kubernetes-commit: 9ac127408d48aa0876330c79c933d4f1cd603761
2019-03-01 12:51:01 +01:00
Kevin Wiesmüller 61f4009197 start implementing managedFields sorting
Kubernetes-commit: 822c0da84474c50ac640629e7cb9cad01904c2f0
2019-02-28 14:24:02 +01:00
danielqsj 822a44db47 convert latency in mertics name to duration
Kubernetes-commit: f7b437cae02c93a0c83a3ad6c044f43751c20346
2019-02-22 21:40:13 +08:00
Kevin Wiesmüller 485fbb474e test that managedFields get stripped recursively
Kubernetes-commit: 8a6a2883f9a38e09ae941b62c14f4e68037b2d21
2019-02-26 20:22:54 +01:00
Kevin Wiesmüller 14b16dd3e2 remove deletionTimestamp from strippedFields
Kubernetes-commit: d73dbfc8c1bdc443cf6bf2f70a7789b689815cf7
2019-02-26 20:22:30 +01:00
Kevin Wiesmüller 752a6fcdc7 add tests for new stripped fields and cleanup test
Kubernetes-commit: 89f4f9d4bfe5dd14a11e94ff13b1efa676a2d59f
2019-02-23 12:54:33 +01:00
Kevin Wiesmüller a0ddba7a54 add more fields to be stripped from managedFields
Kubernetes-commit: 78ba7fa05c4360e217af3854c5ae5ba4e823312f
2019-02-17 22:35:15 +01:00
Davanum Srinivas d0a81fb0fb Avoid using ghodss/yaml - switch to our forked repo
Change-Id: I115bc834b2b8473c3a81812a76b8433fda24a908

Kubernetes-commit: 42aba643290c19a63168513bd758822e8014a0fd
2019-02-21 18:48:28 -05:00
Kevin Wiesmüller 00e253c3da hardcode time
Kubernetes-commit: 332bb15476ed6f7ef0b55a5a3a3a735b915ccee3
2019-02-19 20:17:33 +01:00
Kevin Wiesmüller 0faeae1509 rename mocks to fakes and add nil check
Kubernetes-commit: 96d4fa7e4678430046d8fee98bc715f385242e3f
2019-02-19 19:13:49 +01:00
Kevin Wiesmüller 84fe2e0447 add fieldmanager tests for stripFields
Kubernetes-commit: 2f8e8fa3af4b8adce5562dd1a033fd37ea8244d8
2019-02-18 11:44:07 +01:00
Kenichi Omichi 538ceee47b Fix golint failures on handlers/negotiation
DefaultEndpointRestrictions is only used in the module,
so this renames it to defaultEndpointRestrictions.

Kubernetes-commit: 302ec9859113f322a32ed03673865b32ca5a130a
2019-01-18 22:06:48 +00:00
Mehdy Bohlool 87b5ac0c06 Add ObjectInterfaces to Admission and Validation
Kubernetes-commit: 513a87c7b25aa58f84fafe0dc170cee4c76e481b
2019-02-16 12:27:24 -08:00
Justin SB bf98046128 Remove executable file permission from OWNERS files
Kubernetes-commit: dd19b923b7c26420af39fcf4eedfa213b236c8d3
2019-01-03 12:18:20 -05:00
jennybuckley ddd6f48420 Make apply conflict errors more readable
Kubernetes-commit: 69b9167dcbc8eea2ca5653fa42584539920a1fd4
2019-02-12 15:16:19 -08:00
Antoine Pelisse 3afb63e414 Revert "Temporary fix for alpha features test"
Kubernetes-commit: 845e44dd207fc3793f8bab1b69665a816f966489
2019-02-12 12:25:21 -08:00
Chao Xu 3866fe78d2 Limit the number of operations in a single json patch to be 10,000
Kubernetes-commit: 5e6fc5dce8b12c5ce80e016b208a51c81a8c9ce8
2019-02-12 23:37:01 -08:00
Antoine Pelisse e23fc114aa Add server-side apply members on some apiserver OWNERS
Kubernetes-commit: 83f0653a14ab304ca3c049587e40bb33e9c55353
2019-02-08 16:10:25 -08:00
Chao Xu 4ebbf20f41 Adding a limit on the maximum bytes accepted to be decoded in a resource
write request.

Kubernetes-commit: b971b12d3cfa8887aa87957fbba92b90e3e99dc6
2019-02-06 16:58:24 -08:00
Kevin Wiesmüller fa595d7437 strip selected fields from managedFields
refactor fieldstrip and update tests

add checks and remove empty fields

shorten test and check for nil manager

fix gofmt

panic on nil manager

Kubernetes-commit: 9082cac48240ebc316015dabb466e5b24a113dc1
2019-02-03 22:22:10 +01:00
Zhenguo Niu c4e066e6be Clean up unneeded break in switch
There's no need to explicitly add break after every case, as switch
statements will break automatically.

Kubernetes-commit: 7cef40cb831e0238528fbf9fe0f8e76212da0c5e
2018-08-30 15:03:50 +08:00
Dr. Stefan Schimanski 9c9f2c012a apiserver: fix openapi extension types to be JSON
Kubernetes-commit: e67d5f2d8dbbc45d28d0fd5566747ef0df93eb6d
2019-02-07 15:34:42 +01:00
Roy Lenferink 4c9524b9fb Updated OWNERS files to include link to docs
Kubernetes-commit: b43c04452f3b563473b5c2a765d4ac18cc0ff58f
2019-01-30 20:05:00 +01:00
Ted Yu ea3640581f gofmt
Kubernetes-commit: 4f50eb49eae1e6561263ff4abc00ea956139a2ef
2019-02-05 13:58:42 -08:00
Ted Yu ac1ef9aea6 change case for error
Kubernetes-commit: 1638e6698403341122cd55df61e6fe12559b0604
2019-02-05 11:34:36 -08:00
Ted Yu cdd65830fd Misc fix for feature-serverside-apply
Kubernetes-commit: f2e59b44ad5610bb749901b505305ba16c44fad5
2019-02-05 10:29:38 -08:00
Jennifer Buckley 9955ab5084 Temporary fix for alpha suite
Kubernetes-commit: 3f947e034fe6436a2075e8eb202aeaaae46e9df5
2019-02-05 13:23:24 -08:00
Antoine Pelisse 3c768f935f Avoid closure
Kubernetes-commit: bbab0d6c5f9fe75388583772ef4f094e863f9627
2019-01-30 14:15:25 -08:00
Antoine Pelisse 91c401c45f Add object information on FieldManager failures
Kubernetes-commit: 79f3135d2ea2884d2d8115dcdd93a0b454c87b6f
2019-01-29 16:19:52 -08:00
jennybuckley f279314dc7 Minor fixes
Kubernetes-commit: 6b2e4682fe883eebcaf1c1e43cf2957dde441174
2019-02-01 11:55:18 -08:00
Antoine Pelisse d1a2d7fd8d Plugin FieldManager in CRD handler, change to API
Kubernetes-commit: b55417f429353e1109df8b3bfa2afc8dbd9f240b
2019-01-29 14:24:52 -08:00
Antoine Pelisse 337fc9ccde API Machinery, Kubectl and tests
Kubernetes-commit: 0e1d50e70fdc9ed838d75a7a1abbe5fa607d22a1
2019-01-16 21:14:42 -08:00
wojtekt 0760bae7df Adjust buckets in apiserver request latency metrics
Kubernetes-commit: d0508c7e872f60826d68c58c458cfd865554b486
2019-02-01 15:59:09 +01:00
Andrew Kim 2b43930b32 replace k8s.io/apiserver/pkg/util/trace with k8s.io/utils/trace
Kubernetes-commit: 93b086f6eafc1e94214fc1d946a1917482751cf3
2019-01-24 11:50:30 -05: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
Davanum Srinivas a6f07cccd1 Switch location for goautoneg vendored code
Move to github.com/munnerz/goautoneg as bitbucket is flaky!

Change-Id: Iaa6e964ef0d6f308eea59bcc6f365ecd7dbf0784

Kubernetes-commit: 16fd72d6c91ba466a0e955a1d59a6c8d9e8791bc
2018-12-17 20:39:56 -05:00
danielqsj da40ddb2dd Move etcd latency metrics to histogram and update test case
Kubernetes-commit: 8b418631c08cf66ee57c9ec31fe95372a0a3e075
2019-01-02 13:50:02 +08:00
danielqsj e0406b8675 Change endpoints metrics to conform guideline
Kubernetes-commit: 88c4b644005c5f674e9d03abae7e1cccda4fd23e
2018-12-26 22:29:13 +08:00
Jordan Liggitt 8a453581d7 Fix nil panic propagation
Kubernetes-commit: b8c64e30d18d3ea41de703d369e2a97063bce08f
2019-01-12 11:11:47 -05:00
Davanum Srinivas 5bbdd5d7c3 Strengthen ErrorToAPIStatus against bad input
Change-Id: Id44a59f56c074901257760ff4e40ce29820c6c50

Kubernetes-commit: 6858a24835721cae6968ad85cdf4985afaa03923
2019-01-04 11:22:46 -05:00
Jordan Liggitt 5e146b0a14 Flush headers before streaming logs
Kubernetes-commit: 93625f502676f7a89474cdd3d588354a8ffabb78
2019-01-04 10:16:40 -05:00
Md. Emruz Hossain 5c0ad5c6cf Fix a typo
Kubernetes-commit: 83ff55ccc39ecc1adadd96486d5c1a5c02466e33
2018-12-31 12:28:33 +06:00
Yang Li b6d1828116 Fix unreachable code
Kubernetes-commit: 267425667f45f37b0fb70a6e6904efb995cb4924
2018-11-18 04:16:25 +08:00
Clayton Coleman a229479a54 Better organize object conversion in response handling
Prepare to support watch by cleaning up the conversion method and
splitting out each transition into a smaller method.

Kubernetes-commit: 63c49ba55a8da571522a9615dfa64471c5e9041e
2018-11-28 22:01:47 -05:00
Clayton Coleman 065e089126 Ensure all response object modification happens in one place
Make setLink and setListLink the same, and make them happen in transformResponseObject.
Make those methods also responsible for ensuring an empty list. Then move outputMediaType
negotiation before all other calls in the specific methods, to ensure we fail fast.

Refactoring in preparation to support type conversion on watch.

Kubernetes-commit: 56a25d8c5f04ec5401b99c8eb29e980b1e8123d3
2018-11-28 21:32:51 -05:00
Dr. Stefan Schimanski b4ca200ede apiserver: add component label to request metrics
Kubernetes-commit: 7190b17e5a52a7c0673c2e8a30cbe95f2847a6df
2018-11-29 16:30:15 +01:00
Dr. Stefan Schimanski 0f8de8e61f apiserver: add group+version to request metrics
Kubernetes-commit: ff6e028755163ef52ad135da9f5d800c5749632c
2018-11-29 16:03:37 +01:00
Daniel Kłobuszewski 877329b0f3 Add option to k8s apiserver to reject incoming requests upon audit failure
Kubernetes-commit: 7a10f4eda725f55bec9893eb1c03f2402dbcd32f
2018-07-03 14:40:55 +02:00
Jordan Liggitt 67a9161222 apiserver: propagate panics from REST handlers correctly
Kubernetes-commit: 0952c9ee9692dea46b7e1456f984bafa5cdb56ed
2018-11-15 10:07:49 -05:00
jennybuckley 7cc3f112fb Build OpenAPI Definitions per group instead of per resource
Kubernetes-commit: 758e8623e9b08065f053bedf4474626696b6346c
2018-11-14 12:50:02 -08:00
Davanum Srinivas 2710b17b80 Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
2018-11-09 13:49:10 -05:00
Patrick Barker ee71388a42 updates audit endpoints test
Kubernetes-commit: 5a84453e4eaab610e2af5346b948091a409327e2
2018-11-01 15:56:50 -06:00
Mike Danese 1692373df9 move audience context functions to authenticator package
Kubernetes-commit: 817cf70191b73d1ee9f4e7af83089e5854e5131d
2018-10-31 14:50:11 -07:00
Neha Yadav 3e6dd50d69 fix(bug): make body a optional parameter in [DELETE] /apis/batch/v1/namespaces/{namespace}/jobs/{name}
Kubernetes-commit: 31372f16129b3f6fa50e85e175643b3a43ba3da2
2018-10-27 00:40:10 +05:30
Samuel Davidson d8ee4bc0cb Revert "limit forbidden error to details of what was forbidden"
This reverts commit ecbd0137957b4afd4cdd94c0209998228fd70e99.

Kubernetes-commit: 294e02ed4b341fe9497cdfadb93cf19f1e64243f
2018-10-26 15:58:09 -07:00
Walter Fender 4749d14e11 Added tracing for long running requests.
Added tracing for use cases where etcd is not the cause of long running
requests.
Fixed spelling.
Factored in Wojtek-t feedback.

Kubernetes-commit: 99ebe8747176a10c718d5e3276c64d8c507bfb3b
2018-10-12 17:36:36 -07:00
Clayton Coleman 4e305103fd Dynamic client watchers should be able to handle ERROR gracefully
Watch can return type "ERROR" and a metav1.Status object. We need to
handle that during wait, and make it easy to handle the status object.

Kubernetes-commit: 5a8afa073f6b8cbb8b09f997f6db747c39dffb6e
2018-10-03 14:16:44 -04:00
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
Ibrahim AshShohail 47845b88c3 Update usages of http.ResponseWriter.WriteHeader to use http.Error
Signed-off-by: Ibrahim AshShohail <me@ibrasho.com>

Kubernetes-commit: 2fb3ba71f196031e9b36095d64c921cacc54f44e
2018-10-08 22:20:52 +03:00
Mike Danese 2ced48ac6e rebase authenticators onto new interface.
Kubernetes-commit: e5227216c0796d725c695e36cfc1d54e7631d3a6
2018-10-15 15:17:36 -07:00
xichengliudui 21f232e065 Remove duplicate words
Kubernetes-commit: e39448237370df37d2f77bf98cf951a19b1e5b6c
2018-10-15 15:55:49 -04:00
Mike Danese 37ab80320b tokenreview: add APIAudiences config to generic API server and augment context
Kubernetes-commit: 21fd8f204128a7847786927b460d95be34a6dbde
2018-10-09 22:04:52 -07: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
Zhenguo Niu 277a076fa4 Remove unnecessary concatenation of strings
Remove unnecessary concatenation of strings "/{" + "namespace" + "}/"

Kubernetes-commit: 70fd811f84cdb7f435153a69612d495fe617162e
2018-08-30 20:11:59 +08:00
Haowei Cai 56ca9f4a1c Add Create and Update Options to rest param installation
Kubernetes-commit: e0162b9105080f9472c1cbbab82a90b6ac2baebc
2018-10-02 17:21:07 -07: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
Marian Lobur 7dbcbd39e2 Remove deprecated legacy audit logging code.
Kubernetes-commit: 3f730d4c255e7c8ee67a020eed0b8f0a8f634750
2018-07-05 13:57:17 +02: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
Jordan Liggitt 3dc9519ac3 limit forbidden error to details of what was forbidden
Kubernetes-commit: ecbd0137957b4afd4cdd94c0209998228fd70e99
2018-08-20 15:36:39 -04: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
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
yue9944882 d7eae80a4e cleaning up
Kubernetes-commit: a6b781935eb833144c3459f791a3a12cfebc66ee
2018-07-24 15:04:28 +08: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
Jordan Liggitt 520d366673 document /watch prefix deprecation
Kubernetes-commit: c31faf2509e7431948a08c9b474858b753188781
2018-06-15 11:21:56 -04:00
jennybuckley 4dcfdb8ab8 Explicitly disable dry run for connect
Kubernetes-commit: 702937ac8614a05d3168c6565bea8a3347883dc0
2018-07-11 11:45:24 -07:00
jennybuckley 1232b1c9c4 Skip building openapi for ignored paths
Kubernetes-commit: 37c10e2e05b31fd65ca865744d745f60fea7d0c3
2018-07-24 16:11:42 -07:00
jennybuckley 91278157f6 Support dry run in admission plugins
Kubernetes-commit: adafb1365e2b9f6c422c437e916e22a4fe1c2e3a
2018-08-06 10:37:44 -07:00
David Eads cb5cac48ee make package name match all the import aliases
Kubernetes-commit: d3bd0eb1d5cefc25e4476d8dc086ebd90439ef4e
2018-08-01 10:01:32 -04:00
Jake Sanders 41bff9cd5e Escape illegal characters in remote extra keys
Signed-off-by: Jake Sanders <jsand@google.com>

Kubernetes-commit: f35e3d07c9898f8ec156209a868fa4451eb9afe2
2018-07-03 21:19:15 -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
Haowei Cai f67bbdae95 Add Accepted to delete response path
Kubernetes-commit: b4b84e023bec4639d9d618cd987f1ee71939f70f
2018-05-03 18:00:51 -07: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
Cong Ding 5081ebb434 cleanup: remove deadcode
Kubernetes-commit: 3bacb04a5f9805bb83e016e341a49d0f13a43598
2018-06-22 16:39:13 -07:00
xuzhonghu 6fc16b5a67 transform ConnectMethods to kube verbs
Kubernetes-commit: 8c820ae303b253cde5d690eac5eec05a0e707c27
2018-06-27 11:14:36 +08:00
wojtekt 7ff366ebcb Fix apiserver metrics
Kubernetes-commit: 3d9552cc388d66851a687cf50a93a6e2c9166c35
2018-06-29 14:15:53 +02: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
xuzhonghu 137aab858e add ut for audit useragent
Kubernetes-commit: a8b0ccc70c1848ac15d32622e33de1da5c6821f9
2018-06-08 17:06:39 +08:00