Add Downward API volume fieldRef support for pod metadata files#530
Conversation
✅ Deploy Preview for interlink-dev canceled.
|
Agent-Logs-Url: https://github.com/interlink-hq/interLink/sessions/966b79b9-f6b2-4041-8aba-bfb574abeab5 Co-authored-by: dciangot <4144326+dciangot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/interlink-hq/interLink/sessions/966b79b9-f6b2-4041-8aba-bfb574abeab5 Co-authored-by: dciangot <4144326+dciangot@users.noreply.github.com>
|
@copilot lint action is failing |
Agent-Logs-Url: https://github.com/interlink-hq/interLink/sessions/f88fe7ab-00db-421c-93d7-5a24efd018c8 Co-authored-by: dciangot <4144326+dciangot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/interlink-hq/interLink/sessions/f88fe7ab-00db-421c-93d7-5a24efd018c8 Co-authored-by: dciangot <4144326+dciangot@users.noreply.github.com>
Fixed. The lint failure was due to staticcheck QF1012 in |
There was a problem hiding this comment.
Pull request overview
This PR extends InterLink’s Downward API handling for volume-mounted metadata files by resolving additional fieldRef paths and adding support for direct volumes[].downwardAPI (not only projected sources). It also makes label/annotation rendering deterministic to avoid non-reproducible output from map iteration.
Changes:
- Refactors Downward API volume item processing into shared helpers and adds support for more
fieldRefpaths (incl. labels/annotations, node/service account, pod/host IPs). - Adds handling for direct
DownwardAPIvolumes inremoteExecutionHandleVolumesby populatingProjectedVolumeMaps. - Adds unit tests covering the new field paths and the direct
downwardAPIvolume path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pkg/virtualkubelet/execute.go |
Adds shared Downward API resolution helpers and new handling for direct DownwardAPI volumes. |
pkg/virtualkubelet/execute_test.go |
Adds tests for the expanded fieldRef mapping and direct downwardAPI volumes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Diego Ciangottini <diego.ciangottini@gmail.com>
| case volume.DownwardAPI != nil: | ||
| projectedVolume := v1.ConfigMap{ | ||
| ObjectMeta: metav1.ObjectMeta{Name: volume.Name}, | ||
| Data: make(map[string]string), | ||
| } | ||
| log.G(ctx).Debug("Adding to PodCreateRequests the downwardAPI volume ", volume.Name) | ||
|
|
| require.Len(t, req.ProjectedVolumeMaps, 1) | ||
| assert.Equal(t, "podinfo", req.ProjectedVolumeMaps[0].Name) | ||
| assert.Equal(t, "test-pod", req.ProjectedVolumeMaps[0].Data["pod-name"]) | ||
| assert.Equal(t, "app=\"demo\"\n", req.ProjectedVolumeMaps[0].Data["labels"]) | ||
| assert.Equal(t, "a=\"b\"\n", req.ProjectedVolumeMaps[0].Data["annotations"]) |
InterLink already resolved Downward API
fieldReffor env vars, but volume-based Downward API metadata files were incomplete. This PR extends volume handling so pods can mount metadata files from both projected and directdownwardAPIvolumes with Kubernetes-standard field paths.Downward API field path coverage
metadata.name,metadata.namespace,metadata.uidmetadata.labels,metadata.annotationsspec.nodeName,spec.serviceAccountNamestatus.podIP,status.hostIPDirect
downwardAPIvolume supportvolumes[].downwardAPIinremoteExecutionHandleVolumes(previously onlyprojectedsources were handled for this path).ProjectedVolumeMapsfor downstream execution in the same way as other projected sources.Deterministic metadata file rendering
metadata.labels/metadata.annotationsas newline-delimitedkey="value"entries with sorted keys for deterministic output.Targeted unit coverage
downwardAPIvolumes