migrated pkg/controller/endpointslice to contextual logging

Signed-off-by: Naman <namanlakhwani@gmail.com>
This commit is contained in:
Naman
2023-01-24 19:09:00 +05:30
parent c95b16b280
commit 09849b09cf
15 changed files with 186 additions and 132 deletions

View File

@@ -100,6 +100,7 @@ func TestDualStackEndpoints(t *testing.T) {
1*time.Second)
epsController := endpointslice.NewController(
ctx,
informers.Core().V1().Pods(),
informers.Core().V1().Services(),
informers.Core().V1().Nodes(),
@@ -112,7 +113,7 @@ func TestDualStackEndpoints(t *testing.T) {
informers.Start(ctx.Done())
// use only one worker to serialize the updates
go epController.Run(ctx, 1)
go epsController.Run(1, ctx.Done())
go epsController.Run(ctx, 1)
var testcases = []struct {
name string

View File

@@ -47,6 +47,7 @@ func TestEndpointSliceMirroring(t *testing.T) {
t.Fatalf("Error creating clientset: %v", err)
}
ctx, cancel := context.WithCancel(context.Background())
resyncPeriod := 12 * time.Hour
informers := informers.NewSharedInformerFactory(client, resyncPeriod)
@@ -58,6 +59,7 @@ func TestEndpointSliceMirroring(t *testing.T) {
1*time.Second)
epsController := endpointslice.NewController(
ctx,
informers.Core().V1().Pods(),
informers.Core().V1().Services(),
informers.Core().V1().Nodes(),
@@ -75,11 +77,10 @@ func TestEndpointSliceMirroring(t *testing.T) {
1*time.Second)
// Start informer and controllers
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
informers.Start(ctx.Done())
go epController.Run(ctx, 5)
go epsController.Run(5, ctx.Done())
go epsController.Run(ctx, 5)
go epsmController.Run(5, ctx.Done())
testCases := []struct {

View File

@@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/informers"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/klog/v2/ktesting"
kubeapiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
"k8s.io/kubernetes/pkg/controller/endpointslice"
"k8s.io/kubernetes/test/integration/framework"
@@ -115,7 +116,9 @@ func TestEndpointSliceTerminating(t *testing.T) {
resyncPeriod := 12 * time.Hour
informers := informers.NewSharedInformerFactory(client, resyncPeriod)
_, ctx := ktesting.NewTestContext(t)
epsController := endpointslice.NewController(
ctx,
informers.Core().V1().Pods(),
informers.Core().V1().Services(),
informers.Core().V1().Nodes(),
@@ -125,10 +128,10 @@ func TestEndpointSliceTerminating(t *testing.T) {
1*time.Second)
// Start informer and controllers
stopCh := make(chan struct{})
defer close(stopCh)
informers.Start(stopCh)
go epsController.Run(1, stopCh)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
informers.Start(ctx.Done())
go epsController.Run(ctx, 1)
// Create namespace
ns := framework.CreateNamespaceOrDie(client, "test-endpoints-terminating", t)