Repository: kubernetes/kubernetes (language: go)

Issue:
Replace all deprecated sets.String with sets.Set from directories managed by in sig/node
In this PR https://github.com/kubernetes/kubernetes/pull/112377, sets.Set is newly implemented, and sets.String got marked as deprecated.

In the files managed by sig/node, there are some `sets.String`. This issue aimas to replace all sets.String with sets.Set in the sig/node area.

ref: https://github.com/kubernetes/kubernetes/issues/113709

/kind cleanup
/sig node

- [x] pkg/controller/nodelifecycle
- [ ] test/e2e


Discussion / hints:

Fix patch:
diff --git a/pkg/controller/nodelifecycle/scheduler/rate_limited_queue.go b/pkg/controller/nodelifecycle/scheduler/rate_limited_queue.go
index 289dc019c7453..a1f8326f54c35 100644
--- a/pkg/controller/nodelifecycle/scheduler/rate_limited_queue.go
+++ b/pkg/controller/nodelifecycle/scheduler/rate_limited_queue.go
@@ -81,7 +81,7 @@ func (h *TimedQueue) Pop() interface{} {
 type UniqueQueue struct {
 	lock  sync.Mutex
 	queue TimedQueue
-	set   sets.String
+	set   sets.Set[string]
 }
 
 // Add a new value to the queue if it wasn't added before, or was
@@ -189,7 +189,7 @@ func (q *UniqueQueue) Clear() {
 		q.queue = make(TimedQueue, 0)
 	}
 	if len(q.set) > 0 {
-		q.set = sets.NewString()
+		q.set = sets.New[string]()
 	}
 }
 
@@ -207,7 +207,7 @@ func NewRateLimitedTimedQueue(limiter flowcontrol.RateLimiter) *RateLimitedTimed
 	return &RateLimitedTimedQueue{
 		queue: UniqueQueue{
 			queue: TimedQueue{},
-			set:   sets.NewString(),
+			set:   sets.New[string](),
 		},
 		limiter: limiter,
 	}


Test patch:
diff --git a/pkg/controller/nodelifecycle/scheduler/rate_limited_queue_test.go b/pkg/controller/nodelifecycle/scheduler/rate_limited_queue_test.go
index f97c7198ce569..fb19b7f29b370 100644
--- a/pkg/controller/nodelifecycle/scheduler/rate_limited_queue_test.go
+++ b/pkg/controller/nodelifecycle/scheduler/rate_limited_queue_test.go
@@ -35,7 +35,7 @@ func CheckQueueEq(lhs []string, rhs TimedQueue) bool {
 	return true
 }
 
-func CheckSetEq(lhs, rhs sets.String) bool {
+func CheckSetEq(lhs, rhs sets.Set[string]) bool {
 	return lhs.IsSuperset(rhs) && rhs.IsSuperset(lhs)
 }
 
@@ -49,7 +49,7 @@ func TestUniqueQueueGet(t *testing.T) {
 
 	queue := UniqueQueue{
 		queue: TimedQueue{},
-		set:   sets.NewString(),
+		set:   sets.New[string](),
 	}
 	queue.Add(TimedValue{Value: "first", UID: "11111", AddedAt: now(), ProcessAt: now()})
 	queue.Add(TimedValue{Value: "second", UID: "22222", AddedAt: now(), ProcessAt: now()})
@@ -63,7 +63,7 @@ func TestUniqueQueueGet(t *testing.T) {
 		t.Errorf("Invalid queue. Got %v, expected %v", queue.queue, queuePattern)
 	}
 
-	setPattern := sets.NewString("first", "second", "third")
+	setPattern := sets.New[string]("first", "second", "third")
 	if len(queue.set) != len(setPattern) {
 		t.Fatalf("Map %v should have length %d", queue.set, len(setPattern))
 	}
@@ -80,7 +80,7 @@ func TestUniqueQueueGet(t *testing.T) {
 		t.Errorf("Invalid queue. Got %v, expected %v", queue.queue, queuePattern)
 	}
 
-	setPattern = sets.NewString("second", "third")
+	setPattern = sets.New[string]("second", "third")
 	if len(queue.set) != len(setPattern) {
 		t.Fatalf("Map %v should have length %d", queue.set, len(setPattern))
 	}
@@ -103,7 +103,7 @@ func TestAddNode(t *testing.T) {
 		t.Errorf("Invalid queue. Got %v, expected %v", evictor.queue.queue, queuePattern)
 	}
 
-	setPattern := sets.NewString("first", "second", "third")
+	setPattern := sets.New[string]("first", "second", "third")
 	if len(evictor.queue.set) != len(setPattern) {
 		t.Fatalf("Map %v should have length %d", evictor.queue.set, len(setPattern))
 	}
@@ -134,7 +134,7 @@ func TestDelNode(t *testing.T) {
 		t.Errorf("Invalid queue. Got %v, expected %v", evictor.queue.queue, queuePattern)
 	}
 
-	setPattern := sets.NewString("second", "third")
+	setPattern := sets.New[string]("second", "third")
 	if len(evictor.queue.set) != len(setPattern) {
 		t.Fatalf("Map %v should have length %d", evictor.queue.set, len(setPattern))
 	}
@@ -156,7 +156,7 @@ func TestDelNode(t *testing.T) {
 		t.Errorf("Invalid queue. Got %v, expected %v", evictor.queue.queue, queuePattern)
 	}
 
-	setPattern = sets.NewString("first", "third")
+	setPattern = sets.New[string]("first", "third")
 	if len(evictor.queue.set) != len(setPattern) {
 		t.Fatalf("Map %v should have length %d", evictor.queue.set, len(setPattern))
 	}
@@ -178,7 +178,7 @@ func TestDelNode(t *testing.T) {
 		t.Errorf("Invalid queue. Got %v, expected %v", evictor.queue.queue, queuePattern)
 	}
 
-	setPattern = sets.NewString("first", "second")
+	setPattern = sets.New[string]("first", "second")
 	if len(evictor.queue.set) != len(setPattern) {
 		t.Fatalf("Map %v should have length %d", evictor.queue.set, len(setPattern))
 	}
@@ -194,14 +194,14 @@ func TestTry(t *testing.T) {
 	evictor.Add("third", "33333")
 	evictor.Remove("second")
 
-	deletedMap := sets.NewString()
+	deletedMap := sets.New[string]()
 	logger, _ := ktesting.NewTestContext(t)
 	evictor.Try(logger, func(value TimedValue) (bool, time.Duration) {
 		deletedMap.Insert(value.Value)
 		return true, 0
 	})
 
-	setPattern := sets.NewString("first", "third")
+	setPattern := sets.New[string]("first", "third")
 	if len(deletedMap) != len(setPattern) {
 		t.Fatalf("Map %v should have length %d", evictor.queue.set, len(setPattern))
 	}
@@ -371,14 +371,14 @@ func TestAddAfterTry(t *testing.T) {
 	evictor.Add("third", "33333")
 	evictor.Remove("second")
 
-	deletedMap := sets.NewString()
+	deletedMap := sets.New[string]()
 	logger, _ := ktesting.NewTestContext(t)
 	evictor.Try(logger, func(value TimedValue) (bool, time.Duration) {
 		deletedMap.Insert(value.Value)
 		return true, 0
 	})
 
-	setPattern := sets.NewString("first", "third")
+	setPattern := sets.New[string]("first", "third")
 	if len(deletedMap) != len(setPattern) {
 		t.Fatalf("Map %v should have length %d", evictor.queue.set, len(setPattern))
 	}