mirror of
https://github.com/containers/podman.git
synced 2026-03-27 11:03:09 -04:00
Merge pull request #25842 from ygalblum/quadlet-exec-reload
Quadlet - Add support for adding ExecReload command
This commit is contained in:
@@ -139,6 +139,8 @@ const (
|
||||
KeyPull = "Pull"
|
||||
KeyReadOnly = "ReadOnly"
|
||||
KeyReadOnlyTmpfs = "ReadOnlyTmpfs"
|
||||
KeyReloadCmd = "ReloadCmd"
|
||||
KeyReloadSignal = "ReloadSignal"
|
||||
KeyRemapGid = "RemapGid" // deprecated
|
||||
KeyRemapUid = "RemapUid" // deprecated
|
||||
KeyRemapUidSize = "RemapUidSize" // deprecated
|
||||
@@ -256,6 +258,8 @@ var (
|
||||
KeyPull: true,
|
||||
KeyReadOnly: true,
|
||||
KeyReadOnlyTmpfs: true,
|
||||
KeyReloadCmd: true,
|
||||
KeyReloadSignal: true,
|
||||
KeyRemapGid: true,
|
||||
KeyRemapUid: true,
|
||||
KeyRemapUidSize: true,
|
||||
@@ -578,6 +582,10 @@ func ConvertContainer(container *parser.UnitFile, isUser bool, unitsInfoMap map[
|
||||
serviceStopCmd.Args[0] = fmt.Sprintf("-%s", serviceStopCmd.Args[0])
|
||||
service.AddCmdline(ServiceGroup, "ExecStopPost", serviceStopCmd.Args)
|
||||
|
||||
if err := handleExecReload(container, service, ContainerGroup); err != nil {
|
||||
return nil, warnings, err
|
||||
}
|
||||
|
||||
podman := createBasePodmanCommand(container, ContainerGroup)
|
||||
|
||||
podman.add("run")
|
||||
@@ -2226,3 +2234,29 @@ func addDefaultDependencies(service *parser.UnitFile, isUser bool) {
|
||||
service.PrependUnitLine(UnitGroup, "Wants", networkUnit)
|
||||
}
|
||||
}
|
||||
|
||||
func handleExecReload(quadletUnitFile, serviceUnitFile *parser.UnitFile, groupName string) error {
|
||||
reloadSignal, signalOk := quadletUnitFile.Lookup(groupName, KeyReloadSignal)
|
||||
signalOk = signalOk && len(reloadSignal) > 0
|
||||
reloadcmd, cmdOk := quadletUnitFile.LookupLastArgs(groupName, KeyReloadCmd)
|
||||
cmdOk = cmdOk && len(reloadcmd) > 0
|
||||
|
||||
if !cmdOk && !signalOk {
|
||||
return nil
|
||||
}
|
||||
|
||||
if cmdOk && signalOk {
|
||||
return fmt.Errorf("%s and %s are mutually exclusive but both are set", KeyReloadCmd, KeyReloadSignal)
|
||||
}
|
||||
|
||||
serviceReloadCmd := createBasePodmanCommand(quadletUnitFile, groupName)
|
||||
if cmdOk {
|
||||
serviceReloadCmd.add("exec", "--cidfile=%t/%N.cid")
|
||||
serviceReloadCmd.add(reloadcmd...)
|
||||
} else {
|
||||
serviceReloadCmd.add("kill", "--cidfile=%t/%N.cid", "--signal", reloadSignal)
|
||||
}
|
||||
serviceUnitFile.AddCmdline(ServiceGroup, "ExecReload", serviceReloadCmd.Args)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user