Repository navigation
feat(actuator): inject plain and secret environment variables from component snapshots - #803
Conversation
There was a problem hiding this comment.
Code Review
This pull request extends the actuator's configuration injection by adding support for secret environment variables and secret volume mounts from component custom resources into JobSet containers. It also includes volume name sanitization, collision deduplication, and updated documentation and tests. The feedback suggests optimizing performance by moving the construction of component environment variables outside the loop in injectAccessIntoJobSet and adding a defensive nil check for podSpec in buildSecretVolumeMounts to prevent potential nil pointer dereferences.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request enhances the actuator's configuration injection by adding support for secret environment variables and secret volume mounts into JobSet containers, complete with volume name sanitization, deduplication, conflict protection, updated documentation, and unit tests. The review feedback suggests adding a defensive check to ensure volume mount paths are absolute to prevent Kubernetes API server rejection, and pre-allocating slices for volume mounts and environment variables to optimize performance.
2aced12 to
5d09355
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request expands the access configuration injection in the actuator to support secret environment variables (via secretKeyRef) and secret volume mounts. It introduces robust handling for volume name sanitization, volume deduplication for shared secrets, and conflict protection to avoid overwriting existing mounts. Comprehensive unit tests and documentation updates have been added to verify and describe these new features. There are no review comments to address, and I have no additional feedback to provide.
5d09355 to
4222803
Compare
4222803 to
758b5f7
Compare
758b5f7 to
5681706
Compare
5681706 to
1a86bc8
Compare
1a86bc8 to
6c2c68c
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request expands the configuration injection capabilities of the Actuator daemon. In addition to plain environment variables, it now supports injecting secret environment variables (via valueFrom.secretKeyRef) and mounting Kubernetes Secrets as read-only volumes into all primary and init containers of a JobSet. It includes volume name sanitization to RFC 1123 standards, deduplication of shared secret volumes, and conflict protection for existing mounts. Extensive unit tests and documentation updates have been added to cover these new features. I have no additional feedback to provide as there are no review comments.
6c2c68c to
03926bb
Compare
32aaf7b to
88967dc
Compare
88967dc to
304a242
Compare
There was a problem hiding this comment.
some logging (at least at debug level) would be nice...
The merge-base changed after approval.
304a242 to
8703f41
Compare
|
Added structured debug-level logging in
Kept logging strictly bounded to |
fefb391 to
0336c17
Compare
The merge-base changed after approval.
0336c17 to
aae359c
Compare
…mponent snapshots Extract plain environment variables (status.access.envVars) and secret environment variables (status.access.secretEnvVars) from resolved Component custom resources and inject them across primary containers and initContainers in all JobSet replicatedJobs. Secret environment variables are resolved into corev1.SecretKeyRef selectors pointing to the target secret and key. TAG=agy CONV=a22ce4d3-ff57-4515-bf2f-e810b9aec5ce
Add structured debug-level logging when evaluating component snapshots, injecting environment variables, and falling back to the default components namespace, avoiding excessive log spam by logging once per component. TAG=agy CONV=a22ce4d3-ff57-4515-bf2f-e810b9aec5ce
aae359c to
e5115e6
Compare
There was a problem hiding this comment.
🤖 Incremental PR Approval
Clean rebase detected with zero semantic patch lines changed.
Preserving prior approval by @AntonTyb on commit 0336c17.
Summary
Layer 2 of the component snapshot injection stack: resolves plain (
status.access.envVars) and secret (status.access.secretEnvVars) environment variables from resolved Component custom resources and injects them across primary and init containers in all JobSet replicatedJobs.Motivation & Context
Following Layer 1's snapshot discovery and placement gating (PR #802), WorkUnits requiring platform components need their operational configurations and credentials passed through container environment variables.
This is Layer 2 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, implementedextractComponentAccessto extractenvVarsandsecretEnvVarsmaps from the Component CR'sstatus.access.buildPlainEnvVarstransforms key-value pairs into deterministic, sortedcorev1.EnvVarentries.buildSecretEnvVarsparses declarations in"<secret_name>:<key>"format and createscorev1.EnvVarentries withValueFrom.SecretKeyRef. Malformed declarations without valid secret/key delimiters are skipped gracefully.injectAccessIntoJobSetinjects environment variables into all containers (podSpec.ContainersandpodSpec.InitContainers) across all replicated jobs, updating existing entries in place.cmd/actuator/README.mdwith environment variable injection details.Assumptions
secretEnvVarsare managed by the component operator and exist in the WorkUnit's namespace.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_EnvVars_Injection: Verifies injection of both plain and secret env vars across containers.TestConstructJobSet_ComponentSnapshot_EnvVars_UpdateExisting: Verifies updating existing env vars in place.TestConstructJobSet_ComponentSnapshot_AccessExtraction_Error: Verifies error propagation on malformed status.access structures.TestConstructJobSet_ComponentSnapshot_EmptyAccess: Verifies clean no-op handling when status.access is nil or empty.TestExtractStringMap_Types: Tests robust scalar string conversion.TestBuildSecretEnvVars_EdgeCases: Verifies delimiter parsing edge cases.TestCreateWorkUnit_ComponentSnapshotInjection_EnvVars_Success: E2E client verification of JobSet creation and env var injection.tools/analyze_diff_size.py --base-ref feat/components-snapshot-discovery-gate-b548436694verified 141 production code lines (< 400), 262 test lines, 403 total code lines (< 1,000), and 6 doc lines (< 1,000)../.githooks/pre-commitpassed cleanly (buildifier, gofmt, golangci-lint, determinism, addlicense).TAG=agy
CONV=a22ce4d3-ff57-4515-bf2f-e810b9aec5ce