summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--contrib/spec/podman.spec.in2
-rw-r--r--contrib/systemd/system/podman-restart.service12
-rw-r--r--contrib/systemd/system/podman.service3
-rw-r--r--pkg/api/handlers/compat/images.go25
-rw-r--r--pkg/bindings/images/build.go16
-rw-r--r--pkg/cgroups/cgroups.go5
-rw-r--r--pkg/domain/entities/images.go2
-rw-r--r--pkg/domain/infra/abi/containers.go9
-rw-r--r--pkg/domain/infra/abi/images.go2
-rw-r--r--pkg/domain/infra/tunnel/containers.go8
-rw-r--r--test/apiv2/python/rest_api/test_v2_0_0_image.py9
-rw-r--r--test/system/045-start.bats11
-rw-r--r--test/system/070-build.bats23
14 files changed, 110 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 3e40881f3..9b5dd34a5 100644
--- a/Makefile
+++ b/Makefile
@@ -748,11 +748,13 @@ install.systemd:
install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.timer ${DESTDIR}${USERSYSTEMDDIR}/podman-auto-update.timer
install ${SELINUXOPT} -m 644 contrib/systemd/user/podman.socket ${DESTDIR}${USERSYSTEMDDIR}/podman.socket
install ${SELINUXOPT} -m 644 contrib/systemd/user/podman.service ${DESTDIR}${USERSYSTEMDDIR}/podman.service
+ install ${SELINUXOPT} -m 644 contrib/systemd/user/podman-restart.service ${DESTDIR}${USERSYSTEMDDIR}/podman-restart.service
# System services
install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.service ${DESTDIR}${SYSTEMDDIR}/podman-auto-update.service
install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.timer ${DESTDIR}${SYSTEMDDIR}/podman-auto-update.timer
install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.socket ${DESTDIR}${SYSTEMDDIR}/podman.socket
install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.service ${DESTDIR}${SYSTEMDDIR}/podman.service
+ install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-restart.service ${DESTDIR}${SYSTEMDDIR}/podman-restart.service
else
install.systemd:
endif
diff --git a/contrib/spec/podman.spec.in b/contrib/spec/podman.spec.in
index 6146a2c0e..ef8523f8c 100644
--- a/contrib/spec/podman.spec.in
+++ b/contrib/spec/podman.spec.in
@@ -531,10 +531,12 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
%{_unitdir}/podman-auto-update.timer
%{_unitdir}/podman.service
%{_unitdir}/podman.socket
+%{_unitdir}/podman-restart.service
%{_usr}/lib/systemd/user/podman.service
%{_usr}/lib/systemd/user/podman.socket
%{_usr}/lib/systemd/user/podman-auto-update.service
%{_usr}/lib/systemd/user/podman-auto-update.timer
+%{_usr}/lib/systemd/user/podman-restart.service
%{_usr}/lib/tmpfiles.d/podman.conf
%if 0%{?with_devel}
diff --git a/contrib/systemd/system/podman-restart.service b/contrib/systemd/system/podman-restart.service
new file mode 100644
index 000000000..baf12b3ae
--- /dev/null
+++ b/contrib/systemd/system/podman-restart.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Podman Start All Containers With Restart Policy Set To Always
+Documentation=man:podman-start(1)
+StartLimitIntervalSec=0
+
+[Service]
+Type=oneshot
+Environment=LOGGING="--log-level=info"
+ExecStart=/usr/bin/podman $LOGGING start --all --filter restart-policy=always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/contrib/systemd/system/podman.service b/contrib/systemd/system/podman.service
index 7e5195e7a..cefb13ae3 100644
--- a/contrib/systemd/system/podman.service
+++ b/contrib/systemd/system/podman.service
@@ -10,3 +10,6 @@ Type=exec
KillMode=process
Environment=LOGGING="--log-level=info"
ExecStart=/usr/bin/podman $LOGGING system service
+
+[Install]
+WantedBy=multi-user.target
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go
index ac212474b..7baa1145a 100644
--- a/pkg/api/handlers/compat/images.go
+++ b/pkg/api/handlers/compat/images.go
@@ -166,10 +166,11 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime)
query := struct {
- FromSrc string `schema:"fromSrc"`
- Changes []string `schema:"changes"`
- Message string `schema:"message"`
- Repo string `shchema:"repo"`
+ Changes []string `schema:"changes"`
+ FromSrc string `schema:"fromSrc"`
+ Message string `schema:"message"`
+ Platform string `schema:"platform"`
+ Repo string `shchema:"repo"`
}{
// This is where you can override the golang default value for one of fields
}
@@ -192,9 +193,21 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file"))
}
}
+
+ platformSpecs := strings.Split(query.Platform, "/")
+ opts := entities.ImageImportOptions{
+ Source: source,
+ Changes: query.Changes,
+ Message: query.Message,
+ Reference: query.Repo,
+ OS: platformSpecs[0],
+ }
+ if len(platformSpecs) > 1 {
+ opts.Architecture = platformSpecs[1]
+ }
+
imageEngine := abi.ImageEngine{Libpod: runtime}
- // TODO: add support for ImageImportOptions to take a platform parameter. Also import https://github.com/opencontainers/image-spec/tree/master/specs-go/v1 either here or within imageEngine.Import to get default platform
- report, err := imageEngine.Import(r.Context(), entities.ImageImportOptions{Source: source, Changes: query.Changes, Message: query.Message, Reference: query.Repo})
+ report, err := imageEngine.Import(r.Context(), opts)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to import tarball"))
return
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index c7d432b16..937d05330 100644
--- a/pkg/bindings/images/build.go
+++ b/pkg/bindings/images/build.go
@@ -299,6 +299,22 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
tarContent := []string{options.ContextDirectory}
newContainerFiles := []string{}
for _, c := range containerFiles {
+ if c == "/dev/stdin" {
+ content, err := ioutil.ReadAll(os.Stdin)
+ if err != nil {
+ return nil, err
+ }
+ tmpFile, err := ioutil.TempFile("", "build")
+ if err != nil {
+ return nil, err
+ }
+ defer os.Remove(tmpFile.Name()) // clean up
+ defer tmpFile.Close()
+ if _, err := tmpFile.Write(content); err != nil {
+ return nil, err
+ }
+ c = tmpFile.Name()
+ }
containerfile, err := filepath.Abs(c)
if err != nil {
logrus.Errorf("cannot find absolute path of %v: %v", c, err)
diff --git a/pkg/cgroups/cgroups.go b/pkg/cgroups/cgroups.go
index 911edeb5b..9cb32a364 100644
--- a/pkg/cgroups/cgroups.go
+++ b/pkg/cgroups/cgroups.go
@@ -165,14 +165,13 @@ func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool)
if _, found := exclude[name]; found {
continue
}
- isSymLink := false
fileInfo, err := os.Stat(cgroupRoot + "/" + name)
if err != nil {
- isSymLink = !fileInfo.IsDir()
+ continue
}
c := controller{
name: name,
- symlink: isSymLink,
+ symlink: !fileInfo.IsDir(),
}
controllers = append(controllers, c)
}
diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go
index 3cc46ed0a..17b82037e 100644
--- a/pkg/domain/entities/images.go
+++ b/pkg/domain/entities/images.go
@@ -271,8 +271,10 @@ type ImageLoadReport struct {
}
type ImageImportOptions struct {
+ Architecture string
Changes []string
Message string
+ OS string
Quiet bool
Reference string
SignaturePolicy string
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index 5a953c047..e6dd19e63 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -702,7 +702,9 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
reports := []*entities.ContainerStartReport{}
var exitCode = define.ExecErrorCodeGeneric
containersNamesOrIds := namesOrIds
+ all := options.All
if len(options.Filters) > 0 {
+ all = false
filterFuncs := make([]libpod.ContainerFilter, 0, len(options.Filters))
if len(options.Filters) > 0 {
for k, v := range options.Filters {
@@ -719,6 +721,10 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
}
containersNamesOrIds = []string{}
for _, candidate := range candidates {
+ if options.All {
+ containersNamesOrIds = append(containersNamesOrIds, candidate.ID())
+ continue
+ }
for _, nameOrID := range namesOrIds {
if nameOrID == candidate.ID() || nameOrID == candidate.Name() {
containersNamesOrIds = append(containersNamesOrIds, nameOrID)
@@ -726,8 +732,7 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
}
}
}
-
- ctrs, rawInputs, err := getContainersAndInputByContext(options.All, options.Latest, containersNamesOrIds, ic.Libpod)
+ ctrs, rawInputs, err := getContainersAndInputByContext(all, options.Latest, containersNamesOrIds, ic.Libpod)
if err != nil {
return nil, err
}
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index 083566201..5992181d3 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -388,6 +388,8 @@ func (ir *ImageEngine) Import(ctx context.Context, options entities.ImageImportO
importOptions.CommitMessage = options.Message
importOptions.Tag = options.Reference
importOptions.SignaturePolicyPath = options.SignaturePolicy
+ importOptions.OS = options.OS
+ importOptions.Architecture = options.Architecture
if !options.Quiet {
importOptions.Writer = os.Stderr
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 74ced300a..0047fc839 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -508,7 +508,9 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
reports := []*entities.ContainerStartReport{}
var exitCode = define.ExecErrorCodeGeneric
containersNamesOrIds := namesOrIds
+ all := options.All
if len(options.Filters) > 0 {
+ all = false
containersNamesOrIds = []string{}
opts := new(containers.ListOptions).WithFilters(options.Filters).WithAll(true)
candidates, listErr := containers.List(ic.ClientCtx, opts)
@@ -516,6 +518,10 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
return nil, listErr
}
for _, candidate := range candidates {
+ if options.All {
+ containersNamesOrIds = append(containersNamesOrIds, candidate.ID)
+ continue
+ }
for _, nameOrID := range namesOrIds {
if nameOrID == candidate.ID {
containersNamesOrIds = append(containersNamesOrIds, nameOrID)
@@ -530,7 +536,7 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
}
}
}
- ctrs, err := getContainersByContext(ic.ClientCtx, options.All, false, containersNamesOrIds)
+ ctrs, err := getContainersByContext(ic.ClientCtx, all, false, containersNamesOrIds)
if err != nil {
return nil, err
}
diff --git a/test/apiv2/python/rest_api/test_v2_0_0_image.py b/test/apiv2/python/rest_api/test_v2_0_0_image.py
index cea34e2e7..59dcea87f 100644
--- a/test/apiv2/python/rest_api/test_v2_0_0_image.py
+++ b/test/apiv2/python/rest_api/test_v2_0_0_image.py
@@ -89,14 +89,9 @@ class ImageTestCase(APITestCase):
def test_create(self):
r = requests.post(
- self.podman_url + "/v1.40/images/create?fromImage=alpine&platform=linux/amd64/v8",
- timeout=15,
- )
+ self.podman_url + "/v1.40/images/create?fromImage=alpine&platform=linux/amd64/v8", timeout=15)
self.assertEqual(r.status_code, 200, r.text)
- r = requests.post(
- self.podman_url + "/v1.40/images/create?fromSrc=-&repo=fedora&message=testing123",
- timeout=15,
- )
+ r = requests.post(self.podman_url + "/v1.40/images/create?fromSrc=-&repo=fedora&message=testing123&platform=linux/amd64", timeout=15)
self.assertEqual(r.status_code, 200, r.text)
def test_search_compat(self):
diff --git a/test/system/045-start.bats b/test/system/045-start.bats
index 3e0118dba..7e4bbde8d 100644
--- a/test/system/045-start.bats
+++ b/test/system/045-start.bats
@@ -59,4 +59,15 @@ load helpers
is "$output" "Error: fakepolicy invalid restart policy"
}
+@test "podman start --all --filter" {
+ run_podman run -d $IMAGE /bin/true
+ cid_exited_0="$output"
+ run_podman run -d $IMAGE /bin/false
+ cid_exited_1="$output"
+
+ run_podman wait $cid_exited_0 $cid_exited_1
+ run_podman start --all --filter exited=0
+ is "$output" "$cid_exited_0"
+}
+
# vim: filetype=sh
diff --git a/test/system/070-build.bats b/test/system/070-build.bats
index 40622d6cc..6843e28a5 100644
--- a/test/system/070-build.bats
+++ b/test/system/070-build.bats
@@ -29,6 +29,29 @@ EOF
run_podman rmi -f build_test
}
+@test "podman build test -f -" {
+ rand_filename=$(random_string 20)
+ rand_content=$(random_string 50)
+
+ tmpdir=$PODMAN_TMPDIR/build-test
+ mkdir -p $tmpdir
+ containerfile=$PODMAN_TMPDIR/Containerfile
+ cat >$containerfile <<EOF
+FROM $IMAGE
+RUN apk add nginx
+RUN echo $rand_content > /$rand_filename
+EOF
+
+ # The 'apk' command can take a long time to fetch files; bump timeout
+ PODMAN_TIMEOUT=240 run_podman build -t build_test -f - --format=docker $tmpdir < $containerfile
+ is "$output" ".*STEP 4: COMMIT" "COMMIT seen in log"
+
+ run_podman run --rm build_test cat /$rand_filename
+ is "$output" "$rand_content" "reading generated file in image"
+
+ run_podman rmi -f build_test
+}
+
@test "podman build - global runtime flags test" {
skip_if_remote "--runtime-flag flag not supported for remote"