mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 10:53:34 +00:00
rebase: bump sigs.k8s.io/controller-runtime
Bumps the k8s-dependencies group with 1 update in the / directory: [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime). Updates `sigs.k8s.io/controller-runtime` from 0.17.3 to 0.18.2 - [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases) - [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.17.3...v0.18.2) --- updated-dependencies: - dependency-name: sigs.k8s.io/controller-runtime dependency-type: direct:production update-type: version-update:semver-minor dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
mergify[bot]
parent
c8af2b638a
commit
c1ee11261e
50
vendor/sigs.k8s.io/controller-runtime/pkg/cache/cache.go
generated
vendored
50
vendor/sigs.k8s.io/controller-runtime/pkg/cache/cache.go
generated
vendored
@ -39,11 +39,9 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/cache/internal"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
|
||||
logf "sigs.k8s.io/controller-runtime/pkg/internal/log"
|
||||
)
|
||||
|
||||
var (
|
||||
log = logf.RuntimeLog.WithName("object-cache")
|
||||
defaultSyncPeriod = 10 * time.Hour
|
||||
)
|
||||
|
||||
@ -203,6 +201,9 @@ type Options struct {
|
||||
|
||||
// DefaultTransform will be used as transform for all object types
|
||||
// unless there is already one set in ByObject or DefaultNamespaces.
|
||||
//
|
||||
// A typical usecase for this is to use TransformStripManagedFields
|
||||
// to reduce the caches memory usage.
|
||||
DefaultTransform toolscache.TransformFunc
|
||||
|
||||
// DefaultWatchErrorHandler will be used to the WatchErrorHandler which is called
|
||||
@ -222,7 +223,7 @@ type Options struct {
|
||||
DefaultUnsafeDisableDeepCopy *bool
|
||||
|
||||
// ByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object.
|
||||
// object, this will fall through to Default* settings.
|
||||
// If unset, this will fall through to the Default* settings.
|
||||
ByObject map[client.Object]ByObject
|
||||
|
||||
// newInformer allows overriding of NewSharedIndexInformer for testing.
|
||||
@ -346,6 +347,20 @@ func New(cfg *rest.Config, opts Options) (Cache, error) {
|
||||
return delegating, nil
|
||||
}
|
||||
|
||||
// TransformStripManagedFields strips the managed fields of an object before it is committed to the cache.
|
||||
// If you are not explicitly accessing managedFields from your code, setting this as `DefaultTransform`
|
||||
// on the cache can lead to a significant reduction in memory usage.
|
||||
func TransformStripManagedFields() toolscache.TransformFunc {
|
||||
return func(in any) (any, error) {
|
||||
// Nilcheck managed fields to avoid hitting https://github.com/kubernetes/kubernetes/issues/124337
|
||||
if obj, err := meta.Accessor(in); err == nil && obj.GetManagedFields() != nil {
|
||||
obj.SetManagedFields(nil)
|
||||
}
|
||||
|
||||
return in, nil
|
||||
}
|
||||
}
|
||||
|
||||
func optionDefaultsToConfig(opts *Options) Config {
|
||||
return Config{
|
||||
LabelSelector: opts.DefaultLabelSelector,
|
||||
@ -419,19 +434,6 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
|
||||
}
|
||||
}
|
||||
|
||||
for namespace, cfg := range opts.DefaultNamespaces {
|
||||
cfg = defaultConfig(cfg, optionDefaultsToConfig(&opts))
|
||||
if namespace == metav1.NamespaceAll {
|
||||
cfg.FieldSelector = fields.AndSelectors(
|
||||
appendIfNotNil(
|
||||
namespaceAllSelector(maps.Keys(opts.DefaultNamespaces)),
|
||||
cfg.FieldSelector,
|
||||
)...,
|
||||
)
|
||||
}
|
||||
opts.DefaultNamespaces[namespace] = cfg
|
||||
}
|
||||
|
||||
for obj, byObject := range opts.ByObject {
|
||||
isNamespaced, err := apiutil.IsObjectNamespaced(obj, opts.Scheme, opts.Mapper)
|
||||
if err != nil {
|
||||
@ -485,6 +487,22 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
|
||||
opts.ByObject[obj] = byObject
|
||||
}
|
||||
|
||||
// Default namespaces after byObject has been defaulted, otherwise a namespace without selectors
|
||||
// will get the `Default` selectors, then get copied to byObject and then not get defaulted from
|
||||
// byObject, as it already has selectors.
|
||||
for namespace, cfg := range opts.DefaultNamespaces {
|
||||
cfg = defaultConfig(cfg, optionDefaultsToConfig(&opts))
|
||||
if namespace == metav1.NamespaceAll {
|
||||
cfg.FieldSelector = fields.AndSelectors(
|
||||
appendIfNotNil(
|
||||
namespaceAllSelector(maps.Keys(opts.DefaultNamespaces)),
|
||||
cfg.FieldSelector,
|
||||
)...,
|
||||
)
|
||||
}
|
||||
opts.DefaultNamespaces[namespace] = cfg
|
||||
}
|
||||
|
||||
// Default the resync period to 10 hours if unset
|
||||
if opts.SyncPeriod == nil {
|
||||
opts.SyncPeriod = &defaultSyncPeriod
|
||||
|
Reference in New Issue
Block a user