mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 18:09:57 +00:00
skip importing terminating clusters (#1358)
Signed-off-by: Yang Le <yangle@redhat.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user