kube-controller-manager: readjust log verbosity
- Increase the global level for broadcaster's logging to 3 so that users can ignore event messages by lowering the logging level. It reduces information noise. - Making sure the context is properly injected into the broadcaster, this will allow the -v flag value to be used also in that broadcaster, rather than the above global value. - test: use cancellation from ktesting - golangci-hints: checked error return value
This commit is contained in:
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package dualstack
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -44,11 +43,9 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
return map[string]string{"foo": "bar"}
|
||||
}
|
||||
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
tCtx := ktesting.Init(t)
|
||||
|
||||
client, _, tearDownFn := framework.StartTestServer(ctx, t, framework.TestServerSetup{
|
||||
client, _, tearDownFn := framework.StartTestServer(tCtx, t, framework.TestServerSetup{
|
||||
ModifyServerRunOptions: func(opts *options.ServerRunOptions) {
|
||||
opts.ServiceClusterIPRanges = fmt.Sprintf("%s,%s", serviceCIDR, secondaryServiceCIDR)
|
||||
// Disable ServiceAccount admission plugin as we don't have serviceaccount controller running.
|
||||
@@ -59,7 +56,7 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
|
||||
// Wait until the default "kubernetes" service is created.
|
||||
if err := wait.Poll(250*time.Millisecond, time.Minute, func() (bool, error) {
|
||||
_, err := client.CoreV1().Services(metav1.NamespaceDefault).Get(ctx, "kubernetes", metav1.GetOptions{})
|
||||
_, err := client.CoreV1().Services(metav1.NamespaceDefault).Get(tCtx, "kubernetes", metav1.GetOptions{})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return false, err
|
||||
}
|
||||
@@ -88,11 +85,12 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if _, err := client.CoreV1().Nodes().Create(ctx, testNode, metav1.CreateOptions{}); err != nil {
|
||||
if _, err := client.CoreV1().Nodes().Create(tCtx, testNode, metav1.CreateOptions{}); err != nil {
|
||||
t.Fatalf("Failed to create Node %q: %v", testNode.Name, err)
|
||||
}
|
||||
|
||||
epController := endpoint.NewEndpointController(
|
||||
tCtx,
|
||||
informers.Core().V1().Pods(),
|
||||
informers.Core().V1().Services(),
|
||||
informers.Core().V1().Endpoints(),
|
||||
@@ -100,7 +98,7 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
1*time.Second)
|
||||
|
||||
epsController := endpointslice.NewController(
|
||||
ctx,
|
||||
tCtx,
|
||||
informers.Core().V1().Pods(),
|
||||
informers.Core().V1().Services(),
|
||||
informers.Core().V1().Nodes(),
|
||||
@@ -110,10 +108,10 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
1*time.Second)
|
||||
|
||||
// Start informer and controllers
|
||||
informers.Start(ctx.Done())
|
||||
informers.Start(tCtx.Done())
|
||||
// use only one worker to serialize the updates
|
||||
go epController.Run(ctx, 1)
|
||||
go epsController.Run(ctx, 1)
|
||||
go epController.Run(tCtx, 1)
|
||||
go epsController.Run(tCtx, 1)
|
||||
|
||||
var testcases = []struct {
|
||||
name string
|
||||
@@ -170,7 +168,7 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
createdPod, err := client.CoreV1().Pods(ns.Name).Create(ctx, pod, metav1.CreateOptions{})
|
||||
createdPod, err := client.CoreV1().Pods(ns.Name).Create(tCtx, pod, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create pod %s: %v", pod.Name, err)
|
||||
}
|
||||
@@ -181,7 +179,7 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
Phase: v1.PodRunning,
|
||||
PodIPs: []v1.PodIP{{IP: podIPbyFamily[v1.IPv4Protocol]}, {IP: podIPbyFamily[v1.IPv6Protocol]}},
|
||||
}
|
||||
_, err = client.CoreV1().Pods(ns.Name).UpdateStatus(ctx, createdPod, metav1.UpdateOptions{})
|
||||
_, err = client.CoreV1().Pods(ns.Name).UpdateStatus(tCtx, createdPod, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to update status of pod %s: %v", pod.Name, err)
|
||||
}
|
||||
@@ -209,7 +207,7 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
}
|
||||
|
||||
// create a service
|
||||
_, err = client.CoreV1().Services(ns.Name).Create(ctx, svc, metav1.CreateOptions{})
|
||||
_, err = client.CoreV1().Services(ns.Name).Create(tCtx, svc, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating service: %v", err)
|
||||
}
|
||||
@@ -218,7 +216,7 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
// legacy endpoints are not dual stack
|
||||
// and use the address of the first IP family
|
||||
if err := wait.PollImmediate(1*time.Second, wait.ForeverTestTimeout, func() (bool, error) {
|
||||
e, err := client.CoreV1().Endpoints(ns.Name).Get(ctx, svc.Name, metav1.GetOptions{})
|
||||
e, err := client.CoreV1().Endpoints(ns.Name).Get(tCtx, svc.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Logf("Error fetching endpoints: %v", err)
|
||||
return false, nil
|
||||
@@ -240,7 +238,7 @@ func TestDualStackEndpoints(t *testing.T) {
|
||||
// wait until the endpoint slices are created
|
||||
err = wait.PollImmediate(1*time.Second, wait.ForeverTestTimeout, func() (bool, error) {
|
||||
lSelector := discovery.LabelServiceName + "=" + svc.Name
|
||||
esList, err := client.DiscoveryV1().EndpointSlices(ns.Name).List(ctx, metav1.ListOptions{LabelSelector: lSelector})
|
||||
esList, err := client.DiscoveryV1().EndpointSlices(ns.Name).List(tCtx, metav1.ListOptions{LabelSelector: lSelector})
|
||||
if err != nil {
|
||||
t.Logf("Error listing EndpointSlices: %v", err)
|
||||
return false, nil
|
||||
|
Reference in New Issue
Block a user