Skip to content

Commit 527120f

Browse files
committed
pkg/operator: remove azure path fix controller conditions
the previous commit removes the job when present. this commit also makes sure there are no conditions related to the job present in the operator status.
1 parent 118b393 commit 527120f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

pkg/operator/azurepathfixcontroller.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package operator
22

33
import (
4+
"context"
45
"fmt"
56
"strings"
67
"time"
78

9+
operatorv1 "github.com/openshift/api/operator/v1"
810
"k8s.io/apimachinery/pkg/api/errors"
911
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1012
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -201,6 +203,33 @@ func (c *AzurePathFixController) sync() error {
201203
// this job is no longer needed. on OCP versions >=4.17 we can be certain that
202204
// this has already migrated the blobs to the correct place, and we can now
203205
// safely remove the job. see OCPBUGS-29003 for details.
206+
progressing := "AzurePathFixProgressing"
207+
degraded := "AzurePathFixControllerDegraded"
208+
removeConditionFn := func(conditionType string) v1helpers.UpdateStatusFunc {
209+
return func(oldStatus *operatorv1.OperatorStatus) error {
210+
v1helpers.RemoveOperatorCondition(&oldStatus.Conditions, conditionType)
211+
return nil
212+
}
213+
}
214+
removeConditionFns := []v1helpers.UpdateStatusFunc{}
215+
progressingConditionFound := v1helpers.FindOperatorCondition(imageRegistryConfig.Status.Conditions, progressing) != nil
216+
if progressingConditionFound {
217+
removeConditionFns = append(removeConditionFns, removeConditionFn(progressing))
218+
}
219+
degradedConditionFound := v1helpers.FindOperatorCondition(imageRegistryConfig.Status.Conditions, degraded) != nil
220+
if degradedConditionFound {
221+
removeConditionFns = append(removeConditionFns, removeConditionFn(degraded))
222+
}
223+
if len(removeConditionFns) > 0 {
224+
if _, _, err := v1helpers.UpdateStatus(
225+
context.TODO(),
226+
c.operatorClient,
227+
removeConditionFns...,
228+
); err != nil {
229+
return err
230+
}
231+
}
232+
204233
_, err = gen.Get()
205234
if errors.IsNotFound(err) {
206235
return nil

0 commit comments

Comments
 (0)