mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
Merge pull request #90865 from Huang-Wei/dedicated-informfactory-node-controller
test: Use dedicated informerFactory for node lifecycle controller
This commit is contained in:
commit
53ba2ce026
@ -134,7 +134,6 @@ func TestTaintBasedEvictions(t *testing.T) {
|
|||||||
testCtx = testutils.InitTestScheduler(t, testCtx, true, nil)
|
testCtx = testutils.InitTestScheduler(t, testCtx, true, nil)
|
||||||
defer testutils.CleanupTest(t, testCtx)
|
defer testutils.CleanupTest(t, testCtx)
|
||||||
cs := testCtx.ClientSet
|
cs := testCtx.ClientSet
|
||||||
informers := testCtx.InformerFactory
|
|
||||||
_, err := cs.CoreV1().Namespaces().Create(context.TODO(), testCtx.NS, metav1.CreateOptions{})
|
_, err := cs.CoreV1().Namespaces().Create(context.TODO(), testCtx.NS, metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to create namespace %+v", err)
|
t.Errorf("Failed to create namespace %+v", err)
|
||||||
@ -142,10 +141,10 @@ func TestTaintBasedEvictions(t *testing.T) {
|
|||||||
|
|
||||||
// Start NodeLifecycleController for taint.
|
// Start NodeLifecycleController for taint.
|
||||||
nc, err := nodelifecycle.NewNodeLifecycleController(
|
nc, err := nodelifecycle.NewNodeLifecycleController(
|
||||||
informers.Coordination().V1().Leases(),
|
externalInformers.Coordination().V1().Leases(),
|
||||||
informers.Core().V1().Pods(),
|
externalInformers.Core().V1().Pods(),
|
||||||
informers.Core().V1().Nodes(),
|
externalInformers.Core().V1().Nodes(),
|
||||||
informers.Apps().V1().DaemonSets(),
|
externalInformers.Apps().V1().DaemonSets(),
|
||||||
cs,
|
cs,
|
||||||
5*time.Second, // Node monitor grace period
|
5*time.Second, // Node monitor grace period
|
||||||
time.Minute, // Node startup grace period
|
time.Minute, // Node startup grace period
|
||||||
@ -167,8 +166,8 @@ func TestTaintBasedEvictions(t *testing.T) {
|
|||||||
// Waiting for all controller sync.
|
// Waiting for all controller sync.
|
||||||
externalInformers.Start(testCtx.Ctx.Done())
|
externalInformers.Start(testCtx.Ctx.Done())
|
||||||
externalInformers.WaitForCacheSync(testCtx.Ctx.Done())
|
externalInformers.WaitForCacheSync(testCtx.Ctx.Done())
|
||||||
informers.Start(testCtx.Ctx.Done())
|
testCtx.InformerFactory.Start(testCtx.Ctx.Done())
|
||||||
informers.WaitForCacheSync(testCtx.Ctx.Done())
|
testCtx.InformerFactory.WaitForCacheSync(testCtx.Ctx.Done())
|
||||||
|
|
||||||
nodeRes := v1.ResourceList{
|
nodeRes := v1.ResourceList{
|
||||||
v1.ResourceCPU: resource.MustParse("4000m"),
|
v1.ResourceCPU: resource.MustParse("4000m"),
|
||||||
|
@ -79,15 +79,14 @@ func TestTaintNodeByCondition(t *testing.T) {
|
|||||||
defer testutils.CleanupTest(t, testCtx)
|
defer testutils.CleanupTest(t, testCtx)
|
||||||
|
|
||||||
cs := testCtx.ClientSet
|
cs := testCtx.ClientSet
|
||||||
informers := testCtx.InformerFactory
|
|
||||||
nsName := testCtx.NS.Name
|
nsName := testCtx.NS.Name
|
||||||
|
|
||||||
// Start NodeLifecycleController for taint.
|
// Start NodeLifecycleController for taint.
|
||||||
nc, err := nodelifecycle.NewNodeLifecycleController(
|
nc, err := nodelifecycle.NewNodeLifecycleController(
|
||||||
informers.Coordination().V1().Leases(),
|
externalInformers.Coordination().V1().Leases(),
|
||||||
informers.Core().V1().Pods(),
|
externalInformers.Core().V1().Pods(),
|
||||||
informers.Core().V1().Nodes(),
|
externalInformers.Core().V1().Nodes(),
|
||||||
informers.Apps().V1().DaemonSets(),
|
externalInformers.Apps().V1().DaemonSets(),
|
||||||
cs,
|
cs,
|
||||||
time.Hour, // Node monitor grace period
|
time.Hour, // Node monitor grace period
|
||||||
time.Second, // Node startup grace period
|
time.Second, // Node startup grace period
|
||||||
@ -108,8 +107,8 @@ func TestTaintNodeByCondition(t *testing.T) {
|
|||||||
// Waiting for all controller sync.
|
// Waiting for all controller sync.
|
||||||
externalInformers.Start(testCtx.Ctx.Done())
|
externalInformers.Start(testCtx.Ctx.Done())
|
||||||
externalInformers.WaitForCacheSync(testCtx.Ctx.Done())
|
externalInformers.WaitForCacheSync(testCtx.Ctx.Done())
|
||||||
informers.Start(testCtx.Ctx.Done())
|
testCtx.InformerFactory.Start(testCtx.Ctx.Done())
|
||||||
informers.WaitForCacheSync(testCtx.Ctx.Done())
|
testCtx.InformerFactory.WaitForCacheSync(testCtx.Ctx.Done())
|
||||||
|
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
// Test TaintNodeByCondition feature.
|
// Test TaintNodeByCondition feature.
|
||||||
|
Loading…
Reference in New Issue
Block a user