Skip to content

Commit

Permalink
Merge pull request #4831 from timebertt/promote/cachedruntimeclients
Browse files Browse the repository at this point in the history
Promote CachedRuntimeClients feature gate to beta
  • Loading branch information
timebertt committed Oct 14, 2021
2 parents 69f56d7 + 1a4cecd commit 424290b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion docs/deployment/feature_gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ The following tables are a summary of the feature gates that you can set on diff
| ManagedIstio | `true` | `Beta` | `1.19` | |
| APIServerSNI | `false` | `Alpha` | `1.7` | `1.18` |
| APIServerSNI | `true` | `Beta` | `1.19` | |
| CachedRuntimeClients | `false` | `Alpha` | `1.7` | |
| CachedRuntimeClients | `false` | `Alpha` | `1.7` | `1.33` |
| CachedRuntimeClients | `true` | `Beta` | `1.34` | |
| SeedChange | `false` | `Alpha` | `1.12` | |
| SeedKubeScheduler | `false` | `Alpha` | `1.15` | |
| ReversedVPN | `false` | `Alpha` | `1.22` | |
Expand Down
9 changes: 5 additions & 4 deletions docs/development/kubernetes-clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ This means, that if you read the same object from different cache implementation
By default, the `client.Client` created by a controller-runtime `Manager` is a `DelegatingClient`. It delegates `Get` and `List` calls to a `Cache` and all other calls to a client, that talks directly to the API server. Exceptions are requests with `*unstructured.Unstructured` objects and object kinds that were configured to be excluded from the cache in the `DelegatingClient`.

> ℹ️ Currently, the controller-runtime client contained in Gardener's client collection (`kubernetes.Interface.Client()`) is not cached and does not use the cache contained in the client set (`kubernetes.Interface.Cache()`). This means, the client always reads directly from the API server, but you can intentionally read from the cache if desired.
>
> If the `CachedRuntimeClients` feature gate is enabled, `Client()` returns a `DelegatingClient` that uses the cache returned from `Cache()` under the hood. This means, all `Client()` usages should be ready for cached clients and should be able to cater with stale cache reads.
> See [gardener/gardener#2822](https://github.com/gardener/gardener/issues/2822) for details on the graduation progress.
> ℹ️
> If the `CachedRuntimeClients` feature gate is enabled (enabled by default starting from `v1.34`), `kubernetes.Interface.Client()` returns a `DelegatingClient` that uses the cache returned from `kubernetes.Interface.Cache()` under the hood. This means, all `Client()` usages need to be ready for cached clients and should be able to cater with stale cache reads.
> See [gardener/gardener#2822](https://github.com/gardener/gardener/issues/2822) for details on the graduation progress to beta.
>
> If the feature gate is explicitly disabled, the controller-runtime client (`kubernetes.Interface.Client()`) is not cached and does not use the cache contained in the client set (`kubernetes.Interface.Cache()`). This means, the client always reads directly from the API server, but you can intentionally read from the cache if desired.
_Important characteristics of cached controller-runtime clients:_

Expand Down
7 changes: 4 additions & 3 deletions pkg/client/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ import (
)

var (
// UseCachedRuntimeClients is a flag for enabling cached controller-runtime clients (defaults to false).
// If enabled, the client returned by Interface.Client() will be backed by a cache, otherwise it will talk directly
// to the API server.
// UseCachedRuntimeClients is a flag for enabling cached controller-runtime clients. The CachedRuntimeClients feature
// gate (enabled by default sinde v1.34) causes this flag to be set to true.
// If enabled, the client returned by Interface.Client() will be backed by Interface.Cache(), otherwise it will talk
// directly to the API server.
UseCachedRuntimeClients = false
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controllermanager/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
// FeatureGate is a shared global FeatureGate for Gardener Controller Manager flags.
FeatureGate = featuregate.NewFeatureGate()
featureGates = map[featuregate.Feature]featuregate.FeatureSpec{
features.CachedRuntimeClients: {Default: false, PreRelease: featuregate.Alpha},
features.CachedRuntimeClients: {Default: true, PreRelease: featuregate.Beta},
features.UseDNSRecords: {Default: false, PreRelease: featuregate.Alpha},
features.RotateSSHKeypairOnMaintenance: {Default: false, PreRelease: featuregate.Alpha},
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ const (

// CachedRuntimeClients enables a cache in the controller-runtime clients, that Gardener uses.
// If disabled all controller-runtime clients will directly talk to the API server instead of relying on a cache.
// owner @tim-ebert
// owner @timebertt
// alpha: v1.7.0
// beta: v1.34.0
CachedRuntimeClients featuregate.Feature = "CachedRuntimeClients"

// SeedChange enables updating the `spec.seedName` field during shoot validation from a non-empty value
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
features.HVPAForShootedSeed: {Default: false, PreRelease: featuregate.Alpha},
features.ManagedIstio: {Default: true, PreRelease: featuregate.Beta},
features.APIServerSNI: {Default: true, PreRelease: featuregate.Beta},
features.CachedRuntimeClients: {Default: false, PreRelease: featuregate.Alpha},
features.CachedRuntimeClients: {Default: true, PreRelease: featuregate.Beta},
features.SeedKubeScheduler: {Default: false, PreRelease: featuregate.Alpha},
features.ReversedVPN: {Default: false, PreRelease: featuregate.Alpha},
features.UseDNSRecords: {Default: false, PreRelease: featuregate.Alpha},
Expand Down

0 comments on commit 424290b

Please sign in to comment.