Skip to content

Omit managed fields from cached Kubernetes objects #4225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/postgres-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"

Expand Down Expand Up @@ -67,6 +68,7 @@ func initManager(ctx context.Context) (runtime.Options, error) {
log := logging.FromContext(ctx)

options := runtime.Options{}
options.Cache.DefaultTransform = cache.TransformStripManagedFields()
options.Cache.SyncPeriod = initialize.Pointer(time.Hour)

// If we aren't using it, http/2 should be disabled
Expand Down
2 changes: 2 additions & 0 deletions cmd/postgres-operator/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestInitManager(t *testing.T) {
options, err := initManager(ctx)
assert.NilError(t, err)

assert.Assert(t, options.Cache.DefaultTransform != nil)
if assert.Check(t, options.Cache.SyncPeriod != nil) {
assert.Equal(t, *options.Cache.SyncPeriod, time.Hour)
}
Expand All @@ -42,6 +43,7 @@ func TestInitManager(t *testing.T) {

{
options.Cache.SyncPeriod = nil
options.Cache.DefaultTransform = nil
options.Controller.GroupKindConcurrency = nil
options.HealthProbeBindAddress = ""
options.Metrics.TLSOpts = nil
Expand Down
Loading