Skip to content

feat(operator): create Snapshot from DynamoCheckpoint controller#2

Merged
Ronkahn21 merged 3 commits into
feat/snapshot-crdfrom
feat/snapshot-crd-b-operator
Jun 11, 2026
Merged

feat(operator): create Snapshot from DynamoCheckpoint controller#2
Ronkahn21 merged 3 commits into
feat/snapshot-crdfrom
feat/snapshot-crd-b-operator

Conversation

@Ronkahn21

Copy link
Copy Markdown
Owner

Overview:

Component B of the DynamoCheckpoint → Snapshot/SnapshotContent migration. The DynamoCheckpoint controller now creates a Snapshot (the Component A CRD) for each checkpoint, once the source pod exists. This is the new authoritative capture record — required, not best-effort. The existing Job/Lease/agent flow and the restore path are unchanged.

Internal staging PR into the base branch feat/snapshot-crd.

Details:

  • In handleCreating (after the Job is fetched, before the Lease/observation): find the Job's source pod, then create the Snapshot.
  • findSourcePod — selects the pod by Job ownership (batchv1.JobNameLabel + metav1.IsControlledBy); returns a standard NotFound when the pod isn't created yet, so the caller client.IgnoreNotFounds and requeues.
  • ensureSnapshot — if a Snapshot already exists and is owned by this checkpoint, no-op; otherwise create it via Server-Side Apply (client.Apply + field owner + force-ownership) with the DynamoCheckpoint as controller owner. Named snapshot-<checkpointID>, spec.checkpointID + spec.source.podRef.name set. Empty-UID guard. A foreign-owned name collision returns Forbidden (terminal).
  • Required semantics — terminal create error (IsInvalid/IsBadRequest/IsForbidden) fails the checkpoint (Phase=Failed, SnapshotCreateFailed); transient requeues. The checkpoint cannot reach Ready without its Snapshot.
  • Owner-ref: this phase only — the checkpoint owns the Snapshot for now (GC); the long-term design will not couple them.
  • RBACsnapshots added to the operator's combined nvidia.com rule in config/rbac/role.yaml and the helm manager-rbac.yaml (no kubebuilder markers).

Verification (in-sandbox): go build ./..., go vet, fake-client tests pass (TestFindSourcePod*, TestEnsureSnapshot*, TestFailOrRequeueSnapshot*, and the existing HandleCreating/Reconcile/FinalizeResource suites updated to seed the Job-owned pod). CodeRabbit: no findings.

Where should the reviewer start?

  • deploy/operator/internal/controller/checkpoint_snapshot.go
  • deploy/operator/internal/controller/dynamocheckpoint_controller.go (the new block in handleCreating)

Related Issues

🚫 This PR is NOT linked to an issue:

  • Confirmed — no related issue (internal staging PR into the migration base branch)

Once the checkpoint Job's source pod exists, the DynamoCheckpoint
controller creates a Snapshot (nvidia.com/v1alpha1) owned by the
checkpoint via Server-Side Apply, naming it snapshot-<checkpointID> and
referencing the source pod. Snapshot creation is a required step of the
new capture path: a terminal error fails the checkpoint, a transient one
requeues, and the checkpoint cannot reach Ready without it. Source pod
is found by Job ownership. RBAC for snapshots added to the operator role
(kustomize + helm). Restore path and the Job/Lease flow are unchanged.

Signed-off-by: Ron Kahn <rkahn@nvidia.com>
Comment thread deploy/operator/internal/controller/checkpoint_snapshot.go Outdated
Comment thread deploy/operator/internal/controller/dynamocheckpoint_controller_test.go Outdated
Comment thread deploy/operator/internal/controller/checkpoint_snapshot.go
Comment thread deploy/operator/internal/controller/checkpoint_snapshot.go Outdated
Comment thread deploy/operator/internal/controller/checkpoint_snapshot.go Outdated
Comment thread deploy/operator/internal/controller/dynamocheckpoint_controller.go Outdated
Address PR review: add controller_common.IgnoreIntermediateError (err for
terminal API errors, nil for transient) mirroring client.IgnoreNotFound;
remove failOrRequeueSnapshot and inline the terminal/transient decision in
handleCreating with a focused updateFailedStatus helper (no encapsulated
status update); move the checkpoint UID validation out of ensureSnapshot to
handleCreating; emit a SnapshotCreateFailed event at the point of failure in
ensureSnapshot; add a podNameFromJob test helper.

Signed-off-by: Ron Kahn <rkahn@nvidia.com>
Comment thread deploy/operator/internal/controller/checkpoint_snapshot.go
Comment thread deploy/operator/internal/controller/dynamocheckpoint_controller.go Outdated
Address PR review: split ensureSnapshot into findOwnedSnapshot /
buildSnapshot / applySnapshot helpers with a thin orchestrator; remove the
ckpt.UID guard in handleCreating (a checkpoint from the API server always has
a UID, so the case cannot happen).

Signed-off-by: Ron Kahn <rkahn@nvidia.com>
@Ronkahn21 Ronkahn21 merged commit 6b5bfbc into feat/snapshot-crd Jun 11, 2026
13 of 17 checks passed
@Ronkahn21 Ronkahn21 deleted the feat/snapshot-crd-b-operator branch June 11, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant