skip importing terminating clusters (#1358)

Signed-off-by: Yang Le <yangle@redhat.com>
This commit is contained in:
Yang Le
2026-01-29 13:13:32 +08:00
committed by GitHub
parent 2743547b40
commit f2aa5d4d6a
2 changed files with 15 additions and 0 deletions

View File

@@ -116,6 +116,11 @@ func (i *Importer) sync(ctx context.Context, syncCtx factory.SyncContext, cluste
return err
}
// If the cluster is in terminating state, skip the reconcile
if !cluster.DeletionTimestamp.IsZero() {
return nil
}
// If the cluster is imported, skip the reconcile
if meta.IsStatusConditionTrue(cluster.Status.Conditions, ManagedClusterConditionImported) {
return nil

View File

@@ -28,6 +28,7 @@ import (
)
func TestSync(t *testing.T) {
now := metav1.Now()
cases := []struct {
name string
provider *fakeProvider
@@ -62,6 +63,15 @@ func TestSync(t *testing.T) {
testingcommon.AssertNoActions(t, actions)
},
},
{
name: "cluster in terminating state",
provider: &fakeProvider{isOwned: true},
key: "cluster1",
cluster: &clusterv1.ManagedCluster{ObjectMeta: metav1.ObjectMeta{Name: "cluster1", DeletionTimestamp: &now}},
validate: func(t *testing.T, actions []clienttesting.Action) {
testingcommon.AssertNoActions(t, actions)
},
},
{
name: "not owned by the provider",
provider: &fakeProvider{isOwned: false},