mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #6896 from mheon/fix_remote_createcommand
Fix container and pod create commands for remote create
This commit is contained in:
@ -401,6 +401,9 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
|
|||||||
}
|
}
|
||||||
var command []string
|
var command []string
|
||||||
|
|
||||||
|
// Include the command used to create the container.
|
||||||
|
s.ContainerCreateCommand = os.Args
|
||||||
|
|
||||||
// Build the command
|
// Build the command
|
||||||
// If we have an entry point, it goes first
|
// If we have an entry point, it goes first
|
||||||
if c.Entrypoint != nil {
|
if c.Entrypoint != nil {
|
||||||
|
@ -149,6 +149,8 @@ func create(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createOptions.CreateCommand = os.Args
|
||||||
|
|
||||||
if replace {
|
if replace {
|
||||||
if err := replacePod(createOptions.Name); err != nil {
|
if err := replacePod(createOptions.Name); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1419,12 +1419,12 @@ func WithPreserveFDs(fd uint) CtrCreateOption {
|
|||||||
|
|
||||||
// WithCreateCommand adds the full command plus arguments of the current
|
// WithCreateCommand adds the full command plus arguments of the current
|
||||||
// process to the container config.
|
// process to the container config.
|
||||||
func WithCreateCommand() CtrCreateOption {
|
func WithCreateCommand(cmd []string) CtrCreateOption {
|
||||||
return func(ctr *Container) error {
|
return func(ctr *Container) error {
|
||||||
if ctr.valid {
|
if ctr.valid {
|
||||||
return define.ErrCtrFinalized
|
return define.ErrCtrFinalized
|
||||||
}
|
}
|
||||||
ctr.config.CreateCommand = os.Args
|
ctr.config.CreateCommand = cmd
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1625,12 +1625,12 @@ func WithPodHostname(hostname string) PodCreateOption {
|
|||||||
|
|
||||||
// WithPodCreateCommand adds the full command plus arguments of the current
|
// WithPodCreateCommand adds the full command plus arguments of the current
|
||||||
// process to the pod config.
|
// process to the pod config.
|
||||||
func WithPodCreateCommand() PodCreateOption {
|
func WithPodCreateCommand(createCmd []string) PodCreateOption {
|
||||||
return func(pod *Pod) error {
|
return func(pod *Pod) error {
|
||||||
if pod.valid {
|
if pod.valid {
|
||||||
return define.ErrPodFinalized
|
return define.ErrPodFinalized
|
||||||
}
|
}
|
||||||
pod.config.CreateCommand = os.Args
|
pod.config.CreateCommand = createCmd
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,7 @@ type PodRmReport struct {
|
|||||||
|
|
||||||
type PodCreateOptions struct {
|
type PodCreateOptions struct {
|
||||||
CGroupParent string
|
CGroupParent string
|
||||||
|
CreateCommand []string
|
||||||
Hostname string
|
Hostname string
|
||||||
Infra bool
|
Infra bool
|
||||||
InfraImage string
|
InfraImage string
|
||||||
@ -133,6 +134,7 @@ func (p PodCreateOptions) ToPodSpecGen(s *specgen.PodSpecGenerator) {
|
|||||||
}
|
}
|
||||||
s.InfraImage = p.InfraImage
|
s.InfraImage = p.InfraImage
|
||||||
s.SharedNamespaces = p.Share
|
s.SharedNamespaces = p.Share
|
||||||
|
s.PodCreateCommand = p.CreateCommand
|
||||||
|
|
||||||
// Networking config
|
// Networking config
|
||||||
s.NetNS = p.Net.Network
|
s.NetNS = p.Net.Network
|
||||||
|
@ -406,10 +406,6 @@ func CreateContainerFromCreateConfig(ctx context.Context, r *libpod.Runtime, cre
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the CreateCommand explicitly. Some (future) consumers of libpod
|
|
||||||
// might not want to set it.
|
|
||||||
options = append(options, libpod.WithCreateCommand())
|
|
||||||
|
|
||||||
ctr, err := r.NewContainer(ctx, runtimeSpec, options...)
|
ctr, err := r.NewContainer(ctx, runtimeSpec, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -78,7 +78,9 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
|
|||||||
}
|
}
|
||||||
|
|
||||||
options := []libpod.CtrCreateOption{}
|
options := []libpod.CtrCreateOption{}
|
||||||
options = append(options, libpod.WithCreateCommand())
|
if s.ContainerCreateCommand != nil {
|
||||||
|
options = append(options, libpod.WithCreateCommand(s.ContainerCreateCommand))
|
||||||
|
}
|
||||||
|
|
||||||
var newImage *image.Image
|
var newImage *image.Image
|
||||||
if s.Rootfs != "" {
|
if s.Rootfs != "" {
|
||||||
|
@ -93,7 +93,9 @@ func createPodOptions(p *specgen.PodSpecGenerator) ([]libpod.PodCreateOption, er
|
|||||||
options = append(options, libpod.WithInfraContainerPorts(ports))
|
options = append(options, libpod.WithInfraContainerPorts(ports))
|
||||||
}
|
}
|
||||||
options = append(options, libpod.WithPodCgroups())
|
options = append(options, libpod.WithPodCgroups())
|
||||||
options = append(options, libpod.WithPodCreateCommand())
|
if p.PodCreateCommand != nil {
|
||||||
|
options = append(options, libpod.WithPodCreateCommand(p.PodCreateCommand))
|
||||||
|
}
|
||||||
if len(p.InfraConmonPidFile) > 0 {
|
if len(p.InfraConmonPidFile) > 0 {
|
||||||
options = append(options, libpod.WithInfraConmonPidFile(p.InfraConmonPidFile))
|
options = append(options, libpod.WithInfraConmonPidFile(p.InfraConmonPidFile))
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,12 @@ type PodBasicConfig struct {
|
|||||||
// Conflicts with NoInfra=true.
|
// Conflicts with NoInfra=true.
|
||||||
// Optional.
|
// Optional.
|
||||||
SharedNamespaces []string `json:"shared_namespaces,omitempty"`
|
SharedNamespaces []string `json:"shared_namespaces,omitempty"`
|
||||||
|
// PodCreateCommand is the command used to create this pod.
|
||||||
|
// This will be shown in the output of Inspect() on the pod, and may
|
||||||
|
// also be used by some tools that wish to recreate the pod
|
||||||
|
// (e.g. `podman generate systemd --new`).
|
||||||
|
// Optional.
|
||||||
|
PodCreateCommand []string `json:"pod_create_command,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodNetworkConfig contains networking configuration for a pod.
|
// PodNetworkConfig contains networking configuration for a pod.
|
||||||
|
@ -135,6 +135,13 @@ type ContainerBasicConfig struct {
|
|||||||
// Remove indicates if the container should be removed once it has been started
|
// Remove indicates if the container should be removed once it has been started
|
||||||
// and exits
|
// and exits
|
||||||
Remove bool `json:"remove,omitempty"`
|
Remove bool `json:"remove,omitempty"`
|
||||||
|
// ContainerCreateCommand is the command that was used to create this
|
||||||
|
// container.
|
||||||
|
// This will be shown in the output of Inspect() on the container, and
|
||||||
|
// may also be used by some tools that wish to recreate the container
|
||||||
|
// (e.g. `podman generate systemd --new`).
|
||||||
|
// Optional.
|
||||||
|
ContainerCreateCommand []string `json:"containerCreateCommand,omitempty"`
|
||||||
// PreserveFDs is a number of additional file descriptors (in addition
|
// PreserveFDs is a number of additional file descriptors (in addition
|
||||||
// to 0, 1, 2) that will be passed to the executed process. The total FDs
|
// to 0, 1, 2) that will be passed to the executed process. The total FDs
|
||||||
// passed will be 3 + PreserveFDs.
|
// passed will be 3 + PreserveFDs.
|
||||||
|
@ -915,10 +915,6 @@ func CreateContainerFromCreateConfig(ctx context.Context, r *libpod.Runtime, cre
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the CreateCommand explicitly. Some (future) consumers of libpod
|
|
||||||
// might not want to set it.
|
|
||||||
options = append(options, libpod.WithCreateCommand())
|
|
||||||
|
|
||||||
ctr, err := r.NewContainer(ctx, runtimeSpec, options...)
|
ctr, err := r.NewContainer(ctx, runtimeSpec, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -59,7 +59,6 @@ var _ = Describe("Podman pod inspect", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman pod inspect (CreateCommand)", func() {
|
It("podman pod inspect (CreateCommand)", func() {
|
||||||
Skip(v2remotefail)
|
|
||||||
podName := "myTestPod"
|
podName := "myTestPod"
|
||||||
createCommand := []string{"pod", "create", "--name", podName, "--hostname", "rudolph", "--share", "net"}
|
createCommand := []string{"pod", "create", "--name", podName, "--hostname", "rudolph", "--share", "net"}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user