Skip to content

Commit ca01c09

Browse files
committed
feat(api): add ImpVM.spec.snapshotRef for snapshot-based boot
1 parent 84c120f commit ca01c09

6 files changed

Lines changed: 67 additions & 2 deletions

File tree

api/v1alpha1/impvm_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ type ImpVMSpec struct {
5151
// +optional
5252
NodeName string `json:"nodeName,omitempty"`
5353

54+
// SnapshotRef names the child ImpVMSnapshot execution to restore this VM from.
55+
// When set, the agent configures Firecracker to boot from the snapshot files
56+
// rather than a fresh image. The snapshot must be in the same namespace as the VM.
57+
// Used by ImpWarmPool (pool members boot from elected base snapshot) and
58+
// ImpVMMigration (target VM restores source VM state).
59+
// +optional
60+
SnapshotRef string `json:"snapshotRef,omitempty"`
61+
5462
// NodeSelector constrains scheduling to nodes matching all labels.
5563
// Same semantics as Pod.spec.nodeSelector.
5664
// +optional

api/v1alpha1/impvm_types_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ func TestImpVMStatus_exhaustedAt(t *testing.T) {
7676
assert.Equal(t, int32(5), out2.RestartCount)
7777
}
7878

79+
func TestImpVM_snapshotRef_roundTrip(t *testing.T) {
80+
vm := ImpVM{
81+
Spec: ImpVMSpec{
82+
Image: "busybox:latest",
83+
SnapshotRef: "snap-parent-20260306-120105",
84+
},
85+
}
86+
b, err := json.Marshal(vm)
87+
require.NoError(t, err)
88+
var out ImpVM
89+
require.NoError(t, json.Unmarshal(b, &out))
90+
assert.Equal(t, "snap-parent-20260306-120105", out.Spec.SnapshotRef)
91+
}
92+
7993
func TestRestartPolicy_roundTrip(t *testing.T) {
8094
rp := RestartPolicy{
8195
Mode: "reschedule",

api/v1alpha1/shared_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const (
44
// LabelSnapshotParent is the label key on child ImpVMSnapshot execution objects
55
// that identifies their parent ImpVMSnapshot (the schedule/config object).
66
LabelSnapshotParent = "imp.dev/snapshot-parent"
7+
8+
// LabelWarmPool is the label key applied to ImpVM objects that belong to a warm pool.
9+
LabelWarmPool = "imp.dev/warm-pool"
710
)
811

912
// LocalObjectRef is a reference to an object in the same namespace.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/imp.dev_impvms.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,14 @@ spec:
539539
- cool-down
540540
type: string
541541
type: object
542+
snapshotRef:
543+
description: |-
544+
SnapshotRef names the child ImpVMSnapshot execution to restore this VM from.
545+
When set, the agent configures Firecracker to boot from the snapshot files
546+
rather than a fresh image. The snapshot must be in the same namespace as the VM.
547+
Used by ImpWarmPool (pool members boot from elected base snapshot) and
548+
ImpVMMigration (target VM restores source VM state).
549+
type: string
542550
templateRef:
543551
description: TemplateRef references an ImpVMTemplate. Mutually exclusive
544552
with ClassRef.

config/crd/bases/imp.dev_impwarmpools.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ spec:
6666
format: int32
6767
type: integer
6868
snapshotRef:
69-
description: SnapshotRef names the ImpVMSnapshot to boot pool members
70-
from.
69+
description: |-
70+
SnapshotRef names the ImpVMSnapshot parent to boot pool members from.
71+
The pool controller uses status.baseSnapshot on the referenced object
72+
to resolve the elected execution artifact. The pool stays idle until
73+
a base snapshot has been elected via `kubectl imp elect`.
7174
type: string
7275
templateName:
7376
description: TemplateName is the ImpVMTemplate used to create pool

0 commit comments

Comments
 (0)