forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves all of the ignitionfiles out of the `machine` package and into its own called `ignition`. This required `VMType` to get moved out of the `machine` package and into the `define` package in order to prevent a circular dependency. Signed-off-by: Jake Correnti <[email protected]>
- Loading branch information
1 parent
de797e5
commit c728eeb
Showing
33 changed files
with
259 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import ( | |
"github.com/containers/podman/v4/pkg/machine/define" | ||
"github.com/containers/podman/v4/pkg/machine/sockets" | ||
"github.com/containers/podman/v4/pkg/machine/vmconfigs" | ||
"github.com/containers/podman/v4/pkg/machine/ignition" | ||
"github.com/containers/podman/v4/pkg/strongunits" | ||
"github.com/containers/podman/v4/pkg/util" | ||
"github.com/containers/podman/v4/utils" | ||
|
@@ -36,7 +37,7 @@ import ( | |
|
||
var ( | ||
// vmtype refers to qemu (vs libvirt, krun, etc). | ||
vmtype = machine.AppleHvVirt | ||
vmtype = define.AppleHvVirt | ||
) | ||
|
||
const ( | ||
|
@@ -160,7 +161,7 @@ func (m *MacMachine) Init(opts machine.InitOptions) (bool, error) { | |
go callbackFuncs.CleanOnSignal() | ||
|
||
callbackFuncs.Add(m.ConfigPath.Delete) | ||
dataDir, err := machine.GetDataDir(machine.AppleHvVirt) | ||
dataDir, err := machine.GetDataDir(define.AppleHvVirt) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
@@ -254,11 +255,11 @@ func (m *MacMachine) Init(opts machine.InitOptions) (bool, error) { | |
callbackFuncs.Add(m.removeSSHKeys) | ||
} | ||
|
||
builder := machine.NewIgnitionBuilder(machine.DynamicIgnition{ | ||
builder := ignition.NewIgnitionBuilder(ignition.DynamicIgnition{ | ||
Name: opts.Username, | ||
Key: key, | ||
VMName: m.Name, | ||
VMType: machine.AppleHvVirt, | ||
VMType: define.AppleHvVirt, | ||
TimeZone: opts.TimeZone, | ||
WritePath: m.IgnitionFile.GetPath(), | ||
UID: m.UID, | ||
|
@@ -273,10 +274,10 @@ func (m *MacMachine) Init(opts machine.InitOptions) (bool, error) { | |
return false, err | ||
} | ||
|
||
builder.WithUnit(machine.Unit{ | ||
Enabled: machine.BoolToPtr(true), | ||
builder.WithUnit(ignition.Unit{ | ||
Enabled: ignition.BoolToPtr(true), | ||
Name: "ready.service", | ||
Contents: machine.StrToPtr(fmt.Sprintf(appleHVReadyUnit, "vsock")), | ||
Contents: ignition.StrToPtr(fmt.Sprintf(appleHVReadyUnit, "vsock")), | ||
}) | ||
builder.WithUnit(generateSystemDFilesForVirtiofsMounts(virtiofsMnts)...) | ||
|
||
|
@@ -786,7 +787,7 @@ func loadMacMachineFromJSON(fqConfigPath string) (*MacMachine, error) { | |
} | ||
|
||
func (m *MacMachine) jsonConfigPath() (string, error) { | ||
configDir, err := machine.GetConfDir(machine.AppleHvVirt) | ||
configDir, err := machine.GetConfDir(define.AppleHvVirt) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
@@ -817,7 +818,7 @@ func getVMInfos() ([]*machine.ListResponse, error) { | |
|
||
listEntry.Name = vm.Name | ||
listEntry.Stream = vm.ImageStream | ||
listEntry.VMType = machine.AppleHvVirt.String() | ||
listEntry.VMType = define.AppleHvVirt.String() | ||
listEntry.CPUs = vm.CPUs | ||
listEntry.Memory = vm.Memory * units.MiB | ||
listEntry.DiskSize = vm.DiskSize * units.GiB | ||
|
@@ -1014,7 +1015,7 @@ func (m *MacMachine) setupAPIForwarding(cmd gvproxy.GvproxyCommand) (gvproxy.Gvp | |
} | ||
|
||
func (m *MacMachine) dockerSock() (string, error) { | ||
dd, err := machine.GetDataDir(machine.AppleHvVirt) | ||
dd, err := machine.GetDataDir(define.AppleHvVirt) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
@@ -1023,7 +1024,7 @@ func (m *MacMachine) dockerSock() (string, error) { | |
|
||
func (m *MacMachine) forwardSocketPath() (*define.VMFile, error) { | ||
sockName := "podman.sock" | ||
path, err := machine.GetDataDir(machine.AppleHvVirt) | ||
path, err := machine.GetDataDir(define.AppleHvVirt) | ||
if err != nil { | ||
return nil, fmt.Errorf("Resolving data dir: %s", err.Error()) | ||
} | ||
|
@@ -1060,7 +1061,7 @@ func (m *MacMachine) isFirstBoot() (bool, error) { | |
} | ||
|
||
func (m *MacMachine) getIgnitionSock() (*define.VMFile, error) { | ||
dataDir, err := machine.GetDataDir(machine.AppleHvVirt) | ||
dataDir, err := machine.GetDataDir(define.AppleHvVirt) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -1087,7 +1088,7 @@ func (m *MacMachine) getRuntimeDir() (string, error) { | |
} | ||
|
||
func (m *MacMachine) userGlobalSocketLink() (string, error) { | ||
path, err := machine.GetDataDir(machine.AppleHvVirt) | ||
path, err := machine.GetDataDir(define.AppleHvVirt) | ||
if err != nil { | ||
logrus.Errorf("Resolving data dir: %s", err.Error()) | ||
return "", err | ||
|
@@ -1100,12 +1101,12 @@ func (m *MacMachine) isIncompatible() bool { | |
return m.UID == -1 | ||
} | ||
|
||
func generateSystemDFilesForVirtiofsMounts(mounts []machine.VirtIoFs) []machine.Unit { | ||
func generateSystemDFilesForVirtiofsMounts(mounts []machine.VirtIoFs) []ignition.Unit { | ||
// mounting in fcos with virtiofs is a bit of a dance. we need a unit file for the mount, a unit file | ||
// for automatic mounting on boot, and a "preparatory" service file that disables FCOS security, performs | ||
// the mkdir of the mount point, and then re-enables security. This must be done for each mount. | ||
|
||
var unitFiles []machine.Unit | ||
var unitFiles []ignition.Unit | ||
for _, mnt := range mounts { | ||
// Here we are looping the mounts and for each mount, we are adding two unit files | ||
// for virtiofs. One unit file is the mount itself and the second is to automount it | ||
|
@@ -1126,20 +1127,20 @@ Type=virtiofs | |
[Install] | ||
WantedBy=multi-user.target | ||
` | ||
virtiofsAutomount := machine.Unit{ | ||
Enabled: machine.BoolToPtr(true), | ||
virtiofsAutomount := ignition.Unit{ | ||
Enabled: ignition.BoolToPtr(true), | ||
Name: fmt.Sprintf("%s.automount", mnt.Tag), | ||
Contents: machine.StrToPtr(fmt.Sprintf(autoMountUnit, mnt.Target, mnt.Target)), | ||
Contents: ignition.StrToPtr(fmt.Sprintf(autoMountUnit, mnt.Target, mnt.Target)), | ||
} | ||
virtiofsMount := machine.Unit{ | ||
Enabled: machine.BoolToPtr(true), | ||
virtiofsMount := ignition.Unit{ | ||
Enabled: ignition.BoolToPtr(true), | ||
Name: fmt.Sprintf("%s.mount", mnt.Tag), | ||
Contents: machine.StrToPtr(fmt.Sprintf(mountUnit, mnt.Tag, mnt.Target)), | ||
Contents: ignition.StrToPtr(fmt.Sprintf(mountUnit, mnt.Tag, mnt.Target)), | ||
} | ||
|
||
// This "unit" simulates something like systemctl enable virtiofs-mount-prepare@ | ||
enablePrep := machine.Unit{ | ||
Enabled: machine.BoolToPtr(true), | ||
enablePrep := ignition.Unit{ | ||
Enabled: ignition.BoolToPtr(true), | ||
Name: fmt.Sprintf("virtiofs-mount-prepare@%s.service", mnt.Tag), | ||
} | ||
|
||
|
@@ -1163,8 +1164,8 @@ ExecStopPost=chattr +i / | |
[Install] | ||
WantedBy=remote-fs.target | ||
` | ||
virtioFSChattr := machine.Unit{ | ||
Contents: machine.StrToPtr(mountPrep), | ||
virtioFSChattr := ignition.Unit{ | ||
Contents: ignition.StrToPtr(mountPrep), | ||
Name: "[email protected]", | ||
} | ||
unitFiles = append(unitFiles, virtioFSChattr) | ||
|
Oops, something went wrong.