Skip to content

Commit cc9a7a8

Browse files
committed
feat(api): ImpVMSnapshot — NodeLocalSpec, BaseSnapshot election, TerminatedAt, retention bounds
1 parent 06615fc commit cc9a7a8

2 files changed

Lines changed: 87 additions & 2 deletions

File tree

api/v1alpha1/impvmsnapshot_types.go

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,22 @@ type ImpVMSnapshotSpec struct {
1818
// +optional
1919
Schedule string `json:"schedule,omitempty"`
2020

21-
// Retention is the number of completed snapshots to keep (oldest pruned first).
21+
// Retention is the number of completed executions to keep (oldest pruned first).
2222
// +optional
2323
// +kubebuilder:default=3
24+
// +kubebuilder:validation:Minimum=1
25+
// +kubebuilder:validation:Maximum=10
2426
Retention int32 `json:"retention,omitempty"`
2527

2628
// Storage defines where the snapshot artifact is persisted.
2729
Storage SnapshotStorageSpec `json:"storage"`
30+
31+
// BaseSnapshot pins a specific child execution as the elected base image.
32+
// Set declaratively or via `kubectl imp elect`.
33+
// Consumers (ImpWarmPool, ImpVMMigration) use this as their boot source.
34+
// The operator validates the named child exists and has phase=Succeeded.
35+
// +optional
36+
BaseSnapshot string `json:"baseSnapshot,omitempty"`
2837
}
2938

3039
// SnapshotStorageSpec configures snapshot artifact storage.
@@ -33,12 +42,25 @@ type SnapshotStorageSpec struct {
3342
// +kubebuilder:validation:Enum=node-local;oci-registry
3443
Type string `json:"type"`
3544

45+
// NodeLocal configures node-local artifact storage.
46+
// Required when Type is "node-local".
47+
// +optional
48+
NodeLocal *NodeLocalSpec `json:"nodeLocal,omitempty"`
49+
3650
// OCIRegistry configures an OCI registry destination.
3751
// Required when Type is "oci-registry".
3852
// +optional
3953
OCIRegistry *OCIRegistrySpec `json:"ociRegistry,omitempty"`
4054
}
4155

56+
// NodeLocalSpec configures node-local snapshot storage.
57+
type NodeLocalSpec struct {
58+
// Path is the base directory for snapshot artifacts on the node.
59+
// Supports remotely-mounted paths (NFS, etc.).
60+
// +kubebuilder:default="/var/lib/imp/snapshots"
61+
Path string `json:"path,omitempty"`
62+
}
63+
4264
// OCIRegistrySpec configures OCI registry access for snapshot storage.
4365
type OCIRegistrySpec struct {
4466
// Repository is the full image reference prefix
@@ -72,6 +94,21 @@ type ImpVMSnapshotStatus struct {
7294
// +optional
7395
NextScheduledAt *metav1.Time `json:"nextScheduledAt,omitempty"`
7496

97+
// LastExecutionRef is the most recently created child execution object.
98+
// +optional
99+
LastExecutionRef *corev1.LocalObjectReference `json:"lastExecutionRef,omitempty"`
100+
101+
// BaseSnapshot mirrors spec.baseSnapshot once the referenced child is
102+
// validated as Succeeded. Consumers read this field only.
103+
// +optional
104+
BaseSnapshot string `json:"baseSnapshot,omitempty"`
105+
106+
// TerminatedAt is set by the agent once the execution reaches a terminal
107+
// state (Succeeded or Failed) and all cleanup is complete.
108+
// The operator uses this — not phase alone — to gate new execution creation.
109+
// +optional
110+
TerminatedAt *metav1.Time `json:"terminatedAt,omitempty"`
111+
75112
// Conditions follow the standard k8s condition convention.
76113
// +optional
77114
// +listType=map

config/crd/bases/imp.dev_impvmsnapshots.yaml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,20 @@ spec:
5858
spec:
5959
description: ImpVMSnapshotSpec defines the desired snapshot.
6060
properties:
61+
baseSnapshot:
62+
description: |-
63+
BaseSnapshot pins a specific child execution as the elected base image.
64+
Set declaratively or via `kubectl imp elect`.
65+
Consumers (ImpWarmPool, ImpVMMigration) use this as their boot source.
66+
The operator validates the named child exists and has phase=Succeeded.
67+
type: string
6168
retention:
6269
default: 3
63-
description: Retention is the number of completed snapshots to keep
70+
description: Retention is the number of completed executions to keep
6471
(oldest pruned first).
6572
format: int32
73+
maximum: 10
74+
minimum: 1
6675
type: integer
6776
schedule:
6877
description: |-
@@ -78,6 +87,18 @@ spec:
7887
storage:
7988
description: Storage defines where the snapshot artifact is persisted.
8089
properties:
90+
nodeLocal:
91+
description: |-
92+
NodeLocal configures node-local artifact storage.
93+
Required when Type is "node-local".
94+
properties:
95+
path:
96+
default: /var/lib/imp/snapshots
97+
description: |-
98+
Path is the base directory for snapshot artifacts on the node.
99+
Supports remotely-mounted paths (NFS, etc.).
100+
type: string
101+
type: object
81102
ociRegistry:
82103
description: |-
83104
OCIRegistry configures an OCI registry destination.
@@ -123,6 +144,11 @@ spec:
123144
status:
124145
description: ImpVMSnapshotStatus reflects the observed state.
125146
properties:
147+
baseSnapshot:
148+
description: |-
149+
BaseSnapshot mirrors spec.baseSnapshot once the referenced child is
150+
validated as Succeeded. Consumers read this field only.
151+
type: string
126152
completedAt:
127153
description: CompletedAt is the time the last snapshot completed.
128154
format: date-time
@@ -191,6 +217,21 @@ spec:
191217
description: Digest is the OCI digest of the produced artifact (oci-registry
192218
only).
193219
type: string
220+
lastExecutionRef:
221+
description: LastExecutionRef is the most recently created child execution
222+
object.
223+
properties:
224+
name:
225+
default: ""
226+
description: |-
227+
Name of the referent.
228+
This field is effectively required, but due to backwards compatibility is
229+
allowed to be empty. Instances of this type with an empty value here are
230+
almost certainly wrong.
231+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
232+
type: string
233+
type: object
234+
x-kubernetes-map-type: atomic
194235
nextScheduledAt:
195236
description: NextScheduledAt is when the next scheduled snapshot will
196237
run.
@@ -203,6 +244,13 @@ spec:
203244
description: SnapshotPath is the node-local path of the snapshot artifact
204245
(node-local only).
205246
type: string
247+
terminatedAt:
248+
description: |-
249+
TerminatedAt is set by the agent once the execution reaches a terminal
250+
state (Succeeded or Failed) and all cleanup is complete.
251+
The operator uses this — not phase alone — to gate new execution creation.
252+
format: date-time
253+
type: string
206254
type: object
207255
type: object
208256
served: true

0 commit comments

Comments
 (0)