Skip to content

Commit 5a02e74

Browse files
Merge pull request #6132 from nalind/relabel-binds
run: handle relabeling bind mounts ourselves
2 parents 328e613 + 910933b commit 5a02e74

21 files changed

+758
-43
lines changed

.cirrus.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ env:
2222
IN_PODMAN: 'false'
2323
# root or rootless
2424
PRIV_NAME: root
25+
# default "mention the $BUILDAH_RUNTIME in the task alias, with initial whitespace" value
26+
RUNTIME_N: ""
2527

2628
####
2729
#### Cache-image names to test with
@@ -196,7 +198,7 @@ conformance_task:
196198

197199

198200
integration_task:
199-
name: "Integration $DISTRO_NV w/ $STORAGE_DRIVER"
201+
name: "Integration $DISTRO_NV$RUNTIME_N w/ $STORAGE_DRIVER"
200202
alias: integration
201203
skip: *not_build_docs
202204
depends_on: *smoke_vendor
@@ -207,10 +209,26 @@ integration_task:
207209
DISTRO_NV: "${FEDORA_NAME}"
208210
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
209211
STORAGE_DRIVER: 'vfs'
212+
BUILDAH_RUNTIME: crun
213+
RUNTIME_N: " using crun"
214+
- env:
215+
DISTRO_NV: "${FEDORA_NAME}"
216+
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
217+
STORAGE_DRIVER: 'vfs'
218+
BUILDAH_RUNTIME: runc
219+
RUNTIME_N: " using runc"
210220
- env:
211221
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
212222
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
213223
STORAGE_DRIVER: 'vfs'
224+
BUILDAH_RUNTIME: crun
225+
RUNTIME_N: " using crun"
226+
- env:
227+
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
228+
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
229+
STORAGE_DRIVER: 'vfs'
230+
BUILDAH_RUNTIME: runc
231+
RUNTIME_N: " using runc"
214232
- env:
215233
DISTRO_NV: "${DEBIAN_NAME}"
216234
IMAGE_NAME: "${DEBIAN_CACHE_IMAGE_NAME}"
@@ -220,10 +238,26 @@ integration_task:
220238
DISTRO_NV: "${FEDORA_NAME}"
221239
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
222240
STORAGE_DRIVER: 'overlay'
241+
BUILDAH_RUNTIME: crun
242+
RUNTIME_N: " using crun"
243+
- env:
244+
DISTRO_NV: "${FEDORA_NAME}"
245+
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
246+
STORAGE_DRIVER: 'overlay'
247+
BUILDAH_RUNTIME: runc
248+
RUNTIME_N: " using runc"
249+
- env:
250+
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
251+
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
252+
STORAGE_DRIVER: 'overlay'
253+
BUILDAH_RUNTIME: crun
254+
RUNTIME_N: " using crun"
223255
- env:
224256
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
225257
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
226258
STORAGE_DRIVER: 'overlay'
259+
BUILDAH_RUNTIME: runc
260+
RUNTIME_N: " using runc"
227261
- env:
228262
DISTRO_NV: "${DEBIAN_NAME}"
229263
IMAGE_NAME: "${DEBIAN_CACHE_IMAGE_NAME}"
@@ -253,7 +287,7 @@ integration_task:
253287
golang_version_script: '$GOSRC/$SCRIPT_BASE/logcollector.sh golang'
254288

255289
integration_rootless_task:
256-
name: "Integration rootless $DISTRO_NV w/ $STORAGE_DRIVER"
290+
name: "Integration rootless $DISTRO_NV$RUNTIME_N w/ $STORAGE_DRIVER"
257291
alias: integration_rootless
258292
skip: *not_build_docs
259293
depends_on: *smoke_vendor
@@ -266,11 +300,29 @@ integration_rootless_task:
266300
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
267301
STORAGE_DRIVER: 'overlay'
268302
PRIV_NAME: rootless
303+
BUILDAH_RUNTIME: runc
304+
RUNTIME_N: " using runc"
305+
- env:
306+
DISTRO_NV: "${FEDORA_NAME}"
307+
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
308+
STORAGE_DRIVER: 'overlay'
309+
PRIV_NAME: rootless
310+
BUILDAH_RUNTIME: crun
311+
RUNTIME_N: " using crun"
312+
- env:
313+
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
314+
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
315+
STORAGE_DRIVER: 'overlay'
316+
PRIV_NAME: rootless
317+
BUILDAH_RUNTIME: runc
318+
RUNTIME_N: " using runc"
269319
- env:
270320
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
271321
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
272322
STORAGE_DRIVER: 'overlay'
273323
PRIV_NAME: rootless
324+
BUILDAH_RUNTIME: crun
325+
RUNTIME_N: " using crun"
274326
- env:
275327
DISTRO_NV: "${DEBIAN_NAME}"
276328
IMAGE_NAME: "${DEBIAN_CACHE_IMAGE_NAME}"

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export GOLANGCI_LINT_VERSION := 2.1.0
5959
# Note: Uses the -N -l go compiler options to disable compiler optimizations
6060
# and inlining. Using these build options allows you to subsequently
6161
# use source debugging tools like delve.
62-
all: bin/buildah bin/imgtype bin/copy bin/inet bin/tutorial docs
62+
all: bin/buildah bin/imgtype bin/copy bin/inet bin/tutorial bin/dumpspec docs
6363

6464
# Update nix/nixpkgs.json its latest stable commit
6565
.PHONY: nixpkgs
@@ -107,6 +107,9 @@ bin/buildah.%: $(SOURCES)
107107
mkdir -p ./bin
108108
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ -tags "containers_image_openpgp" ./cmd/buildah
109109

