Skip to content

Conversation

@sivakami-projects
Copy link
Contributor

Reason for Change:

Added a new stage to the long running cluster to create and delete pn, pni and pod objects repeatedly.

Requirements:

Notes:

@sivakami-projects sivakami-projects marked this pull request as ready for review November 10, 2025 22:36
@sivakami-projects sivakami-projects requested a review from a team as a code owner November 10, 2025 22:36
Copilot finished reviewing on behalf of sivakami-projects November 10, 2025 22:38
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 a new long-running test stage to the SwiftV2 pipeline that repeatedly creates and deletes PodNetwork (pn), PodNetworkInstance (pni), and Pod objects to test the datapath over extended periods.

Key changes:

  • New Ginkgo test suite that runs indefinitely, cycling through resource creation and deletion every 35 minutes
  • Helper functions for Azure resource queries and Kubernetes operations
  • Pipeline configuration updates to run the new test stage with unlimited timeout
  • Refactored VNet creation scripts to use loops and dynamic cluster naming

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/integration/swiftv2/longRunningCluster/datapath_test.go New test suite for long-running datapath tests with resource lifecycle management
test/integration/swiftv2/longRunningCluster/datapath.go Helper functions to create Kubernetes resources from templates
test/integration/swiftv2/helpers/az_helpers.go New helper functions for Azure CLI operations and Kubernetes resource management
test/integration/manifests/swiftv2/long-running-cluster/*.yaml Kubernetes resource templates for PodNetwork, PodNetworkInstance, and Pods
hack/aks/Makefile New targets for delegated subnet creation and dummy cluster provisioning
go.mod & go.sum Updated Go version and dependencies, removed version pinning for Ginkgo/Gomega
.pipelines/swiftv2-long-running/template/long-running-pipeline-template.yaml New test stage with unlimited timeout
.pipelines/swiftv2-long-running/scripts/create_vnets.sh Refactored to use loops and create delegation clusters dynamically
.pipelines/swiftv2-long-running/scripts/create_aks.sh Added kubeconfig export for test consumption
.pipelines/swiftv2-long-running/pipeline.yaml Updated default VM size

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +45 to +46
for {
iteration++
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The infinite loop lacks any graceful termination mechanism or error handling for catastrophic failures. If the test encounters repeated failures, it will continue indefinitely. Consider adding a context with cancellation or a maximum iteration count to allow controlled shutdown.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +26
func runAzCommand(cmd string, args ...string) string {
out, err := exec.Command(cmd, args...).CombinedOutput()
if err != nil {
panic(fmt.Sprintf("Failed to run %s %v: %s", cmd, args, string(out)))
}
return strings.TrimSpace(string(out))
}

func GetVnetGUID(rg, vnet string) string {
return runAzCommand("az", "network", "vnet", "show", "--resource-group", rg, "--name", vnet, "--query", "resourceGuid", "-o", "tsv")
}

func GetSubnetARMID(rg, vnet, subnet string) string {
return runAzCommand("az", "network", "vnet", "subnet", "show", "--resource-group", rg, "--vnet-name", vnet, "--name", subnet, "--query", "id", "-o", "tsv")
}

func GetSubnetGUID(rg, vnet, subnet string) string {
subnetID := GetSubnetARMID(rg, vnet, subnet)
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

Using panic in a helper function is not idiomatic for Go libraries and makes error handling difficult for callers. Return an error instead and let the caller decide how to handle failures. This is especially important in test code where you want meaningful test failures, not panics.

Suggested change
func runAzCommand(cmd string, args ...string) string {
out, err := exec.Command(cmd, args...).CombinedOutput()
if err != nil {
panic(fmt.Sprintf("Failed to run %s %v: %s", cmd, args, string(out)))
}
return strings.TrimSpace(string(out))
}
func GetVnetGUID(rg, vnet string) string {
return runAzCommand("az", "network", "vnet", "show", "--resource-group", rg, "--name", vnet, "--query", "resourceGuid", "-o", "tsv")
}
func GetSubnetARMID(rg, vnet, subnet string) string {
return runAzCommand("az", "network", "vnet", "subnet", "show", "--resource-group", rg, "--vnet-name", vnet, "--name", subnet, "--query", "id", "-o", "tsv")
}
func GetSubnetGUID(rg, vnet, subnet string) string {
subnetID := GetSubnetARMID(rg, vnet, subnet)
func runAzCommand(cmd string, args ...string) (string, error) {
out, err := exec.Command(cmd, args...).CombinedOutput()
if err != nil {
return "", fmt.Errorf("failed to run %s %v: %s", cmd, args, string(out))
}
return strings.TrimSpace(string(out)), nil
}
func GetVnetGUID(rg, vnet string) (string, error) {
return runAzCommand("az", "network", "vnet", "show", "--resource-group", rg, "--name", vnet, "--query", "resourceGuid", "-o", "tsv")
}
func GetSubnetARMID(rg, vnet, subnet string) (string, error) {
return runAzCommand("az", "network", "vnet", "subnet", "show", "--resource-group", rg, "--vnet-name", vnet, "--name", subnet, "--query", "id", "-o", "tsv")
}
func GetSubnetGUID(rg, vnet, subnet string) (string, error) {
subnetID, err := GetSubnetARMID(rg, vnet, subnet)
if err != nil {
return "", fmt.Errorf("failed to get subnet ARM ID: %w", err)
}

Copilot uses AI. Check for mistakes.
Comment on lines +128 to +132
@i=1; \
for subnet in $(EXTRA_SUBNETS); do \
prefix=$$(echo $(EXTRA_SUBNET_CIDRS) | cut -d',' -f$$i); \
$(AZCLI) network vnet subnet create -g $(GROUP) --vnet-name $(VNET) --name $$subnet --address-prefixes $$prefix -o none; \
i=$$((i+1)); \
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The loop increments i after creating each subnet, but if EXTRA_SUBNETS and EXTRA_SUBNET_CIDRS have mismatched counts, this will silently use empty prefixes or wrong prefixes for later subnets. There's no validation that the two lists have the same number of elements. Add validation or use a safer iteration method.

Suggested change
@i=1; \
for subnet in $(EXTRA_SUBNETS); do \
prefix=$$(echo $(EXTRA_SUBNET_CIDRS) | cut -d',' -f$$i); \
$(AZCLI) network vnet subnet create -g $(GROUP) --vnet-name $(VNET) --name $$subnet --address-prefixes $$prefix -o none; \
i=$$((i+1)); \
@subnets="$(EXTRA_SUBNETS)"; \
cidrs="$(EXTRA_SUBNET_CIDRS)"; \
subnet_count=$$(echo $$subnets | awk '{print NF}'); \
cidr_count=$$(echo $$cidrs | awk -F',' '{print NF}'); \
if [ "$$subnet_count" -ne "$$cidr_count" ]; then \
echo "Error: Number of EXTRA_SUBNETS ($$subnet_count) does not match number of EXTRA_SUBNET_CIDRS ($$cidr_count)"; \
exit 1; \
fi; \
i=1; \
for subnet in $$subnets; do \
prefix=$$(echo $$cidrs | cut -d',' -f$$i); \
$(AZCLI) network vnet subnet create -g $(GROUP) --vnet-name $(VNET) --name $$subnet --address-prefixes $$prefix -o none; \
i=$$((i+1)); \

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants