Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #3010: search filter out not ready cluster #3019

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/search/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (c *Controller) doCacheCluster(cluster string) error {
return nil
}

// STEP1: stop informer manager for the cluster which does not exist anymore.
// STEP1: stop informer manager for the cluster which does not exist anymore or is not ready.
cls, err := c.clusterLister.Get(cluster)
if err != nil {
if apierrors.IsNotFound(err) {
Expand All @@ -194,6 +194,12 @@ func (c *Controller) doCacheCluster(cluster string) error {
return nil
}

if !util.IsClusterReady(&cls.Status) {
klog.Warningf("cluster %s is notReady try to stop this cluster informer", cluster)
c.InformerManager.Stop(cluster)
return nil
}

// STEP2: added/updated cluster, builds an informer manager for a specific cluster.
if !c.InformerManager.IsManagerExist(cluster) {
klog.Info("try to build informer manager for cluster ", cluster)
Expand Down
6 changes: 6 additions & 0 deletions pkg/search/proxy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ func (ctl *Controller) reconcile(util.QueueKey) error {
if !util.ClusterMatches(cluster, registry.Spec.TargetCluster) {
continue
}

if !util.IsClusterReady(&cluster.Status) {
klog.Warningf("cluster %s is notReady", cluster.Name)
continue
}

if _, exist := resourcesByClusters[cluster.Name]; !exist {
resourcesByClusters[cluster.Name] = make(map[schema.GroupVersionResource]struct{})
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/search/proxy/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
karmadafake "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/fake"
karmadainformers "github.com/karmada-io/karmada/pkg/generated/informers/externalversions"
"github.com/karmada-io/karmada/pkg/search/proxy/store"
"github.com/karmada-io/karmada/pkg/util"
)

var (
Expand Down Expand Up @@ -245,6 +246,9 @@ func TestController_reconcile(t *testing.T) {
func newCluster(name string) *clusterv1alpha1.Cluster {
c := &clusterv1alpha1.Cluster{}
c.Name = name
conditions := make([]metav1.Condition, 0, 1)
conditions = append(conditions, util.NewCondition(clusterv1alpha1.ClusterConditionReady, "", "", metav1.ConditionTrue))
c.Status.Conditions = conditions
return c
}

Expand Down