Skip to content

Commit 9cfcc24

Browse files
committed
fix: remove dangling cluster taints
Because of an issue, after Cluster deletion, ClusterTaint resources were not cleaned up properly. This was discovered during the migration to move away from ClusterTaint resource. This commit will clean-up dangling taints. Signed-off-by: Oguz Kilcan <[email protected]> (cherry picked from commit ffd695f)
1 parent ea874ab commit 9cfcc24

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

internal/backend/runtime/omni/migration/migration_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,10 +2199,14 @@ func (suite *MigrationSuite) TestMoveClusterTaintFromResourceToLabel() {
21992199
defer cancel()
22002200

22012201
clusterID := "cluster1"
2202+
deletedClusterID := "cluster2"
22022203

22032204
taint := omni.NewClusterTaint(resources.DefaultNamespace, clusterID)
22042205
suite.Require().NoError(suite.state.Create(ctx, taint))
22052206

2207+
danglingTaint := omni.NewClusterTaint(resources.DefaultNamespace, deletedClusterID)
2208+
suite.Require().NoError(suite.state.Create(ctx, danglingTaint))
2209+
22062210
clusterStatus := omni.NewClusterStatus(resources.DefaultNamespace, clusterID)
22072211
suite.Require().NoError(suite.state.Create(ctx, clusterStatus, state.WithCreateOwner(omnictrl.ClusterStatusControllerName)))
22082212

@@ -2221,6 +2225,11 @@ func (suite *MigrationSuite) TestMoveClusterTaintFromResourceToLabel() {
22212225
suite.Require().Error(err)
22222226
suite.Require().True(state.IsNotFoundError(err), "ClusterTaint resource should not exist after migration")
22232227
suite.Require().Nil(taintDeleted, "ClusterTaint resource should not exist after migration")
2228+
2229+
danglingTaintDeleted, err := safe.ReaderGetByID[*omni.ClusterTaint](ctx, suite.state, deletedClusterID)
2230+
suite.Require().Error(err)
2231+
suite.Require().True(state.IsNotFoundError(err), "ClusterTaint resource should not exist after migration")
2232+
suite.Require().Nil(danglingTaintDeleted, "ClusterTaint resource should not exist after migration")
22242233
}
22252234

22262235
func startMigration[

internal/backend/runtime/omni/migration/migrations.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1931,9 +1931,10 @@ func moveClusterTaintFromResourceToLabel(ctx context.Context, st state.State, _
19311931

19321932
return nil
19331933
}, state.WithExpectedPhaseAny(), state.WithUpdateOwner(omnictrl.ClusterStatusControllerName))
1934-
if err != nil {
1934+
if err != nil && !state.IsNotFoundError(err) {
19351935
return err
19361936
}
1937+
// cluster status does not exist, taint is dangling, just remove it
19371938

19381939
if err = st.TeardownAndDestroy(ctx, taint.Metadata()); err != nil {
19391940
return err

0 commit comments

Comments
 (0)