From 90839ad73b9ec40d693da6c4e859680bb03eafc6 Mon Sep 17 00:00:00 2001 From: Rokibul Hasan Date: Wed, 13 Mar 2024 11:24:51 +0600 Subject: [PATCH] Check only the readiness of kube-ui-server for cluster status. (#291) Signed-off-by: Rokibul Hasan --- pkg/registry/meta/clusterstatus/status.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pkg/registry/meta/clusterstatus/status.go b/pkg/registry/meta/clusterstatus/status.go index 1b9dacaa6..f2e05251e 100644 --- a/pkg/registry/meta/clusterstatus/status.go +++ b/pkg/registry/meta/clusterstatus/status.go @@ -21,6 +21,7 @@ import ( "gomodules.xyz/pointer" "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/types" clustermeta "kmodules.xyz/client-go/cluster" rsapi "kmodules.xyz/resource-metadata/apis/meta/v1alpha1" uiapi "kmodules.xyz/resource-metadata/apis/ui/v1alpha1" @@ -29,7 +30,7 @@ import ( const ( MessageFluxCDMissing = "FluxCD is not installed or not ready. Please, reconnect to install/update the component." - MessageRequiredComponentsMissing = "One or more core components are not ready. Please, reconnect to update the components." + MessageRequiredComponentsMissing = "Kube-ui-server is not ready. Please, reconnect to update the components." ) func generateClusterStatusResponse(kc client.Client, mapper meta.RESTMapper) *rsapi.ClusterStatusResponse { @@ -75,7 +76,7 @@ func checkClusterReadiness(kc client.Client) (bool, string, error) { return false, MessageFluxCDMissing, nil } - ready, err = areRequiredFeatureSetsReady(kc) + ready, err = isKubeUiServerReady(kc) if err != nil { return false, "", err } @@ -85,20 +86,15 @@ func checkClusterReadiness(kc client.Client) (bool, string, error) { return true, "", nil } -func areRequiredFeatureSetsReady(kc client.Client) (bool, error) { - var featureSets uiapi.FeatureSetList - err := kc.List(context.TODO(), &featureSets) +func isKubeUiServerReady(kc client.Client) (bool, error) { + var feature uiapi.Feature + err := kc.Get(context.TODO(), types.NamespacedName{Name: "kube-ui-server"}, &feature) if err != nil { return false, err } - if len(featureSets.Items) == 0 { - return false, nil - } - for _, fs := range featureSets.Items { - if len(fs.Spec.RequiredFeatures) > 0 && !pointer.Bool(fs.Status.Ready) { - return false, nil - } + if !pointer.Bool(feature.Status.Ready) { + return false, nil } return true, nil }