-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(agent): missing path for pod without labels (#2518)
## Description identify when a pod has no labels (and thus has no `/metadata/labels` for jsonpatch replace operations. use the `add` jsonpath operation to add the labels path with the map[string]string value of `{"zarf-agent": "patched"}` ## Related Issue Fixes #2517 ## Testing Deploy a pod without labels to test: ``` apiVersion: v1 kind: Pod metadata: creationTimestamp: null name: test namespace: test spec: containers: - image: nginx name: test resources: {} dnsPolicy: ClusterFirst restartPolicy: Always status: {} ``` ## Checklist before merging - [x] 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
- Loading branch information
1 parent
f6fe020
commit 5bf7e01
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2021-Present The Zarf Authors | ||
|
||
// Package test provides e2e tests for Zarf. | ||
package test | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPodWithoutLabels(t *testing.T) { | ||
t.Log("E2E: Pod Without Labels") | ||
e2e.SetupWithCluster(t) | ||
|
||
// Path to pod manifest containing 0 lavbels | ||
buildPath := filepath.Join("src", "test", "packages", "37-pod-without-labels", "pod.yaml") | ||
|
||
// Create the testing namespace | ||
_, _, err := e2e.Kubectl("create", "ns", "pod-label") | ||
require.NoError(t, err) | ||
|
||
// Create the pod without labels | ||
// This is not an image zarf will have in the registry - but the agent was failing to admit on an internal server error before completing admission | ||
_, _, err = e2e.Kubectl("create", "-f", buildPath, "-n", "pod-label") | ||
require.NoError(t, err) | ||
|
||
// Cleanup | ||
_, _, err = e2e.Kubectl("delete", "-f", buildPath, "-n", "pod-label") | ||
require.NoError(t, err) | ||
_, _, err = e2e.Kubectl("delete", "ns", "pod-label") | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
creationTimestamp: null | ||
name: test | ||
spec: | ||
containers: | ||
- image: nginx | ||
name: test | ||
resources: {} | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
status: {} |