mirror of
https://github.com/containers/podman.git
synced 2025-06-22 01:48:54 +08:00
Merge pull request #5997 from giuseppe/fix-pod-create
v2, podman: fix a bunch of "podman pod *" tests
This commit is contained in:
@ -397,6 +397,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
|
|||||||
s.DNSOptions = c.Net.DNSOptions
|
s.DNSOptions = c.Net.DNSOptions
|
||||||
s.StaticIP = c.Net.StaticIP
|
s.StaticIP = c.Net.StaticIP
|
||||||
s.StaticMAC = c.Net.StaticMAC
|
s.StaticMAC = c.Net.StaticMAC
|
||||||
|
s.UseImageHosts = c.Net.NoHosts
|
||||||
|
|
||||||
// deferred, must be added on libpod side
|
// deferred, must be added on libpod side
|
||||||
//var ImageVolumes map[string]struct{}
|
//var ImageVolumes map[string]struct{}
|
||||||
|
@ -145,7 +145,7 @@ func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, opt
|
|||||||
reports []*entities.PodStopReport
|
reports []*entities.PodStopReport
|
||||||
)
|
)
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, p := range pods {
|
for _, p := range pods {
|
||||||
@ -180,6 +180,7 @@ func (ic *ContainerEngine) PodRestart(ctx context.Context, namesOrIds []string,
|
|||||||
errs, err := p.Restart(ctx)
|
errs, err := p.Restart(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
report.Errs = []error{err}
|
report.Errs = []error{err}
|
||||||
|
reports = append(reports, &report)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
@ -207,6 +208,7 @@ func (ic *ContainerEngine) PodStart(ctx context.Context, namesOrIds []string, op
|
|||||||
errs, err := p.Start(ctx)
|
errs, err := p.Start(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
report.Errs = []error{err}
|
report.Errs = []error{err}
|
||||||
|
reports = append(reports, &report)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
@ -226,7 +228,7 @@ func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, optio
|
|||||||
reports []*entities.PodRmReport
|
reports []*entities.PodRmReport
|
||||||
)
|
)
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, p := range pods {
|
for _, p := range pods {
|
||||||
@ -234,6 +236,7 @@ func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, optio
|
|||||||
err := ic.Libpod.RemovePod(ctx, p, true, options.Force)
|
err := ic.Libpod.RemovePod(ctx, p, true, options.Force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
report.Err = err
|
report.Err = err
|
||||||
|
reports = append(reports, &report)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
reports = append(reports, &report)
|
reports = append(reports, &report)
|
||||||
|
@ -46,6 +46,13 @@ func createPodOptions(p *specgen.PodSpecGenerator) ([]libpod.PodCreateOption, er
|
|||||||
if len(p.HostAdd) > 0 {
|
if len(p.HostAdd) > 0 {
|
||||||
options = append(options, libpod.WithPodHosts(p.HostAdd))
|
options = append(options, libpod.WithPodHosts(p.HostAdd))
|
||||||
}
|
}
|
||||||
|
if len(p.DNSServer) > 0 {
|
||||||
|
var dnsServers []string
|
||||||
|
for _, d := range p.DNSServer {
|
||||||
|
dnsServers = append(dnsServers, d.String())
|
||||||
|
}
|
||||||
|
options = append(options, libpod.WithPodDNS(dnsServers))
|
||||||
|
}
|
||||||
if len(p.DNSOption) > 0 {
|
if len(p.DNSOption) > 0 {
|
||||||
options = append(options, libpod.WithPodDNSOption(p.DNSOption))
|
options = append(options, libpod.WithPodDNSOption(p.DNSOption))
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func (p *PodSpecGenerator) Validate() error {
|
|||||||
return exclusivePodOptions("NoInfra", "NoManageResolvConf")
|
return exclusivePodOptions("NoInfra", "NoManageResolvConf")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.NetNS.NSMode != Bridge {
|
if p.NetNS.NSMode != "" && p.NetNS.NSMode != Bridge && p.NetNS.NSMode != Default {
|
||||||
if len(p.PortMappings) > 0 {
|
if len(p.PortMappings) > 0 {
|
||||||
return errors.New("PortMappings can only be used with Bridge mode networking")
|
return errors.New("PortMappings can only be used with Bridge mode networking")
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ var _ = Describe("Podman pod create", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
Skip(v2fail)
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -16,7 +16,6 @@ var _ = Describe("Podman pod restart", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
Skip(v2fail)
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -19,7 +19,6 @@ var _ = Describe("Podman pod rm", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
Skip(v2fail)
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -16,7 +16,6 @@ var _ = Describe("Podman pod stop", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
Skip(v2fail)
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Reference in New Issue
Block a user