Skip to content

Commit

Permalink
fix: no longer remove the agent ignore label from namespaces (#2623)
Browse files Browse the repository at this point in the history
## Description

Fixes namespaces being able to be excluded from Zarf's mutation
(deleting the label forces everything through the Zarf agent).

## Related Issue

Fixes #N/A

## Checklist before merging

- [ ] Test, docs, adr added or updated as needed
- [X] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/.github/CONTRIBUTING.md#developer-workflow)
followed

---------

Co-authored-by: Austin Abro <[email protected]>
  • Loading branch information
Racer159 and AustinAbro321 committed Jun 13, 2024
1 parent 3932a13 commit 7415967
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/pkg/cluster/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@ func AdoptZarfManagedLabels(labels map[string]string) map[string]string {
labels = make(map[string]string)
}
labels[k8s.ZarfManagedByLabel] = "zarf"
delete(labels, k8s.AgentLabel)
return labels
}
16 changes: 16 additions & 0 deletions src/test/e2e/26_simple_packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,19 @@ func TestManifests(t *testing.T) {
stdOut, stdErr, err = e2e.Zarf("package", "remove", "manifests", "--confirm")
require.NoError(t, err, stdOut, stdErr)
}

func TestAgentIgnore(t *testing.T) {
t.Log("E2E: Test Manifests that are Agent Ignored")
e2e.SetupWithCluster(t)

testCreate := filepath.Join("src", "test", "packages", "26-agent-ignore")
testDeploy := filepath.Join("build", fmt.Sprintf("zarf-package-agent-ignore-namespace-%s.tar.zst", e2e.Arch))

// Create the agent ignore test package
stdOut, stdErr, err := e2e.Zarf("package", "create", testCreate, "-o", "build", "--confirm")
require.NoError(t, err, stdOut, stdErr)

// Deploy the agent ignore test package
stdOut, stdErr, err = e2e.Zarf("package", "deploy", testDeploy, "--confirm")
require.NoError(t, err, stdOut, stdErr)
}
20 changes: 20 additions & 0 deletions src/test/packages/26-agent-ignore/manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd-deployment
spec:
selector:
matchLabels:
app: httpd
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: httpd
spec:
containers:
- name: httpd
# This is explicitly a different tag than examples/manifests to ensure it has to pull the image from outside the cluster
image: "httpd:alpine"
ports:
- containerPort: 80
6 changes: 6 additions & 0 deletions src/test/packages/26-agent-ignore/manifests/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: httpd-ignored
labels:
zarf.dev/agent: ignore
23 changes: 23 additions & 0 deletions src/test/packages/26-agent-ignore/zarf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: ZarfPackageConfig
metadata:
name: agent-ignore-namespace
description: Simple test to check that Zarf respects ignored namespaces.

components:
- name: httpd-deployment
required: true
manifests:
- name: agent-ignore-httpd
namespace: httpd-ignored
files:
- manifests/deployment.yaml
- manifests/namespace.yaml
actions:
onDeploy:
after:
- wait:
cluster:
kind: deployment
name: httpd-deployment
namespace: httpd-ignored
condition: "{.status.readyReplicas}=2"

0 comments on commit 7415967

Please sign in to comment.