Skip to content

Commit

Permalink
metrics: Fix format error log in validateMetric
Browse files Browse the repository at this point in the history
Previously, the log error was not formatted  properly: "context timeout:
%!w(string=context deadline exceeded)", now it prints the error message a
string: "context timeout: context deadline exceeded".

Signed-off-by: Donia Chaiehloudj <[email protected]>
  • Loading branch information
doniacld committed Jul 10, 2023
1 parent c07aeda commit 37d4983
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion connectivity/check/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ func (a *Action) validateMetric(ctx context.Context, node string, result Metrics
select {
case <-ctx.Done():
// Context timeout is reached, let's exit.
a.Failf("failed to collect metrics on node %s, context timeout: %w", node, ctx.Err().Error())
a.Failf("failed to collect metrics on node %s, context timeout: %s\n", node, ctx.Err())
return
case <-ticker.C:
// Ticker is delivered, let's retry.
Expand Down
30 changes: 15 additions & 15 deletions connectivity/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,13 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch

// Tests with deny policy
ct.NewTest("echo-ingress-from-other-client-deny").
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(echoIngressFromOtherClientDenyPolicyYAML). // Deny other client contact echo
WithScenarios(
tests.PodToPod(tests.WithSourceLabelsOption(clientLabel)), // Client to echo should be allowed
tests.PodToPod(tests.WithSourceLabelsOption(client2Label)), // Client2 to echo should be denied
tests.ClientToClient(), // Client to client should be allowed
tests.ClientToClient(), // Client to client should be allowed
).
WithExpectations(func(a *check.Action) (egress, ingress check.Result) {
if a.Source().HasLabel("other", "client") &&
Expand All @@ -591,8 +591,8 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch

// This policy denies ICMP ingress to client only from other client
ct.NewTest("client-ingress-from-other-client-icmp-deny").
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(echoIngressICMPDenyPolicyYAML). // Deny ICMP traffic from client to another client
WithFeatureRequirements(check.RequireFeatureEnabled(check.FeatureICMPPolicy)).
WithScenarios(
Expand All @@ -609,8 +609,8 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch

// This policy denies port 8080 from client to echo
ct.NewTest("client-egress-to-echo-deny").
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(clientEgressToEchoDenyPolicyYAML). // Deny client to echo traffic via port 8080
WithScenarios(
tests.ClientToClient(), // Client to client traffic should be allowed
Expand All @@ -627,7 +627,7 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch

// This policy denies port http-8080 from client to echo, but allows traffic from client2 to echo
ct.NewTest("client-ingress-to-echo-named-port-deny").
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(clientEgressToEchoDenyNamedPortPolicyYAML).
WithScenarios(
Expand All @@ -644,7 +644,7 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch

// This policy denies port 8080 from client to echo (using label match expression), but allows traffic from client2
ct.NewTest("client-egress-to-echo-expression-deny").
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(clientEgressToEchoExpressionDenyPolicyYAML).
WithScenarios(
Expand All @@ -661,7 +661,7 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch

// This policy denies port 8080 from client with service account selector to echo, but not from client2
ct.NewTest("client-with-service-account-egress-to-echo-deny").
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(clientWithServiceAccountEgressToEchoDenyPolicyYAML).
WithScenarios(
Expand All @@ -678,7 +678,7 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch

// This policy denies port 8080 from client to endpoint with service account, but not from client2
ct.NewTest("client-egress-to-echo-service-account-deny").
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(clientEgressToEchoServiceAccountDenyPolicyYAML).
WithScenarios(
Expand Down Expand Up @@ -832,15 +832,15 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch
// Test L7 HTTP with different methods introspection using an egress policy on the clients.
ct.NewTest("client-egress-l7-method").
WithFeatureRequirements(check.RequireFeatureEnabled(check.FeatureL7Proxy)).
WithCiliumPolicy(clientEgressOnlyDNSPolicyYAML). // DNS resolution only
WithCiliumPolicy(clientEgressOnlyDNSPolicyYAML). // DNS resolution only
WithCiliumPolicy(clientEgressL7HTTPMethodPolicyYAML). // L7 allow policy with HTTP introspection (POST only)
WithScenarios(
tests.PodToPodWithEndpoints(tests.WithMethod("POST"), tests.WithDestinationLabelsOption(map[string]string{"other": "echo"})),
tests.PodToPodWithEndpoints(tests.WithDestinationLabelsOption(map[string]string{"first": "echo"})),
).
WithExpectations(func(a *check.Action) (egress, ingress check.Result) {
if a.Source().HasLabel("other", "client") && // Only client2 is allowed to make HTTP calls.
(a.Destination().Port() == 8080) { // port 8080 is traffic to echo Pod.
(a.Destination().Port() == 8080) { // port 8080 is traffic to echo Pod.
if a.Destination().HasLabel("other", "echo") { //we are POSTing only other echo
egress = check.ResultOK

Expand All @@ -858,7 +858,7 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch
// Test L7 HTTP introspection using an egress policy on the clients.
ct.NewTest("client-egress-l7").
WithFeatureRequirements(check.RequireFeatureEnabled(check.FeatureL7Proxy)).
WithCiliumPolicy(clientEgressOnlyDNSPolicyYAML). // DNS resolution only
WithCiliumPolicy(clientEgressOnlyDNSPolicyYAML). // DNS resolution only
WithCiliumPolicy(renderedTemplates["clientEgressL7HTTPPolicyYAML"]). // L7 allow policy with HTTP introspection
WithScenarios(
tests.PodToPod(),
Expand Down Expand Up @@ -886,7 +886,7 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch
// Test L7 HTTP named port introspection using an egress policy on the clients.
ct.NewTest("client-egress-l7-named-port").
WithFeatureRequirements(check.RequireFeatureEnabled(check.FeatureL7Proxy)).
WithCiliumPolicy(clientEgressOnlyDNSPolicyYAML). // DNS resolution only
WithCiliumPolicy(clientEgressOnlyDNSPolicyYAML). // DNS resolution only
WithCiliumPolicy(renderedTemplates["clientEgressL7HTTPNamedPortPolicyYAML"]). // L7 allow policy with HTTP introspection (named port)
WithScenarios(
tests.PodToPod(),
Expand Down

0 comments on commit 37d4983

Please sign in to comment.