8000 feat(actuator): inject secret volume mounts from component snapshots by VLukiantsev · Pull Request #813 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

feat(actuator): inject secret volume mounts from component snapshots - #813

Merged
VLukiantsev merged 3 commits into
feat/components-snapshot-secrets-volumes-b548436694from
feat/components-snapshot-volumes-b548436694
Sep 8, 2026
Merged

VLukiantsev merged 3 commits into
feat/components-snapshot-secrets-volumes-b548436694from
feat/components-snapshot-volumes-b548436694

Conversation

@VLukiantsev
@VLukiantsev VLukiantsev commented Sep 7, 2026 •
Copy link
Copy Markdown
Collaborator

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):

Key Changes

  • Volume Mount Extraction: In cmd/actuator/k8s_client/component_injection.go, extracted secretVolumeMounts from status.access.
  • RFC 1123 DNS Subdomain Sanitization: Implemented sanitizeVolumeName to ensure volume names only contain lowercase alphanumeric characters and hyphens, capped at 50 characters, with fallback to "secret-vol".
  • Collision Deduplication & Disambiguation: Implemented getOrAddSecretVolume to share volume definitions when multiple components reference the same Secret name, and disambiguate conflicting volume names with incremental numeric suffixes (secret-1, secret-2).
  • Path Validation & Deduplication: Validates that mount paths are absolute (prefixed with /), attaches ReadOnly: true volume mounts to all containers (podSpec.Containers and podSpec.InitContainers), and deduplicates mounts with matching mount paths.
  • Documentation: Updated cmd/actuator/README.md with secret volume mount injection details.

Assumptions

  • Target secrets are provisioned in the WorkUnit's namespace by the respective component operator or credentials broker.
  • Non-restarting JobSets contract (MaxRestarts: 0, restartPolicy: Never/OnFailure) remains strictly enforced.

Verification & Testing

  • Bazel Test Matrix: 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)
  • Unit & E2E Tests:
    • 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.
  • Diff Sizing Check: tools/analyze_diff_size.py --base-ref feat/components-snapshot-secrets-volumes-b548436694 verified 102 production code lines (< 400), 214 test lines, 316 total code lines (< 1,000), and 8 doc lines (< 1,000). Dedicated test suite in component_injection_test.go maintained.
  • Linters: ./.githooks/pre-commit passed cleanly (buildifier, gofmt, golangci-lint, determinism, addlicense).

TAG=agy
CONV=a22ce4d3-ff57-4515-bf2f-e810b9aec5ce

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@VLukiantsev
VLukiantsev force-pushed the feat/components-snapshot-volumes-b548436694 branch from a7468a7 to dbeb520 Compare September 7, 2026 16:54
@VLukiantsev
VLukiantsev force-pushed the feat/components-snapshot-volumes-b548436694 branch from 42154eb to ebb1eac Compare September 7, 2026 17:09
@VLukiantsev
VLukiantsev force-pushed the feat/components-snapshot-volumes-b548436694 branch from ebb1eac to d89ee6f Compare September 8, 2026 09:39
@VLukiantsev
VLukiantsev requested a review from AntonTyb September 8, 2026 10:31
@VLukiantsev
VLukiantsev marked this pull request as ready for review September 8, 2026 10:31
AntonTyb
AntonTyb previously approved these changes Sep 8, 2026
@VLukiantsev
VLukiantsev dismissed AntonTyb’s stale review September 8, 2026 11:07

The merge-base changed after approval.

@VLukiantsev
VLukiantsev force-pushed the feat/components-snapshot-volumes-b548436694 branch 2 times, most recently from 958ab71 to 8833154 Compare September 8, 2026 11:16
@VLukiantsev
VLukiantsev force-pushed the feat/components-snapshot-volumes-b548436694 branch from 8833154 to 686e20f Compare September 8, 2026 11:22
@VLukiantsev
VLukiantsev force-pushed the feat/components-snapshot-volumes-b548436694 branch from 686e20f to dfbad86 Compare September 8, 2026 12:53
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
@VLukiantsev
VLukiantsev force-pushed the feat/components-snapshot-volumes-b548436694 branch from dfbad86 to 2a6d31a Compare September 8, 2026 14:49
@github-actions github-actions Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

@VLukiantsev
VLukiantsev added this pull request to the merge queue Sep 8, 2026
Merged via the queue into main with commit afbfaa3 Sep 8, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0