110+
bin/dumpspec: $(SOURCES)
111+
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/dumpspec
112+
110113
bin/imgtype: $(SOURCES)
111114
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/imgtype/imgtype.go
112115

chroot/pty_unsupported.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

chroot/run_common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"syscall"
1919

2020
"github.com/containers/buildah/bind"
21+
"github.com/containers/buildah/internal/pty"
2122
"github.com/containers/buildah/util"
2223
"github.com/containers/storage/pkg/ioutils"
2324
"github.com/containers/storage/pkg/reexec"
@@ -217,7 +218,7 @@ func runUsingChrootMain() {
217218
var stderr io.Writer
218219
fdDesc := make(map[int]string)
219220
if options.Spec.Process.Terminal {
220-
ptyMasterFd, ptyFd, err := getPtyDescriptors()
221+
ptyMasterFd, ptyFd, err := pty.GetPtyDescriptors()
221222
if err != nil {
222223
logrus.Errorf("error opening PTY descriptors: %v", err)
223224
os.Exit(1)

docs/buildah-build.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ The default certificates directory is _/etc/containers/certs.d_.
189189

190190
**--cgroup-parent**=""
191191

192-
Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
192+
Path to cgroups under which the cgroup for RUN instructions will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
193193

194194
**--cgroupns** *how*
195195

chroot/pty_posix.go renamed to internal/pty/pty_posix.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build freebsd && cgo
22

3-
package chroot
3+
package pty
44

55
// #include <fcntl.h>
66
// #include <stdlib.h>
@@ -37,7 +37,9 @@ func unlockpt(fd int) error {
3737
return nil
3838
}
3939

40-
func getPtyDescriptors() (int, int, error) {
40+
// GetPtyDescriptors allocates a new pseudoterminal and returns the control and
41+
// pseudoterminal file descriptors.
42+
func GetPtyDescriptors() (int, int, error) {
4143
// Create a pseudo-terminal and open the control side
4244
controlFd, err := openpt()
4345
if err != nil {

chroot/pty_ptmx.go renamed to internal/pty/pty_ptmx.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build linux
22

3-
package chroot
3+
package pty
44

55
import (
66
"fmt"
@@ -11,9 +11,11 @@ import (
1111
"golang.org/x/sys/unix"
1212
)
1313

14-
// Open a PTY using the /dev/ptmx device. The main advantage of using
15-
// this instead of posix_openpt is that it avoids cgo.
16-
func getPtyDescriptors() (int, int, error) {
14+
// GetPtyDescriptors allocates a new pseudoterminal and returns the control and
15+
// pseudoterminal file descriptors. This implementation uses the /dev/ptmx
16+
// device. The main advantage of using this instead of posix_openpt is that it
17+
// avoids cgo.
18+
func GetPtyDescriptors() (int, int, error) {
1719
// Create a pseudo-terminal -- open a copy of the master side.
1820
controlFd, err := unix.Open("/dev/ptmx", os.O_RDWR, 0o600)
1921
if err != nil {

internal/pty/pty_unsupported.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build !linux && !(freebsd && cgo)
2+
3+
package pty
4+
5+
import (
6+
"errors"
7+
)
8+
9+
// GetPtyDescriptors would allocate a new pseudoterminal and return the control and
10+
// pseudoterminal file descriptors, if only it could.
11+
func GetPtyDescriptors() (int, int, error) {
12+
return -1, -1, errors.New("GetPtyDescriptors not supported on this platform")
13+
}

rpm/buildah.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export BUILDTAGS+=" libtrust_openssl"
137137
%gobuild -o bin/copy ./tests/copy
138138
%gobuild -o bin/tutorial ./tests/tutorial
139139
%gobuild -o bin/inet ./tests/inet
140+
%gobuild -o bin/dumpspec ./tests/dumpspec
140141
%{__make} docs
141142

142143
%install
@@ -148,6 +149,7 @@ cp bin/imgtype %{buildroot}/%{_bindir}/%{name}-imgtype
148149
cp bin/copy %{buildroot}/%{_bindir}/%{name}-copy
149150
cp bin/tutorial %{buildroot}/%{_bindir}/%{name}-tutorial
150151
cp bin/inet %{buildroot}/%{_bindir}/%{name}-inet
152+
cp bin/dumpspec %{buildroot}/%{_bindir}/%{name}-dumpspec
151153

152154
rm %{buildroot}%{_datadir}/%{name}/test/system/tools/build/*
153155

@@ -172,6 +174,7 @@ rm %{buildroot}%{_datadir}/%{name}/test/system/tools/build/*
172174
%{_bindir}/%{name}-copy
173175
%{_bindir}/%{name}-tutorial
174176
%{_bindir}/%{name}-inet
177+
%{_bindir}/%{name}-dumpspec
175178
%{_datadir}/%{name}/test
176179

177180
%changelog

run_common.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,9 @@ func runUsingRuntime(options RunOptions, configureNetwork bool, moreCreateArgs [
696696
return 1, fmt.Errorf("parsing container state %q from %s: %w", string(stateOutput), runtime, err)
697697
}
698698
switch state.Status {
699-
case "running":
700-
case "stopped":
699+
case specs.StateCreating, specs.StateCreated, specs.StateRunning:
700+
// all fine
701+
case specs.StateStopped:
701702
atomic.StoreUint32(&stopped, 1)
702703
default:
703704
return 1, fmt.Errorf("container status unexpectedly changed to %q", state.Status)

0 commit comments

Comments
 (0)