From c3dd5880a9084927f3987738b3b33a4b669fe09c Mon Sep 17 00:00:00 2001 From: Daniel Shuy Date: Thu, 20 Oct 2022 17:52:22 +0800 Subject: [PATCH] Move logic to clear workflow CRD managed fields to passthrough workflowstore --- pkg/controller/workflowstore/passthrough.go | 8 ++++++++ pkg/controller/workflowstore/resource_version_caching.go | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/controller/workflowstore/passthrough.go b/pkg/controller/workflowstore/passthrough.go index 8e5b03f60..7ff565ea9 100644 --- a/pkg/controller/workflowstore/passthrough.go +++ b/pkg/controller/workflowstore/passthrough.go @@ -76,6 +76,14 @@ func (p *passthroughWorkflowStore) UpdateStatus(ctx context.Context, workflow *v func (p *passthroughWorkflowStore) 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] = v1.ManagedFieldsEntry{} + } + p.metrics.workflowUpdateCount.Inc() // Something has changed. Lets save logger.Debugf(ctx, "Observed FlyteWorkflow Update (maybe finalizer)") diff --git a/pkg/controller/workflowstore/resource_version_caching.go b/pkg/controller/workflowstore/resource_version_caching.go index 5486437aa..758431e7e 100644 --- a/pkg/controller/workflowstore/resource_version_caching.go +++ b/pkg/controller/workflowstore/resource_version_caching.go @@ -109,14 +109,6 @@ 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