You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Client.CollectSnapshot documents concurrent calls as safe and independent, but snapshot agent runs share several Kubernetes resources and selectors:
Every run creates or updates the cluster-scoped aicr-node-reader ClusterRole and ClusterRoleBinding.
Cleanup from either run deletes those shared objects.
Non-ConfigMap outputs stage through the same aicr-snapshot ConfigMap in the namespace.
Pod discovery uses only app.kubernetes.io/name=aicr and selects the youngest matching pod, rather than a pod owned by the current Job.
Callers commonly use the same default Job and ServiceAccount names.
Impact
Overlapping SDK or CLI calls can overwrite RBAC subjects/rules, delete permissions while another Job is running, delete/recreate another run's Job, stream logs from the wrong pod, or retrieve another run's snapshot. DiscoverNetwork makes the shared ClusterRole rules configuration-dependent, increasing the race surface.
Start two CollectSnapshot calls against the same cluster and namespace.
Use different DiscoverNetwork values or let one run complete cleanup while the other is active.
Observe shared RBAC updates/deletion and ambiguous pod/ConfigMap selection.
Expected behavior
Each documented independent run must own and select only its Kubernetes resources and result data.
Acceptance criteria
Generate a run ID for every snapshot operation and apply it to Job, ServiceAccount, namespaced RBAC, cluster-scoped RBAC, staging ConfigMap, labels, and selectors.
Select pods by current Job ownership (controller-uid or equivalent), never the global application label alone.
Cleanup deletes only resources owned by that run.
Concurrent runs with different network-discovery settings cannot change one another's permissions.
A concurrency test overlaps two runs and proves correct logs, result bytes, and cleanup ownership.
Bug description
Client.CollectSnapshotdocuments concurrent calls as safe and independent, but snapshot agent runs share several Kubernetes resources and selectors:aicr-node-readerClusterRole and ClusterRoleBinding.aicr-snapshotConfigMap in the namespace.app.kubernetes.io/name=aicrand selects the youngest matching pod, rather than a pod owned by the current Job.Impact
Overlapping SDK or CLI calls can overwrite RBAC subjects/rules, delete permissions while another Job is running, delete/recreate another run's Job, stream logs from the wrong pod, or retrieve another run's snapshot.
DiscoverNetworkmakes the shared ClusterRole rules configuration-dependent, increasing the race surface.Evidence
aicr/pkg/client/v1/aicr.go
Lines 1440 to 1442 in 6cb3ab9
aicr/pkg/k8s/agent/types.go
Lines 22 to 23 in 6cb3ab9
aicr/pkg/k8s/agent/rbac.go
Lines 205 to 264 in 6cb3ab9
aicr/pkg/k8s/agent/deployer.go
Lines 100 to 121 in 6cb3ab9
aicr/pkg/snapshotter/agent.go
Lines 501 to 529 in 6cb3ab9
aicr/pkg/k8s/agent/wait.go
Lines 111 to 149 in 6cb3ab9
Reproduction
CollectSnapshotcalls against the same cluster and namespace.DiscoverNetworkvalues or let one run complete cleanup while the other is active.Expected behavior
Each documented independent run must own and select only its Kubernetes resources and result data.
Acceptance criteria
controller-uidor equivalent), never the global application label alone.Delivery sequence
main, resolve the outstanding requested changes/conflicts, and re-review it against its current head.AgentConfignaming/default semantics are final.