diff --git a/internal/controller/funcs.go b/internal/controller/funcs.go index a0431b8b..c5e38de6 100644 --- a/internal/controller/funcs.go +++ b/internal/controller/funcs.go @@ -18,7 +18,6 @@ package controller import ( "context" - "encoding/json" "fmt" "math/rand" "strconv" @@ -110,7 +109,14 @@ func RemoveOLSConfig( return false, err } - return true, nil + _, err = GetOLSConfig(ctx, helper) + if err != nil && k8s_errors.IsNotFound(err) { + return true, nil + } else if err != nil { + return false, err + } + + return false, nil } // GetOLSConfig returns OLSConfig if there is one present in the cluster. @@ -267,36 +273,20 @@ func PatchOLSConfig( return nil } -// IsOLSConfigReady returns true if required conditions are true for OLSConfig +// IsOLSConfigReady returns true if OLSConfig's overallStatus is Ready func IsOLSConfigReady(ctx context.Context, helper *common_helper.Helper) (bool, error) { olsConfig, err := GetOLSConfig(ctx, helper) if err != nil { return false, err } - olsConfigStatusList, found, err := uns.NestedSlice(olsConfig.Object, "status", "conditions") - if !found { - return false, err - } - - jsonData, err := json.Marshal(olsConfigStatusList) - if err != nil { - return false, fmt.Errorf("failed to marshal OLSConfig status: %w", err) - } - - var OLSConfigConditions []metav1.Condition - err = json.Unmarshal(jsonData, &OLSConfigConditions) + overallStatus, found, err := uns.NestedString(olsConfig.Object, "status", "overallStatus") if err != nil { - return false, fmt.Errorf("failed to unmarshal JSON containing condition.Conditions: %w", err) + return false, err } - requiredConditionTypes := []string{"ConsolePluginReady", "CacheReady", "ApiReady", "Reconciled"} - for _, OLSConfigCondition := range OLSConfigConditions { - for _, requiredConditionType := range requiredConditionTypes { - if OLSConfigCondition.Type == requiredConditionType && OLSConfigCondition.Status != metav1.ConditionTrue { - return false, OLSConfigPing(ctx, helper) - } - } + if !found || overallStatus != "Ready" { + return false, OLSConfigPing(ctx, helper) } return true, nil diff --git a/test/kuttl/common/openstack-lightspeed-instance/assert-openstack-lightspeed-instance.yaml b/test/kuttl/common/openstack-lightspeed-instance/assert-openstack-lightspeed-instance.yaml index e57cefb6..a0eee232 100644 --- a/test/kuttl/common/openstack-lightspeed-instance/assert-openstack-lightspeed-instance.yaml +++ b/test/kuttl/common/openstack-lightspeed-instance/assert-openstack-lightspeed-instance.yaml @@ -96,9 +96,7 @@ status: - type: ApiReady status: "True" reason: Available - - type: Reconciled - status: "True" - reason: Available + overallStatus: Ready --- apiVersion: lightspeed.openstack.org/v1beta1 kind: OpenStackLightspeed