From afca21c7863c19b8641ed39a8a08a261c9a01ad9 Mon Sep 17 00:00:00 2001 From: Homayoon Alimohammadi Date: Mon, 12 Aug 2024 19:50:48 +0400 Subject: [PATCH] Update feature status on failed apply (#601) Update feature status on failed apply --- src/k8s/pkg/k8sd/controllers/feature.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/k8s/pkg/k8sd/controllers/feature.go b/src/k8s/pkg/k8sd/controllers/feature.go index 04e50cb6b..35dbd9255 100644 --- a/src/k8s/pkg/k8sd/controllers/feature.go +++ b/src/k8s/pkg/k8sd/controllers/feature.go @@ -131,10 +131,14 @@ func (c *FeatureController) reconcile( return fmt.Errorf("failed to retrieve cluster configuration: %w", err) } - if featureStatus, err := apply(cfg); err != nil { - return fmt.Errorf("failed to apply configuration: %w", err) - } else if err := updateFeatureStatus(ctx, featureStatus); err != nil { - return fmt.Errorf("failed to update feature status: %w", err) + status, applyErr := apply(cfg) + if err := updateFeatureStatus(ctx, status); err != nil { + // NOTE (hue): status update errors are not returned but only logged. we might need some retry logic in the future. + log.FromContext(ctx).WithValues("message", status.Message, "applied-successfully", applyErr == nil).Error(err, "Failed to update feature status") + } + + if applyErr != nil { + return fmt.Errorf("failed to apply configuration: %w", applyErr) } return nil