Skip to content

Commit

Permalink
Check only the readiness of kube-ui-server for cluster status. (#291)
Browse files Browse the repository at this point in the history
Signed-off-by: Rokibul Hasan <[email protected]>
  • Loading branch information
RokibulHasan7 authored Mar 13, 2024
1 parent dd58bb3 commit 90839ad
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions pkg/registry/meta/clusterstatus/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 90839ad

Please sign in to comment.