|
1 | 1 | package operator
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "context" |
4 | 5 | "fmt"
|
5 | 6 | "strings"
|
6 | 7 | "time"
|
7 | 8 |
|
| 9 | + operatorv1 "github.com/openshift/api/operator/v1" |
8 | 10 | "k8s.io/apimachinery/pkg/api/errors"
|
9 | 11 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
10 | 12 | utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
@@ -201,6 +203,33 @@ func (c *AzurePathFixController) sync() error {
|
201 | 203 | // this job is no longer needed. on OCP versions >=4.17 we can be certain that
|
202 | 204 | // this has already migrated the blobs to the correct place, and we can now
|
203 | 205 | // 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 | + |
204 | 233 | _, err = gen.Get()
|
205 | 234 | if errors.IsNotFound(err) {
|
206 | 235 | return nil
|
|
0 commit comments