mirror of https://github.com/containers/podman.git
generate systemd: drop support for remote clients
Drop the support for remote clients to generate systemd-service files. The generated files are machine-dependent and hence relate only to the a local machine. Furthermore, a proper service management when using a remote-client is not possible as systemd has no access to a process. Dropping the support will also reduce the risk of making users believe that the generated services are usable in a remote scenario. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
parent
1ad8fe5241
commit
a33e4a89ca
7
API.md
7
API.md
|
@ -49,8 +49,6 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
|
|||
|
||||
[func GenerateKube(name: string, service: bool) KubePodService](#GenerateKube)
|
||||
|
||||
[func GenerateSystemd(name: string, restart: string, timeout: int, useName: bool) string](#GenerateSystemd)
|
||||
|
||||
[func GetAttachSockets(name: string) Sockets](#GetAttachSockets)
|
||||
|
||||
[func GetContainer(id: string) Container](#GetContainer)
|
||||
|
@ -482,11 +480,6 @@ error will be returned. See also [ImportImage](ImportImage).
|
|||
method GenerateKube(name: [string](https://godoc.org/builtin#string), service: [bool](https://godoc.org/builtin#bool)) [KubePodService](#KubePodService)</div>
|
||||
GenerateKube generates a Kubernetes v1 Pod description of a Podman container or pod
|
||||
and its containers. The description is in YAML. See also [ReplayKube](ReplayKube).
|
||||
### <a name="GenerateSystemd"></a>func GenerateSystemd
|
||||
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
|
||||
|
||||
method GenerateSystemd(name: [string](https://godoc.org/builtin#string), restart: [string](https://godoc.org/builtin#string), timeout: [int](https://godoc.org/builtin#int), useName: [bool](https://godoc.org/builtin#bool)) [string](https://godoc.org/builtin#string)</div>
|
||||
|
||||
### <a name="GetAttachSockets"></a>func GetAttachSockets
|
||||
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
|
||||
|
||||
|
|
|
@ -18,11 +18,14 @@ var (
|
|||
// Commands that are universally implemented
|
||||
generateCommands = []*cobra.Command{
|
||||
_containerKubeCommand,
|
||||
_containerSystemdCommand,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Systemd-service generation is not supported for remote-clients.
|
||||
if !remoteclient {
|
||||
generateCommands = append(generateCommands, _containerSystemdCommand)
|
||||
}
|
||||
generateCommand.Command = _generateCommand
|
||||
generateCommand.AddCommand(generateCommands...)
|
||||
generateCommand.SetUsageTemplate(UsageTemplate())
|
||||
|
|
|
@ -1241,8 +1241,6 @@ method GetLayersMapWithImageInfo() -> (layerMap: string)
|
|||
# BuildImageHierarchyMap is for the development of Podman and should not be used.
|
||||
method BuildImageHierarchyMap(name: string) -> (imageInfo: string)
|
||||
|
||||
method GenerateSystemd(name: string, restart: string, timeout: int, useName: bool) -> (unit: string)
|
||||
|
||||
# ImageNotFound means the image could not be found by the provided name or ID in local storage.
|
||||
error ImageNotFound (id: string, reason: string)
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ podman-generate-systemd- Generate Systemd Unit file
|
|||
command will dynamically create the unit file and output it to stdout where it can be piped by the user
|
||||
to a file. The options can be used to influence the results of the output as well.
|
||||
|
||||
Note that this command is not supported for the remote client.
|
||||
|
||||
## OPTIONS:
|
||||
|
||||
|
|
|
@ -12,9 +12,10 @@ The generate command will create structured output (like YAML) based on a contai
|
|||
## COMMANDS
|
||||
|
||||
| Command | Man Page | Description |
|
||||
| ------- | --------------------------------------------------- | ---------------------------------------------------------------------------- |
|
||||
|---------|------------------------------------------------------------|------------------------------------------------------------------------------------|
|
||||
| kube | [podman-generate-kube(1)](podman-generate-kube.1.md) | Generate Kubernetes YAML based on a pod or container. |
|
||||
| systemd | [podman-generate-systemd(1)](podman-generate-systemd.1.md)| Generate a systemd unit file for a container. |
|
||||
| systemd | [podman-generate-systemd(1)](podman-generate-systemd.1.md) | Generate a systemd unit file for a container. Not supported for the remote client. |
|
||||
|
||||
|
||||
## SEE ALSO
|
||||
podman, podman-pod, podman-container
|
||||
|
|
|
@ -951,7 +951,7 @@ func (r *LocalRuntime) Port(c *cliconfig.PortValues) ([]*Container, error) {
|
|||
|
||||
// GenerateSystemd creates a systemd until for a container
|
||||
func (r *LocalRuntime) GenerateSystemd(c *cliconfig.GenerateSystemdValues) (string, error) {
|
||||
return iopodman.GenerateSystemd().Call(r.Conn, c.InputArgs[0], c.RestartPolicy, int64(c.StopTimeout), c.Name)
|
||||
return "", errors.New("systemd generation not supported for remote clients")
|
||||
}
|
||||
|
||||
// GetNamespaces returns namespace information about a container for PS
|
||||
|
|
|
@ -4,9 +4,9 @@ package varlinkapi
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/containers/libpod/cmd/podman/shared"
|
||||
iopodman "github.com/containers/libpod/cmd/podman/varlink"
|
||||
"github.com/containers/libpod/pkg/systemdgen"
|
||||
)
|
||||
|
||||
// GenerateKube ...
|
||||
|
@ -29,24 +29,3 @@ func (i *LibpodAPI) GenerateKube(call iopodman.VarlinkCall, name string, service
|
|||
Service: string(servB),
|
||||
})
|
||||
}
|
||||
|
||||
// GenerateSystemd ...
|
||||
func (i *LibpodAPI) GenerateSystemd(call iopodman.VarlinkCall, nameOrID, restart string, stopTimeout int64, useName bool) error {
|
||||
ctr, err := i.Runtime.LookupContainer(nameOrID)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
timeout := int(ctr.StopTimeout())
|
||||
if stopTimeout >= 0 {
|
||||
timeout = int(stopTimeout)
|
||||
}
|
||||
name := ctr.ID()
|
||||
if useName {
|
||||
name = ctr.Name()
|
||||
}
|
||||
unit, err := systemdgen.CreateSystemdUnitAsString(name, ctr.ID(), restart, ctr.Config().StaticDir, timeout)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
return call.ReplyGenerateSystemd(unit)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue