feat: add guest config injection and host nat wiring

This commit is contained in:
Harivansh Rathi 2026-04-08 19:43:20 +00:00
parent 28ca0219d9
commit a12f54ba5d
8 changed files with 332 additions and 6 deletions

View file

@ -20,6 +20,9 @@ func (d *Daemon) CreateMachine(ctx context.Context, req contracthost.CreateMachi
if err := validateArtifactRef(req.Artifact); err != nil {
return nil, err
}
if err := validateGuestConfig(req.GuestConfig); err != nil {
return nil, err
}
unlock := d.lockMachine(req.MachineID)
defer unlock()
@ -62,6 +65,17 @@ func (d *Daemon) CreateMachine(ctx context.Context, req contracthost.CreateMachi
if err := cloneFile(artifact.RootFSPath, systemVolumePath); err != nil {
return nil, err
}
removeSystemVolumeOnFailure := true
defer func() {
if !removeSystemVolumeOnFailure {
return
}
_ = os.Remove(systemVolumePath)
_ = os.RemoveAll(filepath.Dir(systemVolumePath))
}()
if err := injectGuestConfig(ctx, systemVolumePath, req.GuestConfig); err != nil {
return nil, err
}
spec, err := d.buildMachineSpec(req.MachineID, artifact, userVolumes, systemVolumePath)
if err != nil {
@ -140,6 +154,7 @@ func (d *Daemon) CreateMachine(ctx context.Context, req contracthost.CreateMachi
return nil, err
}
removeSystemVolumeOnFailure = false
clearOperation = true
return &contracthost.CreateMachineResponse{Machine: machineToContract(record)}, nil
}