diff --git a/pkg/operator/starter.go b/pkg/operator/starter.go index 890fbfc41..c68f7784c 100644 --- a/pkg/operator/starter.go +++ b/pkg/operator/starter.go @@ -18,6 +18,7 @@ import ( "github.com/openshift/library-go/pkg/controller/controllercmd" "github.com/openshift/library-go/pkg/operator/genericoperatorclient" "github.com/openshift/library-go/pkg/operator/resource/resourceapply" + "github.com/openshift/library-go/pkg/operator/staleconditions" "github.com/openshift/library-go/pkg/operator/staticpod" "github.com/openshift/library-go/pkg/operator/staticpod/controller/revision" "github.com/openshift/library-go/pkg/operator/staticresourcecontroller" @@ -223,11 +224,21 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle controllerContext.EventRecorder, ) + staleConditions := staleconditions.NewRemoveStaleConditionsController( + []string{ + // IP migrator was removed in 4.5, however older clusters can still have this condition set and it might prevent upgrades + "EtcdMemberIPMigratorDegraded", + }, + operatorClient, + controllerContext.EventRecorder, + ) + operatorInformers.Start(ctx.Done()) kubeInformersForNamespaces.Start(ctx.Done()) configInformers.Start(ctx.Done()) dynamicInformers.Start(ctx.Done()) + go staleConditions.Run(ctx, 1) go fsyncMetricController.Run(ctx, 1) go staticResourceController.Run(ctx, 1) go targetConfigReconciler.Run(ctx, 1) diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staleconditions/remove_stale_conditions.go b/vendor/github.com/openshift/library-go/pkg/operator/staleconditions/remove_stale_conditions.go new file mode 100644 index 000000000..fdaf6cef3 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staleconditions/remove_stale_conditions.go @@ -0,0 +1,44 @@ +package staleconditions + +import ( + "context" + "time" + + operatorv1 "github.com/openshift/api/operator/v1" + + "github.com/openshift/library-go/pkg/controller/factory" + "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/v1helpers" +) + +type RemoveStaleConditionsController struct { + conditions []string + operatorClient v1helpers.OperatorClient +} + +func NewRemoveStaleConditionsController( + conditions []string, + operatorClient v1helpers.OperatorClient, + eventRecorder events.Recorder, +) factory.Controller { + c := &RemoveStaleConditionsController{ + conditions: conditions, + operatorClient: operatorClient, + } + return factory.New().ResyncEvery(time.Second).WithSync(c.sync).WithInformers(operatorClient.Informer()).ToController("RemoveStaleConditionsController", eventRecorder.WithComponentSuffix("remove-stale-conditions")) +} + +func (c RemoveStaleConditionsController) sync(ctx context.Context, syncContext factory.SyncContext) error { + removeStaleConditionsFn := func(status *operatorv1.OperatorStatus) error { + for _, condition := range c.conditions { + v1helpers.RemoveOperatorCondition(&status.Conditions, condition) + } + return nil + } + + if _, _, err := v1helpers.UpdateStatus(c.operatorClient, removeStaleConditionsFn); err != nil { + return err + } + + return nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index cd020f6a7..009c044e7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -214,6 +214,7 @@ github.com/openshift/library-go/pkg/operator/resource/resourceread github.com/openshift/library-go/pkg/operator/resource/retry github.com/openshift/library-go/pkg/operator/resourcesynccontroller github.com/openshift/library-go/pkg/operator/revisioncontroller +github.com/openshift/library-go/pkg/operator/staleconditions github.com/openshift/library-go/pkg/operator/staticpod github.com/openshift/library-go/pkg/operator/staticpod/certsyncpod github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource