Forward workload identity to volume drivers via mount config - #1191
Conversation
Rep already knows the authoritative workload identity (process GUID for LRPs, task GUID for Tasks) at the moment it calls volumeManager.Mount, but does not forward it to the volume driver. Volume drivers that validate a mount against the workload's service bindings therefore have to reconstruct that identity out-of-band, which is slow and requires elevated privileges. Enrich the mount config map with the workload identity before calling Mount: _workload_guid: process_guid (LRP) or task_guid (Task) _workload_type: "lrp" or "task" The change is additive and backward-compatible: the original config map is not mutated, containers without a lifecycle tag are unaffected, and drivers that do not read the keys ignore them. The underscore prefix distinguishes these injected keys from broker-supplied config. Signed-off-by: Viktor-Velkov <viktor.velkov@sap.com>
geofffranks
left a comment
There was a problem hiding this comment.
Thanks! Can you fix a couple things with this?
2. storenode.go:312 / containerstore_test.go:824 — Existing tests pass only because mock containers omit tags entirely. No integration test verifies that containerStore.Create actually passes the enriched map to volumeManager.Mount for tagged LRP/Task containers. — minor
2. storenode.go:337-353 — Hardcoded string literals ("lifecycle", "lrp", "task", "process-guid") duplicate constants already defined in rep (rep.LifecycleTag, etc.). Share the constants to make the coupling explicit. — minor
3. workload_identity_test.go:70-85 — Missing test case for an unrecognized lifecycle tag value (e.g., lifecycle: "other"). — minor
Cover the two gaps raised in review of the workload-identity mount change: - containerstore_test.go: assert containerStore.Create forwards the enriched mount config (_workload_guid/_workload_type) to volumeManager.Mount for tagged LRP and Task containers. The existing volume-mount specs passed only because their mock containers omitted tags, so the enrichment path was never exercised end-to-end. - workload_identity_test.go: add a case for an unrecognized lifecycle tag value, asserting no identity keys are injected, the config is preserved, and the original map is not mutated. Signed-off-by: Viktor-Velkov <viktor.velkov@sap.com>
|
Thanks for the review! Pushed a commit addressing points 1 and 3:
On (2) — sharing the constants — I hit a snag and wanted your call before implementing. The tag-key constants (
Do you have a preference? I'm inclined toward (a) for the explicit coupling you're after, but it's a slightly broader change so wanted to check first. |
|
Yeah let's go with option A. I ran a followup review thoguh and it had these new findings: |
Address the follow-up review: - Define the shared container tag keys and lifecycle values (LifecycleTag, ProcessGuidTag, LRPLifecycle, TaskLifecycle) plus the injected keys (WorkloadGuidKey, WorkloadTypeKey) in the executor package, the layer rep already depends on, and alias rep's existing constants to them. This gives a single source of truth without an import cycle (rep imports executor, not the reverse). - Restructure injectWorkloadIdentity around a single switch with a default that returns the config unchanged, and guard against an empty workload GUID. Unrecognized lifecycle values and nil configs now behave identically to the no-lifecycle-tag path (returning the original map, which may be nil) instead of allocating an empty map. - Replace the hardcoded key/value literals in the production and test code with the shared constants. - Extend the tests: the Task integration test now asserts both mount calls and that base config keys are preserved; the nil-config block covers Task, no-lifecycle, and unrecognized-lifecycle cases; and an LRP with an empty process-guid is covered. Signed-off-by: Viktor-Velkov <viktor.velkov@sap.com>
|
Thanks! Went with option A and addressed the follow-up review — pushed as a new commit ( Shared constants (option A)Defined the tag keys and lifecycle values ( Correctness
Cleanup
VerificationFull The one red spec — |
Summary
Rep already knows the authoritative workload identity (process GUID for LRPs, task GUID for Tasks) at the moment it calls
volumeManager.Mount, but does not forward it to the volume driver. Volume drivers that validate a mount against the workload's service bindings therefore have to reconstruct that identity out-of-band (e.g. acfdot actual-lrps --cell-idcell-wide scan followed by a DesiredLRP fetch), which is slow (~1–2s typical, seconds under load) and requiressudo+ shell tooling on the cell.This PR enriches the mount
configmap with the workload identity Rep already holds, before callingMount:_workload_guid—process_guid(LRP) ortask_guid(Task)_workload_type—"lrp"or"task"No protocol change is required — the keys ride the existing
configmap, which the Docker plugin'sCreatecall already forwards to the driver. A binding-validating driver can then read the identity directly instead of reconstructing it.Backward compatibility
Breaking change? No. The change is additive:
configmap is not mutated (a copy is enriched);lifecycletag are returned unchanged;Tests
containerstoremount tests continue to pass.Related
Design discussion (cross-component contract, alternatives considered): #1192