Skip to content

Conversation

@QxBytes
Copy link
Contributor

@QxBytes QxBytes commented Mar 31, 2025

Reason for Change:

Adds a test to validate functionality of a cilium local redirect policy when a cilium network policy is applied-- for example, confirms whether certain dns requests are redirected and increment a metric when they are allowed in the network policy (and confirms that they don't increment the counter when not allowed). Updates necessary utility methods and creates a function that issues an exec on pod command but does not retry on failure.

Issue Fixed:

N/A

Requirements:

Notes:
Example run: https://msazure.visualstudio.com/One/_build/results?buildId=119685764&view=logs&j=a725b465-af6c-5b16-2e20-4e0bf1d0563e&t=d9595ca1-827d-5105-2385-c679bcc42718
Nightly: https://msazure.visualstudio.com/One/_build/results?buildId=119489437&view=results
ACN PR run (no regression): https://msazure.visualstudio.com/One/_build/results?buildId=119699714&view=results

@QxBytes QxBytes self-assigned this Mar 31, 2025
@QxBytes QxBytes added the ci Infra or tooling. label Mar 31, 2025
@QxBytes QxBytes marked this pull request as ready for review April 1, 2025 16:34
Copilot AI review requested due to automatic review settings April 1, 2025 16:34
@QxBytes QxBytes requested a review from a team as a code owner April 1, 2025 16:34
@QxBytes QxBytes requested a review from huntergregory April 1, 2025 16:34
@QxBytes
Copy link
Contributor Author

QxBytes commented Apr 1, 2025

/azp run Azure Container Networking PR

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for testing Cilium Network Policies with FQDN local redirect by introducing new utility functions, updating command execution retries, and expanding integration tests.

  • Added functions to parse, create, and delete CiliumNetworkPolicy resources.
  • Extended the testing framework with a new FQDN policy manifest and updated test logic to validate DNS redirection and metric counting.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/internal/kubernetes/utils_parse.go Added mustParseCNP to support parsing CiliumNetworkPolicy from file.
test/internal/kubernetes/utils_delete.go Added MustDeleteCiliumNetworkPolicy for handling CiliumNetworkPolicy deletion.
test/internal/kubernetes/utils_create.go Introduced mustCreateCiliumNetworkPolicy with new logging for creation.
test/internal/kubernetes/utils.go Added MustSetupCNP, modified ExecCmdOnPod to use ExecCmdOnPodOnce and retry logic.
test/integration/manifests/cilium/lrp/fqdn-cnp.yaml Created a manifest for FQDN-based CiliumNetworkPolicy testing.
test/integration/lrp/lrp_test.go Refactored LRP test to use a common setup function and return a pod struct.
test/integration/lrp/lrp_fqdn_test.go Added integration tests to validate FQDN policies with multiple test cases.
Comments suppressed due to low confidence (3)

test/internal/kubernetes/utils_create.go:195

  • [nitpick] Error handling in mustCreateCiliumNetworkPolicy differs from mustCreateCiliumLocalRedirectPolicy (which uses panic). Consider aligning the error handling strategy for consistency.
log.Fatal(errors.Wrap(err, "failed to delete cilium network policy")) 

test/internal/kubernetes/utils.go:498

  • The ExecCmdOnPod function now wraps ExecCmdOnPodOnce with a retrier, but the retry logic and error handling appear to have been reorganized. Please verify that the retry semantics match the intended behavior as described in the PR.
retrier := retry.Retrier{Attempts: ShortRetryAttempts, Delay: RetryDelay} 

test/integration/lrp/lrp_test.go:127

  • [nitpick] The variable 'selectedClientPod' now holds a Pod struct instead of a string, and the subsequent log uses 'selectedClientPod.Name'. Ensure that the variable name reflects its structure (e.g. 'selectedClientPod' clearly indicates it is a pod object) for clarity.
selectedClientPod := TakeOne(clientPods.Items) 
leverages must delete functions during creation changes log.fatal to panic since log fatal will immediately exit, skipping all defers leverages wait for daemonset instead of wait for pods adds retry parameter to exec cmd on pod, adjusting associated calls incorporates exec cmd on pod error into lrp test
@QxBytes QxBytes force-pushed the alew/lrp-adv-e2e branch from 22fd545 to 3591a97 Compare April 1, 2025 21:52
remove checking for answer string as it only appears in non authoritative dns responses
vipul-21
vipul-21 previously approved these changes Apr 1, 2025
@QxBytes
Copy link
Contributor Author

QxBytes commented Apr 2, 2025

/azp run Azure Container Networking PR

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@QxBytes QxBytes enabled auto-merge April 2, 2025 19:10
@QxBytes QxBytes added this pull request to the merge queue Apr 2, 2025
Merged via the queue into master with commit a2a2ab8 Apr 2, 2025
14 checks passed
@QxBytes QxBytes deleted the alew/lrp-adv-e2e branch April 2, 2025 22:09
sivakami-projects pushed a commit that referenced this pull request Oct 23, 2025
* refactor lrp setup * create lrp test case func * add k8 boilerplate for cnp * add lrp fqdn test and yaml * address linter issue * address feedback * address feedback leverages must delete functions during creation changes log.fatal to panic since log fatal will immediately exit, skipping all defers leverages wait for daemonset instead of wait for pods adds retry parameter to exec cmd on pod, adjusting associated calls incorporates exec cmd on pod error into lrp test * add case without explicit dns server remove checking for answer string as it only appears in non authoritative dns responses * improve debug message * adjust test domain name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Infra or tooling.

4 participants