Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Shared E2E resource group

## Requirements and decisions

- User originally approved opt-in shared resource group mode, then requested shared-group-only execution with no mode flag.
- Push a new branch based on main. Do not run live Azure E2E or cleanup without separate approval.
- Shared group `fleet-networking-e2e` was created in the test subscription, westus2. Proposed grants and WIF service connection are not yet deployed.
- Prior work: [retry PR #459](https://github.com/Azure/fleet-networking/pull/459).

## Plan

1. [x] Trace E2E setup, tests, Azure dependencies, resource ownership and cleanup.
2. [x] Add offline tests for concurrent run isolation, configuration and fail-closed cleanup.
3. [x] Implement opt-in shared-group setup, naming, permissions and safe per-run cleanup; preserve existing behavior.
4. [x] Update documentation and validate targeted tests and shell checks.
5. [x] Push branch and report unverified live behavior and remaining risks.

## Before

Each Azure DevOps scenario creates and deletes a unique resource group. Fixed resource and cluster names assume one run per group.

## Investigation

- `test/scripts/bootstrap.sh` creates the whole group, fixed cluster names, a registry named from the group, Azure identities and role assignments. The network topology scripts create fixed VNet names.
- `test/e2e/e2e_test.go`, `test/e2e/framework/workload_manager.go` and `test/scripts/install-afd.sh` assume fixed cluster or registry names. AFD validates the member node resource groups before assigning roles.
- Traffic Manager profiles are named from Kubernetes object UIDs and tagged with the namespaced profile name; Front Door profiles use Kubernetes hub and Gateway ownership tags. The Traffic Manager E2E also creates an independently named public IP. These resources cannot safely be selected for cleanup using only a generic run-name prefix.
- The proposed WIF identity and grants have not been deployed. Existing E2E scripts assign roles using `--assignee`, and the AFD proof needs separate Network Contributor on member node groups for its test caller.
- A correct shared-group implementation needs durable per-run ownership evidence for controller-generated resources, exact ownership checks and cleanup ordering, including partial setup and cancellation. The current group-deletion cleanup cannot be reused.

## Status

### Admin-context failure follow-up

The approved Azure DevOps run failed during setup because Azure CLI appended `-admin` to context names that already included that suffix. The same issue blocked ATM and AFD cleanup. The user requested a fix, push and another run.

1. [x] Reproduce the context failure in a focused offline test.
2. [x] Correct setup and cleanup and validate offline.
3. [x] Inspect and report resources left by the failed run; obtain explicit approval before manual cleanup.
4. [x] Push the fix.
5. [ ] Trigger and validate the requested new E2E run.

Azure CLI appends `-admin` to an explicitly supplied context for admin credentials. Setup and cleanup now pass the unsuffixed logical cluster name; the Kubernetes context remains `<name>-admin`. The focused mock reproduces the failure before the fix and passes afterward for ordinary setup, performance setup and cleanup. The full script suite, vet, Bash syntax and whitespace checks passed.

The original run completed with failed ATM and AFD cleanup. The user explicitly approved cleanup of those two scenarios. The fixed cleanup completed successfully; read-back found no tagged resources, no six AKS-managed node groups and no role assignments on those node-group scopes. The shared resource group and its tags were preserved, and temporary admin kubeconfigs were removed.

The user approved removing setup kubeconfig, group and collision checks, the cleanup marker, and matching cleanup checks. Azure DevOps log collection and cleanup will run with `always()`. Per-resource ownership checks remain.

1. [x] Remove the selected setup and cleanup checks and marker.
2. [x] Make Azure DevOps log collection and cleanup unconditional.
3. [x] Update documentation and validate offline.
4. [x] Push the changes.

The shared-group-only revision:

1. [x] Remove the legacy resource-group creation/deletion path and require per-run shared-group configuration.
2. [x] Update Azure DevOps and GitHub workflow callers and preserve safe cleanup eligibility.
3. [x] Keep performance topology working with run-specific resources and ownership-verified cleanup.
4. [x] Update tests and documentation and validate offline.
5. [x] Push the shared-group-only revision.

The Azure DevOps pipeline supplies a unique run ID per scenario and attempt; scripts derive physical Azure names and retain the established logical Kubernetes contexts. At the user's request, setup no longer validates the kubeconfig path, resource-group tags or run collisions. Azure DevOps always attempts log collection and cleanup.

Cleanup verifies run tags, resource IDs, AKS node-group ownership, role scopes and peering targets. It verifies Traffic Manager namespace tags and Front Door hub/Gateway identity, stops the run's hub controllers before deleting their profiles, deletes only identified roles and resources, and never deletes the shared group. It fails explicitly when ownership, controller quiescence or deletion cannot be verified.

Shared AFD requires the test principal object ID, grants it Network Contributor only on verified member node groups, and records the principal for cleanup. The user requested storing the object ID as the `E2E_TEST_PRINCIPAL_ID` Azure DevOps pipeline variable instead of parsing a token; the variable was configured for the current CI identity. It must be updated whenever the selected service connection changes; its identity is not independently verified by the pipeline.

The user initially chose to retain both resource-group tag checks, then explicitly requested removing them. The guide uses a caller-selected pre-created group name.

The user subsequently requested removal of `shared_group_test.go` and `azure_principal_id_test.go`. Dedicated mocked cleanup and principal-token regression coverage is no longer retained.

The user requested removal of the GitHub Actions E2E workflow. Azure DevOps remains the E2E pipeline; its setup and cleanup behavior is unchanged.

Changed files: `.pipeline/e2e-tests.yaml`, `test/README.md`, the `test/scripts` setup, topology, configuration, AFD and cleanup scripts and tests, plus E2E framework workload naming and Traffic Manager public-IP tagging.

## Validation and risks

- `GOTOOLCHAIN=go1.26.10 go test -count=1 ./test/scripts` passed after the requested test removal. Earlier runs also covered the now-removed mocked cleanup, token parsing and performance topology cases.
- `GOTOOLCHAIN=go1.26.10 go vet ./test/scripts ./test/e2e/framework` passed.
- `GOTOOLCHAIN=go1.26.10 go test -tags=e2e -run '^$' ./test/e2e` and `go vet -tags=e2e ./test/e2e` passed without executing live E2E.
- Performance packages compiled and passed `go vet` without running their suites. Installed Azure CLI option checks, Bash syntax, both workflow YAML parsing and `git diff --check` passed.
- The generic guide's Markdown fences are balanced and its local links resolve.
- After preflight removal, mocked setup reached creation with unset and existing kubeconfig paths; mocked cleanup reached credential retrieval without kubeconfig or group-tag checks. Azure DevOps YAML checks verified unconditional log collection and cleanup, and the remaining script suite and vet passed.
- The new preflight-removal change has not been validated against live Azure. Setup can overwrite existing kubeconfig contexts and reuse run resources; uniqueness is the caller's responsibility. Cleanup can fail closed and leave resources; there is no stale-run sweeper. Contributor on the shared RG is not a security boundary between runs.
141 changes: 0 additions & 141 deletions .github/workflows/e2e-tests.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/unit-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ jobs:
--retry-delay 1 --retry-max-time 30 --connect-timeout 1 --max-time 2 \
"http://$address/$path"
done
docker logs "$container" 2>&1 | grep -q 'Azure Front Door reconciliation is disabled'
docker logs "$container" 2>&1 | grep 'Azure Front Door reconciliation is disabled' >/dev/null

- name: Verify registry export and pull using a loopback-only registry
shell: bash
Expand Down
52 changes: 19 additions & 33 deletions .pipeline/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ trigger:
pr: none

parameters:
- name: serviceConnection
type: string
default: 'aks-devinfra-fleet-networking-e2e-wif'
- name: scenarios
type: object
default:
Expand Down Expand Up @@ -61,7 +64,8 @@ jobs:
AZURE_NETWORK_SETTING: ${{ scenario.value.AZURE_NETWORK_SETTING }}
ENABLE_TRAFFIC_MANAGER: ${{ lower(scenario.value.ENABLE_TRAFFIC_MANAGER) }}
ENABLE_AZURE_FRONT_DOOR: ${{ lower(scenario.value.ENABLE_AZURE_FRONT_DOOR) }}
AZURE_RESOURCE_GROUP: 'fleet-ado-$(Build.BuildId)-$(SCENARIO)-$(System.JobAttempt)'
AZURE_RESOURCE_GROUP: 'fleet-networking-e2e'
E2E_RUN_ID: '$(Build.BuildId)-$(SCENARIO)-$(System.JobAttempt)'
ENABLE_AFD_PRIVATE_LINK_AUTO_APPROVAL: '$(ENABLE_AZURE_FRONT_DOOR)'
RETAIN_AFD_E2E_SETUP: 'false'
BUILDX_BUILDER_NAME: 'fleet-e2e-$(Build.BuildId)-$(SCENARIO)-$(System.JobAttempt)'
Expand Down Expand Up @@ -95,7 +99,7 @@ jobs:
- bash: |
set -euo pipefail
: "${AZURE_SUBSCRIPTION_ID:?Set AZURE_SUBSCRIPTION_ID as a non-secret ADO pipeline variable}"
for tool in az docker helm kubectl jq yq make timeout; do
for tool in az docker helm kubectl jq yq make timeout sha256sum; do
command -v "$tool"
done
go version
Expand All @@ -115,7 +119,7 @@ jobs:
displayName: Set up E2E environment
timeoutInMinutes: 180
inputs:
azureSubscription: 'aks fleetnetworking'
azureSubscription: ${{ parameters.serviceConnection }}
scriptType: bash
scriptLocation: inlineScript
addSpnToEnvironment: false
Expand All @@ -128,12 +132,9 @@ jobs:
echo "error: service connection subscription does not match the E2E subscription" >&2
exit 1
fi
exists=$(az group exists --subscription "$AZURE_SUBSCRIPTION_ID" -n "$AZURE_RESOURCE_GROUP")
if [[ "$exists" != false ]]; then
echo "error: refusing to reuse resource group $AZURE_RESOURCE_GROUP" >&2
exit 1
fi
echo "##vso[task.setvariable variable=e2eResourcesStarted]true"
# Role assignments to the test principal follow the service connection that runs this job.
E2E_TEST_PRINCIPAL_ID="$(bash test/scripts/caller-object-id.sh)"
export E2E_TEST_PRINCIPAL_ID
make e2e-setup

- bash: |
Expand All @@ -150,7 +151,7 @@ jobs:
displayName: Run E2E tests
timeoutInMinutes: ${{ scenario.value.E2E_TEST_TIMEOUT }}
inputs:
azureSubscription: 'aks fleetnetworking'
azureSubscription: ${{ parameters.serviceConnection }}
scriptType: bash
scriptLocation: inlineScript
addSpnToEnvironment: false
Expand All @@ -173,45 +174,30 @@ jobs:
> "$LOG_DIR/environment.txt"
make e2e-collect-logs
displayName: Collect agent logs
condition: and(always(), eq(variables['e2eResourcesStarted'], 'true'))
condition: always()
timeoutInMinutes: 5

- task: PublishPipelineArtifact@1
displayName: Publish agent logs
condition: and(always(), eq(variables['e2eResourcesStarted'], 'true'))
condition: always()
timeoutInMinutes: 5
inputs:
targetPath: '$(LOG_DIR)'
artifact: 'e2e-$(SCENARIO)-$(System.JobAttempt)'

- task: AzureCLI@2
displayName: Clean up this run's resource group
condition: and(always(), eq(variables['e2eResourcesStarted'], 'true'))
timeoutInMinutes: 20
displayName: Clean up this run's resources
condition: always()
timeoutInMinutes: 90
inputs:
azureSubscription: 'aks fleetnetworking'
azureSubscription: ${{ parameters.serviceConnection }}
scriptType: bash
scriptLocation: inlineScript
addSpnToEnvironment: false
visibleAzLogin: false
keepAzSessionActive: true
inlineScript: |
set -euo pipefail
expected="fleet-ado-$BUILD_BUILDID-$SCENARIO-$SYSTEM_JOBATTEMPT"
if [[ "$AZURE_RESOURCE_GROUP" != "$expected" ]]; then
echo "error: refusing cleanup outside this run's resource group" >&2
exit 1
fi
az account set --subscription "$AZURE_SUBSCRIPTION_ID"
exists=$(az group exists --subscription "$AZURE_SUBSCRIPTION_ID" -n "$expected")
if [[ "$exists" == false ]]; then
echo "Resource group $expected is already absent."
exit 0
fi
group=$(az group show --subscription "$AZURE_SUBSCRIPTION_ID" -n "$expected" -o json)
jq -e --arg id "/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$expected" \
'(.id | ascii_downcase) == ($id | ascii_downcase) and .tags.source == "fleet-networking"' \
<<<"$group" > /dev/null
E2E_TEST_PRINCIPAL_ID="$(bash test/scripts/caller-object-id.sh)"
export E2E_TEST_PRINCIPAL_ID
make e2e-cleanup
az group wait --subscription "$AZURE_SUBSCRIPTION_ID" -n "$expected" \
--deleted --interval 15 --timeout 900
Loading
Loading