summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cirrus.yml54
-rw-r--r--cmd/podman/containers/create.go5
-rw-r--r--pkg/api/handlers/utils/pods.go2
-rw-r--r--test/apiv2/40-pods.at2
-rw-r--r--test/e2e/run_networking_test.go32
-rw-r--r--test/e2e/run_test.go8
6 files changed, 72 insertions, 31 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index 276623607..964368743 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -179,8 +179,8 @@ container_image_build_task:
rpmbuild_task:
only_if: >-
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*' &&
$CIRRUS_BRANCH != $DEST_BRANCH
depends_on:
@@ -207,8 +207,8 @@ rpmbuild_task:
vendor_task:
only_if: >-
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
depends_on:
- "gating"
@@ -239,8 +239,8 @@ vendor_task:
varlink_api_task:
only_if: >-
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
depends_on:
- "gating"
@@ -278,8 +278,8 @@ build_each_commit_task:
only_if: >-
$CIRRUS_BRANCH != $DEST_BRANCH &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
gce_instance:
cpu: 8
@@ -310,8 +310,8 @@ build_without_cgo_task:
only_if: >-
$CIRRUS_BRANCH != $DEST_BRANCH &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
gce_instance:
cpu: 8
@@ -400,8 +400,8 @@ testing_task:
# Only test build cache-images, if that's what's requested
only_if: >-
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
matrix:
- name: "test ${FEDORA_NAME}"
@@ -461,8 +461,8 @@ special_testing_rootless_task:
- "build_without_cgo"
only_if: >-
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
env:
ADD_SECOND_PARTITION: 'true'
@@ -495,8 +495,8 @@ special_testing_in_podman_task:
- "build_without_cgo"
only_if: >-
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
matrix:
- name: "in-podman ${PRIOR_FEDORA_NAME}"
@@ -531,8 +531,8 @@ special_testing_cross_task:
- "vendor"
only_if: >-
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
matrix:
- name: 'cross-platform: windows'
@@ -569,8 +569,8 @@ special_testing_bindings_task:
- "vendor"
only_if: >-
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
env:
SPECIALMODE: 'bindings' # See docs
@@ -596,8 +596,8 @@ special_testing_endpoint_task:
- "vendor"
only_if: >-
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
env:
SPECIALMODE: 'endpoint' # See docs
@@ -619,8 +619,8 @@ test_build_cache_images_task:
only_if: >-
$CIRRUS_BRANCH != $DEST_BRANCH &&
- $CIRRUS_CHANGE_MESSAGE =~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE =~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
depends_on:
- "gating"
@@ -653,8 +653,8 @@ verify_test_built_images_task:
only_if: >-
$CIRRUS_BRANCH != $DEST_BRANCH &&
- $CIRRUS_CHANGE_MESSAGE =~ '.*CI:IMG.*' &&
- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
+ $CIRRUS_CHANGE_TITLE =~ '.*CI:IMG.*' &&
+ $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
depends_on:
@@ -694,7 +694,7 @@ verify_test_built_images_task:
docs_task:
# Don't run this when building/testing new VM images
- only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*'
+ only_if: $CIRRUS_CHANGE_TITLE !=~ '.*CI:IMG.*'
depends_on:
- "gating"
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index 6eec93f98..801547033 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -297,7 +297,12 @@ func createPodIfNecessary(s *specgen.SpecGenerator, netOpts *entities.NetOptions
Infra: true,
Net: netOpts,
CreateCommand: os.Args,
+ Hostname: s.ContainerBasicConfig.Hostname,
}
+ // Unset config values we passed to the pod to prevent them being used twice for the container and pod.
+ s.ContainerBasicConfig.Hostname = ""
+ s.ContainerNetworkConfig = specgen.ContainerNetworkConfig{}
+
s.Pod = podName
return registry.ContainerEngine().PodCreate(context.Background(), createOptions)
}
diff --git a/pkg/api/handlers/utils/pods.go b/pkg/api/handlers/utils/pods.go
index 8276fb55e..54ebe2d29 100644
--- a/pkg/api/handlers/utils/pods.go
+++ b/pkg/api/handlers/utils/pods.go
@@ -45,7 +45,7 @@ func GetPods(w http.ResponseWriter, r *http.Request) ([]*entities.ListPodsReport
}
if len(pods) == 0 {
- return nil, nil
+ return []*entities.ListPodsReport{}, nil
}
lps := make([]*entities.ListPodsReport, 0, len(pods))
diff --git a/test/apiv2/40-pods.at b/test/apiv2/40-pods.at
index 9b8ff04f0..3df541de5 100644
--- a/test/apiv2/40-pods.at
+++ b/test/apiv2/40-pods.at
@@ -3,7 +3,7 @@
# test pod-related endpoints
#
-t GET "libpod/pods/json (clean slate at start)" 200 null
+t GET "libpod/pods/json (clean slate at start)" 200 '[]'
t POST libpod/pods/create name=foo 201 .Id~[0-9a-f]\\{64\\}
pod_id=$(jq -r .Id <<<"$output")
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index 83befe730..a48f7c83e 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -531,8 +531,8 @@ var _ = Describe("Podman run networking", func() {
SkipIfRemote()
SkipIfRootless()
netName := "podmantestnetwork"
- ipAddr := "10.20.30.128"
- create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.20.30.0/24", netName})
+ ipAddr := "10.25.30.128"
+ create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.30.0/24", netName})
create.WaitWithDefaultTimeout()
Expect(create.ExitCode()).To(BeZero())
@@ -540,5 +540,33 @@ var _ = Describe("Podman run networking", func() {
run.WaitWithDefaultTimeout()
Expect(run.ExitCode()).To(BeZero())
Expect(run.OutputToString()).To(ContainSubstring(ipAddr))
+
+ netrm := podmanTest.Podman([]string{"network", "rm", netName})
+ netrm.WaitWithDefaultTimeout()
+ Expect(netrm.ExitCode()).To(BeZero())
+ })
+
+ It("podman run with new:pod and static-ip", func() {
+ SkipIfRemote()
+ SkipIfRootless()
+ netName := "podmantestnetwork2"
+ ipAddr := "10.25.40.128"
+ podname := "testpod"
+ create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.40.0/24", netName})
+ create.WaitWithDefaultTimeout()
+ Expect(create.ExitCode()).To(BeZero())
+
+ run := podmanTest.Podman([]string{"run", "-t", "-i", "--rm", "--pod", "new:" + podname, "--net", netName, "--ip", ipAddr, ALPINE, "ip", "addr"})
+ run.WaitWithDefaultTimeout()
+ Expect(run.ExitCode()).To(BeZero())
+ Expect(run.OutputToString()).To(ContainSubstring(ipAddr))
+
+ podrm := podmanTest.Podman([]string{"pod", "rm", "-f", podname})
+ podrm.WaitWithDefaultTimeout()
+ Expect(podrm.ExitCode()).To(BeZero())
+
+ netrm := podmanTest.Podman([]string{"network", "rm", netName})
+ netrm.WaitWithDefaultTimeout()
+ Expect(netrm.ExitCode()).To(BeZero())
})
})
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 6c65a23e8..157b7d3d7 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -867,6 +867,14 @@ USER mail`
Expect(match).To(BeTrue())
})
+ It("podman run --pod new with hostname", func() {
+ hostname := "abc"
+ session := podmanTest.Podman([]string{"run", "--pod", "new:foobar", "--hostname", hostname, ALPINE, "cat", "/etc/hostname"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(ContainSubstring(hostname))
+ })
+
It("podman run --rm should work", func() {
session := podmanTest.Podman([]string{"run", "--name", "test", "--rm", ALPINE, "ls"})
session.WaitWithDefaultTimeout()