From 1deceef3a0ca12a7bbd094cc3382ca235e8cd922 Mon Sep 17 00:00:00 2001 From: Daniel Rammer Date: Tue, 19 Oct 2021 13:46:45 -0500 Subject: [PATCH] replacing managed fields with a list of one empty instance to clear crd managed fields Signed-off-by: Daniel Rammer --- .../workflowstore/resource_version_caching.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/controller/workflowstore/resource_version_caching.go b/pkg/controller/workflowstore/resource_version_caching.go index 141dc0bb6..eccb28055 100644 --- a/pkg/controller/workflowstore/resource_version_caching.go +++ b/pkg/controller/workflowstore/resource_version_caching.go @@ -9,6 +9,8 @@ import ( "github.com/flyteorg/flytepropeller/pkg/apis/flyteworkflow/v1alpha1" "github.com/flyteorg/flytestdlib/promutils" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // TODO - optimization maybe? we can move this to predicate check, before we add it to the queue? @@ -94,6 +96,14 @@ func (r *resourceVersionCaching) UpdateStatus(ctx context.Context, workflow *v1a func (r *resourceVersionCaching) Update(ctx context.Context, workflow *v1alpha1.FlyteWorkflow, priorityClass PriorityClass) ( newWF *v1alpha1.FlyteWorkflow, err error) { + // If the workflow has any managed fields setting the array to one empty ManagedField clears them in the CRD. + // FlyteWorkflow CRDs are only managed by a single FlytePropeller instance and therefore the managed fields paradigm + // does not add useful functionality. Clearing them reduces CRD size, improving etcd I/O performance. + if len(workflow.ObjectMeta.ManagedFields) > 0 { + workflow.ObjectMeta.ManagedFields = workflow.ObjectMeta.ManagedFields[:1] + workflow.ObjectMeta.ManagedFields[0] = metav1.ManagedFieldsEntry{} + } + newWF, err = r.w.Update(ctx, workflow, priorityClass) if err != nil { return nil, err