Repository navigation
feat(actuator): inject secret volume mounts from component snapshots - #813
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for injecting secret volume mounts from component custom resources into JobSets, including volume definition, RFC 1123 sanitization, collision deduplication, and read-only container mounting. It also adds comprehensive unit tests and updates the README documentation. The feedback suggests optimizing the injection process by returning early if there are no environment variables or secret volume mounts to inject.
a7468a7 to
dbeb520
Compare
42154eb to
ebb1eac
Compare
ebb1eac to
d89ee6f
Compare
The merge-base changed after approval.
958ab71 to
8833154
Compare
8833154 to
686e20f
Compare
686e20f to
dfbad86
Compare
Extract secret volume mounts (status.access.secretVolumeMounts) from resolved Component custom resources and inject them as read-only volumes and volume mounts across all containers and initContainers in JobSet replicatedJobs. Volume names are sanitized to RFC 1123 compliant DNS subdomain labels and collisions across components are deduplicated with incremental numeric suffixes. TAG=agy CONV=a22ce4d3-ff57-4515-bf2f-e810b9aec5ce
…s are empty Return early if there are no plain env vars, secret env vars, or secret volume mounts to avoid unnecessary allocations and replicatedJobs loop iterations. TAG=agy CONV=a22ce4d3-ff57-4515-bf2f-e810b9aec5ce
… logging TAG=agy CONV=a22ce4d3-ff57-4515-bf2f-e810b9aec5ce
dfbad86 to
2a6d31a
Compare
There was a problem hiding this comment.
🤖 Incremental PR Approval
PR author is a code owner and changes since last approval (3 lines) are within the 10-line grace delta.
Preserving prior approval by @AntonTyb on commit d89ee6f.
Summary
Layer 3 of the component snapshot injection stack: resolves secret volume mounts (
status.access.secretVolumeMounts) from resolved Component custom resources and injects them as read-only volumes and volume mounts across all containers and initContainers in JobSet replicatedJobs.Motivation & Context
Following Layer 1 (snapshot discovery and placement gating) and Layer 2 (environment variable injection), components that supply files, credentials, or TLS certificates need them mounted onto container filesystems.
This is Layer 3 of a 3-PR stack (
gh-stack):status.access.envVarsand secret referencesstatus.access.secretEnvVarsviacorev1.SecretKeyRef).status.access.secretVolumeMounts) with RFC 1123 DNS subdomain sanitization and collision deduplication.Key Changes
cmd/actuator/k8s_client/component_injection.go, extractedsecretVolumeMountsfromstatus.access.sanitizeVolumeNameto ensure volume names only contain lowercase alphanumeric characters and hyphens, capped at 50 characters, with fallback to"secret-vol".getOrAddSecretVolumeto share volume definitions when multiple components reference the same Secret name, and disambiguate conflicting volume names with incremental numeric suffixes (secret-1,secret-2)./), attachesReadOnly: truevolume mounts to all containers (podSpec.ContainersandpodSpec.InitContainers), and deduplicates mounts with matching mount paths.cmd/actuator/README.mdwith secret volume mount injection details.Assumptions
MaxRestarts: 0,restartPolicy: Never/OnFailure) remains strictly enforced.Verification & Testing
bazel test //cmd/actuator/...executed and passed 100%://cmd/actuator:actuator_test(PASSED)//cmd/actuator/k8s_client:k8s_client_test(PASSED, 10/10 shards)//cmd/actuator/k8s_client/preconditions_validator:preconditions_validator_test(PASSED)//cmd/actuator/workunittaskhandler:workunittaskhandler_test(PASSED)TestConstructJobSet_ComponentSnapshot_SecretVolumeMounts: Verifies injection of secret volumes and read-only container mounts across components.TestBuildSecretVolumeMounts_InvalidSpecs: Verifies skipping relative mount paths, missing colons, or empty names.TestSanitizeVolumeName: Verifies RFC 1123 compliance, truncation, and fallback.TestGetOrAddSecretVolume_NameDisambiguation: Verifies sharing secret volumes and numeric suffix disambiguation.TestAppendVolumeMountIfNotPresent_Deduplication: Verifies deduplication of matching mount paths.TestCreateWorkUnit_ComponentSnapshotInjection_Volumes_Success: E2E client verification of JobSet creation with injected volume and mount.tools/analyze_diff_size.py --base-ref feat/components-snapshot-secrets-volumes-b548436694verified 102 production code lines (< 400), 214 test lines, 316 total code lines (< 1,000), and 8 doc lines (< 1,000). Dedicated test suite incomponent_injection_test.gomaintained../.githooks/pre-commitpassed cleanly (buildifier, gofmt, golangci-lint, determinism, addlicense).TAG=agy
CONV=a22ce4d3-ff57-4515-bf2f-e810b9aec5ce