Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Yong Tang authored on 2017/11/02 08:37:53... | ... |
@@ -1,4 +1,4 @@ |
1 |
-// +build solaris freebsd |
|
1 |
+// +build freebsd |
|
2 | 2 |
|
3 | 3 |
package container |
4 | 4 |
|
... | ... |
@@ -7,7 +7,7 @@ import ( |
7 | 7 |
) |
8 | 8 |
|
9 | 9 |
func detachMounted(path string) error { |
10 |
- //Solaris and FreeBSD do not support the lazy unmount or MNT_DETACH feature. |
|
10 |
+ // FreeBSD do not support the lazy unmount or MNT_DETACH feature. |
|
11 | 11 |
// Therefore there are separate definitions for this. |
12 | 12 |
return unix.Unmount(path, 0) |
13 | 13 |
} |
... | ... |
@@ -11,7 +11,6 @@ usage() { |
11 | 11 |
echo >&2 " $mkimg -t someuser/centos:5 rinse --distribution centos-5" |
12 | 12 |
echo >&2 " $mkimg -t someuser/mageia:4 mageia-urpmi --version=4" |
13 | 13 |
echo >&2 " $mkimg -t someuser/mageia:4 mageia-urpmi --version=4 --mirror=http://somemirror/" |
14 |
- echo >&2 " $mkimg -t someuser/solaris solaris" |
|
15 | 14 |
exit 1 |
16 | 15 |
} |
17 | 16 |
|
... | ... |
@@ -20,13 +19,6 @@ scriptDir="$(dirname "$(readlink -f "$BASH_SOURCE")")/mkimage" |
20 | 20 |
os= |
21 | 21 |
os=$(uname -o) |
22 | 22 |
|
23 |
-# set up path to gnu tools if solaris |
|
24 |
-[[ $os == "Solaris" ]] && export PATH=/usr/gnu/bin:$PATH |
|
25 |
-# TODO check for gnu-tar, gnu-getopt |
|
26 |
- |
|
27 |
-# TODO requires root/sudo due to some pkg operations. sigh. |
|
28 |
-[[ $os == "Solaris" && $EUID != "0" ]] && echo >&2 "image create on Solaris requires superuser privilege" |
|
29 |
- |
|
30 | 23 |
optTemp=$(getopt --options '+d:t:c:hC' --longoptions 'dir:,tag:,compression:,no-compression,help' --name "$mkimg" -- "$@") |
31 | 24 |
eval set -- "$optTemp" |
32 | 25 |
unset optTemp |
33 | 26 |
deleted file mode 100755 |
... | ... |
@@ -1,89 +0,0 @@ |
1 |
-#!/usr/bin/env bash |
|
2 |
-# |
|
3 |
-# Solaris 12 base image build script. |
|
4 |
-# |
|
5 |
-set -e |
|
6 |
- |
|
7 |
-# TODO add optional package publisher origin |
|
8 |
- |
|
9 |
-rootfsDir="$1" |
|
10 |
-shift |
|
11 |
- |
|
12 |
-# base install |
|
13 |
-( |
|
14 |
- set -x |
|
15 |
- |
|
16 |
- pkg image-create --full --zone \ |
|
17 |
- --facet facet.locale.*=false \ |
|
18 |
- --facet facet.locale.POSIX=true \ |
|
19 |
- --facet facet.doc=false \ |
|
20 |
- --facet facet.doc.*=false \ |
|
21 |
- "$rootfsDir" |
|
22 |
- |
|
23 |
- pkg -R "$rootfsDir" set-property use-system-repo true |
|
24 |
- |
|
25 |
- pkg -R "$rootfsDir" set-property flush-content-cache-on-success true |
|
26 |
- |
|
27 |
- pkg -R "$rootfsDir" install core-os |
|
28 |
-) |
|
29 |
- |
|
30 |
-# Lay in stock configuration, set up milestone |
|
31 |
-# XXX This all may become optional in a base image |
|
32 |
-( |
|
33 |
- # faster to build repository database on tmpfs |
|
34 |
- REPO_DB=/system/volatile/repository.$$ |
|
35 |
- export SVCCFG_REPOSITORY=${REPO_DB} |
|
36 |
- export SVCCFG_DOOR_PATH=$rootfsDir/system/volatile/tmp_repo_door |
|
37 |
- |
|
38 |
- # Import base manifests. NOTE These are a combination of basic requirement |
|
39 |
- # and gleaned from container milestone manifest. They may change. |
|
40 |
- for m in $rootfsDir/lib/svc/manifest/system/environment.xml \ |
|
41 |
- $rootfsDir/lib/svc/manifest/system/svc/global.xml \ |
|
42 |
- $rootfsDir/lib/svc/manifest/system/svc/restarter.xml \ |
|
43 |
- $rootfsDir/lib/svc/manifest/network/dns/client.xml \ |
|
44 |
- $rootfsDir/lib/svc/manifest/system/name-service/switch.xml \ |
|
45 |
- $rootfsDir/lib/svc/manifest/system/name-service/cache.xml \ |
|
46 |
- $rootfsDir/lib/svc/manifest/milestone/container.xml ; do |
|
47 |
- svccfg import $m |
|
48 |
- done |
|
49 |
- |
|
50 |
- # Apply system layer profile, deleting unnecessary dependencies |
|
51 |
- svccfg apply $rootfsDir/etc/svc/profile/generic_container.xml |
|
52 |
- |
|
53 |
- # XXX Even if we keep a repo in the base image, this is definitely optional |
|
54 |
- svccfg apply $rootfsDir/etc/svc/profile/sysconfig/container_sc.xml |
|
55 |
- |
|
56 |
- for s in svc:/system/svc/restarter \ |
|
57 |
- svc:/system/environment \ |
|
58 |
- svc:/network/dns/client \ |
|
59 |
- svc:/system/name-service/switch \ |
|
60 |
- svc:/system/name-service/cache \ |
|
61 |
- svc:/system/svc/global \ |
|
62 |
- svc:/milestone/container ;do |
|
63 |
- svccfg -s $s refresh |
|
64 |
- done |
|
65 |
- |
|
66 |
- # now copy the built up repository into the base rootfs |
|
67 |
- mv $REPO_DB $rootfsDir/etc/svc/repository.db |
|
68 |
-) |
|
69 |
- |
|
70 |
-# pkg(1) needs the zoneproxy-client running in the container. |
|
71 |
-# use a simple wrapper to run it as needed. |
|
72 |
-# XXX maybe we go back to running this in SMF? |
|
73 |
-mv "$rootfsDir/usr/bin/pkg" "$rootfsDir/usr/bin/wrapped_pkg" |
|
74 |
-cat > "$rootfsDir/usr/bin/pkg" <<-'EOF' |
|
75 |
-#!/bin/sh |
|
76 |
-# |
|
77 |
-# THIS FILE CREATED DURING DOCKER BASE IMAGE CREATION |
|
78 |
-# |
|
79 |
-# The Solaris base image uses the sysrepo proxy mechanism. The |
|
80 |
-# IPS client pkg(1) requires the zoneproxy-client to reach the |
|
81 |
-# remote publisher origins through the host. This wrapper script |
|
82 |
-# enables and disables the proxy client as needed. This is a |
|
83 |
-# temporary solution. |
|
84 |
- |
|
85 |
-/usr/lib/zones/zoneproxy-client -s localhost:1008 |
|
86 |
-PKG_SYSREPO_URL=http://localhost:1008 /usr/bin/wrapped_pkg "$@" |
|
87 |
-pkill -9 zoneproxy-client |
|
88 |
-EOF |
|
89 |
-chmod +x "$rootfsDir/usr/bin/pkg" |
5 | 5 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,54 @@ |
0 |
+package libcontainerd |
|
1 |
+ |
|
2 |
+import ( |
|
3 |
+ "os" |
|
4 |
+ "path/filepath" |
|
5 |
+ "syscall" |
|
6 |
+ "time" |
|
7 |
+ |
|
8 |
+ "github.com/docker/docker/pkg/system" |
|
9 |
+) |
|
10 |
+ |
|
11 |
+const ( |
|
12 |
+ sockFile = "docker-containerd.sock" |
|
13 |
+ debugSockFile = "docker-containerd-debug.sock" |
|
14 |
+) |
|
15 |
+ |
|
16 |
+func (r *remote) setDefaults() { |
|
17 |
+ if r.GRPC.Address == "" { |
|
18 |
+ r.GRPC.Address = filepath.Join(r.stateDir, sockFile) |
|
19 |
+ } |
|
20 |
+ if r.Debug.Address == "" { |
|
21 |
+ r.Debug.Address = filepath.Join(r.stateDir, debugSockFile) |
|
22 |
+ } |
|
23 |
+ if r.Debug.Level == "" { |
|
24 |
+ r.Debug.Level = "info" |
|
25 |
+ } |
|
26 |
+ if r.OOMScore == 0 { |
|
27 |
+ r.OOMScore = -999 |
|
28 |
+ } |
|
29 |
+ if r.snapshotter == "" { |
|
30 |
+ r.snapshotter = "overlay" |
|
31 |
+ } |
|
32 |
+} |
|
33 |
+ |
|
34 |
+func (r *remote) stopDaemon() { |
|
35 |
+ // Ask the daemon to quit |
|
36 |
+ syscall.Kill(r.daemonPid, syscall.SIGTERM) |
|
37 |
+ // Wait up to 15secs for it to stop |
|
38 |
+ for i := time.Duration(0); i < shutdownTimeout; i += time.Second { |
|
39 |
+ if !system.IsProcessAlive(r.daemonPid) { |
|
40 |
+ break |
|
41 |
+ } |
|
42 |
+ time.Sleep(time.Second) |
|
43 |
+ } |
|
44 |
+ |
|
45 |
+ if system.IsProcessAlive(r.daemonPid) { |
|
46 |
+ r.logger.WithField("pid", r.daemonPid).Warn("daemon didn't stop within 15 secs, killing it") |
|
47 |
+ syscall.Kill(r.daemonPid, syscall.SIGKILL) |
|
48 |
+ } |
|
49 |
+} |
|
50 |
+ |
|
51 |
+func (r *remote) platformCleanup() { |
|
52 |
+ os.Remove(filepath.Join(r.stateDir, sockFile)) |
|
53 |
+} |
0 | 54 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,34 @@ |
0 |
+package libcontainerd |
|
1 |
+ |
|
2 |
+import "fmt" |
|
3 |
+ |
|
4 |
+// WithOOMScore defines the oom_score_adj to set for the containerd process. |
|
5 |
+func WithOOMScore(score int) RemoteOption { |
|
6 |
+ return oomScore(score) |
|
7 |
+} |
|
8 |
+ |
|
9 |
+type oomScore int |
|
10 |
+ |
|
11 |
+func (o oomScore) Apply(r Remote) error { |
|
12 |
+ if remote, ok := r.(*remote); ok { |
|
13 |
+ remote.OOMScore = int(o) |
|
14 |
+ return nil |
|
15 |
+ } |
|
16 |
+ return fmt.Errorf("WithOOMScore option not supported for this remote") |
|
17 |
+} |
|
18 |
+ |
|
19 |
+// WithSubreaper sets whether containerd should register itself as a |
|
20 |
+// subreaper |
|
21 |
+func WithSubreaper(reap bool) RemoteOption { |
|
22 |
+ return subreaper(reap) |
|
23 |
+} |
|
24 |
+ |
|
25 |
+type subreaper bool |
|
26 |
+ |
|
27 |
+func (s subreaper) Apply(r Remote) error { |
|
28 |
+ if remote, ok := r.(*remote); ok { |
|
29 |
+ remote.Subreaper = bool(s) |
|
30 |
+ return nil |
|
31 |
+ } |
|
32 |
+ return fmt.Errorf("WithSubreaper option not supported for this remote") |
|
33 |
+} |
0 | 34 |
deleted file mode 100644 |
... | ... |
@@ -1,36 +0,0 @@ |
1 |
-// +build linux solaris |
|
2 |
- |
|
3 |
-package libcontainerd |
|
4 |
- |
|
5 |
-import "fmt" |
|
6 |
- |
|
7 |
-// WithOOMScore defines the oom_score_adj to set for the containerd process. |
|
8 |
-func WithOOMScore(score int) RemoteOption { |
|
9 |
- return oomScore(score) |
|
10 |
-} |
|
11 |
- |
|
12 |
-type oomScore int |
|
13 |
- |
|
14 |
-func (o oomScore) Apply(r Remote) error { |
|
15 |
- if remote, ok := r.(*remote); ok { |
|
16 |
- remote.OOMScore = int(o) |
|
17 |
- return nil |
|
18 |
- } |
|
19 |
- return fmt.Errorf("WithOOMScore option not supported for this remote") |
|
20 |
-} |
|
21 |
- |
|
22 |
-// WithSubreaper sets whether containerd should register itself as a |
|
23 |
-// subreaper |
|
24 |
-func WithSubreaper(reap bool) RemoteOption { |
|
25 |
- return subreaper(reap) |
|
26 |
-} |
|
27 |
- |
|
28 |
-type subreaper bool |
|
29 |
- |
|
30 |
-func (s subreaper) Apply(r Remote) error { |
|
31 |
- if remote, ok := r.(*remote); ok { |
|
32 |
- remote.Subreaper = bool(s) |
|
33 |
- return nil |
|
34 |
- } |
|
35 |
- return fmt.Errorf("WithSubreaper option not supported for this remote") |
|
36 |
-} |
37 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,59 @@ |
0 |
+package libcontainerd |
|
1 |
+ |
|
2 |
+import ( |
|
3 |
+ "os" |
|
4 |
+ "path/filepath" |
|
5 |
+ |
|
6 |
+ "github.com/pkg/errors" |
|
7 |
+ "golang.org/x/sys/unix" |
|
8 |
+) |
|
9 |
+ |
|
10 |
+var fdNames = map[int]string{ |
|
11 |
+ unix.Stdin: "stdin", |
|
12 |
+ unix.Stdout: "stdout", |
|
13 |
+ unix.Stderr: "stderr", |
|
14 |
+} |
|
15 |
+ |
|
16 |
+func (p *process) pipeName(index int) string { |
|
17 |
+ return filepath.Join(p.root, p.id+"-"+fdNames[index]) |
|
18 |
+} |
|
19 |
+ |
|
20 |
+func (p *process) IOPaths() (string, string, string) { |
|
21 |
+ var ( |
|
22 |
+ stdin = p.pipeName(unix.Stdin) |
|
23 |
+ stdout = p.pipeName(unix.Stdout) |
|
24 |
+ stderr = p.pipeName(unix.Stderr) |
|
25 |
+ ) |
|
26 |
+ // TODO: debug why we're having zombies when I don't unset those |
|
27 |
+ if p.io.Stdin == nil { |
|
28 |
+ stdin = "" |
|
29 |
+ } |
|
30 |
+ if p.io.Stderr == nil { |
|
31 |
+ stderr = "" |
|
32 |
+ } |
|
33 |
+ return stdin, stdout, stderr |
|
34 |
+} |
|
35 |
+ |
|
36 |
+func (p *process) Cleanup() error { |
|
37 |
+ var retErr error |
|
38 |
+ |
|
39 |
+ // Ensure everything was closed |
|
40 |
+ p.CloseIO() |
|
41 |
+ |
|
42 |
+ for _, i := range [3]string{ |
|
43 |
+ p.pipeName(unix.Stdin), |
|
44 |
+ p.pipeName(unix.Stdout), |
|
45 |
+ p.pipeName(unix.Stderr), |
|
46 |
+ } { |
|
47 |
+ err := os.Remove(i) |
|
48 |
+ if err != nil { |
|
49 |
+ if retErr == nil { |
|
50 |
+ retErr = errors.Wrapf(err, "failed to remove %s", i) |
|
51 |
+ } else { |
|
52 |
+ retErr = errors.Wrapf(retErr, "failed to remove %s", i) |
|
53 |
+ } |
|
54 |
+ } |
|
55 |
+ } |
|
56 |
+ |
|
57 |
+ return retErr |
|
58 |
+} |
0 | 59 |
deleted file mode 100644 |
... | ... |
@@ -1,61 +0,0 @@ |
1 |
-// +build linux solaris |
|
2 |
- |
|
3 |
-package libcontainerd |
|
4 |
- |
|
5 |
-import ( |
|
6 |
- "os" |
|
7 |
- "path/filepath" |
|
8 |
- |
|
9 |
- "github.com/pkg/errors" |
|
10 |
- "golang.org/x/sys/unix" |
|
11 |
-) |
|
12 |
- |
|
13 |
-var fdNames = map[int]string{ |
|
14 |
- unix.Stdin: "stdin", |
|
15 |
- unix.Stdout: "stdout", |
|
16 |
- unix.Stderr: "stderr", |
|
17 |
-} |
|
18 |
- |
|
19 |
-func (p *process) pipeName(index int) string { |
|
20 |
- return filepath.Join(p.root, p.id+"-"+fdNames[index]) |
|
21 |
-} |
|
22 |
- |
|
23 |
-func (p *process) IOPaths() (string, string, string) { |
|
24 |
- var ( |
|
25 |
- stdin = p.pipeName(unix.Stdin) |
|
26 |
- stdout = p.pipeName(unix.Stdout) |
|
27 |
- stderr = p.pipeName(unix.Stderr) |
|
28 |
- ) |
|
29 |
- // TODO: debug why we're having zombies when I don't unset those |
|
30 |
- if p.io.Stdin == nil { |
|
31 |
- stdin = "" |
|
32 |
- } |
|
33 |
- if p.io.Stderr == nil { |
|
34 |
- stderr = "" |
|
35 |
- } |
|
36 |
- return stdin, stdout, stderr |
|
37 |
-} |
|
38 |
- |
|
39 |
-func (p *process) Cleanup() error { |
|
40 |
- var retErr error |
|
41 |
- |
|
42 |
- // Ensure everything was closed |
|
43 |
- p.CloseIO() |
|
44 |
- |
|
45 |
- for _, i := range [3]string{ |
|
46 |
- p.pipeName(unix.Stdin), |
|
47 |
- p.pipeName(unix.Stdout), |
|
48 |
- p.pipeName(unix.Stderr), |
|
49 |
- } { |
|
50 |
- err := os.Remove(i) |
|
51 |
- if err != nil { |
|
52 |
- if retErr == nil { |
|
53 |
- retErr = errors.Wrapf(err, "failed to remove %s", i) |
|
54 |
- } else { |
|
55 |
- retErr = errors.Wrapf(retErr, "failed to remove %s", i) |
|
56 |
- } |
|
57 |
- } |
|
58 |
- } |
|
59 |
- |
|
60 |
- return retErr |
|
61 |
-} |
62 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,56 +0,0 @@ |
1 |
-// +build linux solaris |
|
2 |
- |
|
3 |
-package libcontainerd |
|
4 |
- |
|
5 |
-import ( |
|
6 |
- "os" |
|
7 |
- "path/filepath" |
|
8 |
- "syscall" |
|
9 |
- "time" |
|
10 |
- |
|
11 |
- "github.com/docker/docker/pkg/system" |
|
12 |
-) |
|
13 |
- |
|
14 |
-const ( |
|
15 |
- sockFile = "docker-containerd.sock" |
|
16 |
- debugSockFile = "docker-containerd-debug.sock" |
|
17 |
-) |
|
18 |
- |
|
19 |
-func (r *remote) setDefaults() { |
|
20 |
- if r.GRPC.Address == "" { |
|
21 |
- r.GRPC.Address = filepath.Join(r.stateDir, sockFile) |
|
22 |
- } |
|
23 |
- if r.Debug.Address == "" { |
|
24 |
- r.Debug.Address = filepath.Join(r.stateDir, debugSockFile) |
|
25 |
- } |
|
26 |
- if r.Debug.Level == "" { |
|
27 |
- r.Debug.Level = "info" |
|
28 |
- } |
|
29 |
- if r.OOMScore == 0 { |
|
30 |
- r.OOMScore = -999 |
|
31 |
- } |
|
32 |
- if r.snapshotter == "" { |
|
33 |
- r.snapshotter = "overlay" |
|
34 |
- } |
|
35 |
-} |
|
36 |
- |
|
37 |
-func (r *remote) stopDaemon() { |
|
38 |
- // Ask the daemon to quit |
|
39 |
- syscall.Kill(r.daemonPid, syscall.SIGTERM) |
|
40 |
- // Wait up to 15secs for it to stop |
|
41 |
- for i := time.Duration(0); i < shutdownTimeout; i += time.Second { |
|
42 |
- if !system.IsProcessAlive(r.daemonPid) { |
|
43 |
- break |
|
44 |
- } |
|
45 |
- time.Sleep(time.Second) |
|
46 |
- } |
|
47 |
- |
|
48 |
- if system.IsProcessAlive(r.daemonPid) { |
|
49 |
- r.logger.WithField("pid", r.daemonPid).Warn("daemon didn't stop within 15 secs, killing it") |
|
50 |
- syscall.Kill(r.daemonPid, syscall.SIGKILL) |
|
51 |
- } |
|
52 |
-} |
|
53 |
- |
|
54 |
-func (r *remote) platformCleanup() { |
|
55 |
- os.Remove(filepath.Join(r.stateDir, sockFile)) |
|
56 |
-} |
... | ... |
@@ -13,7 +13,7 @@ func GetMounts() ([]*Info, error) { |
13 | 13 |
} |
14 | 14 |
|
15 | 15 |
// Mounted determines if a specified mountpoint has been mounted. |
16 |
-// On Linux it looks at /proc/self/mountinfo and on Solaris at mnttab. |
|
16 |
+// On Linux it looks at /proc/self/mountinfo. |
|
17 | 17 |
func Mounted(mountpoint string) (bool, error) { |
18 | 18 |
entries, err := parseMountTable() |
19 | 19 |
if err != nil { |
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-// +build !linux,!windows,!freebsd,!solaris,!darwin |
|
1 |
+// +build !linux,!windows,!freebsd,!darwin |
|
2 | 2 |
|
3 | 3 |
package reexec |
4 | 4 |
|
... | ... |
@@ -6,7 +6,7 @@ import ( |
6 | 6 |
"os/exec" |
7 | 7 |
) |
8 | 8 |
|
9 |
-// Command is unsupported on operating systems apart from Linux, Windows, Solaris and Darwin. |
|
9 |
+// Command is unsupported on operating systems apart from Linux, Windows, and Darwin. |
|
10 | 10 |
func Command(args ...string) *exec.Cmd { |
11 | 11 |
return nil |
12 | 12 |
} |
... | ... |
@@ -1,8 +1,8 @@ |
1 |
-// +build !linux,!solaris,!windows |
|
1 |
+// +build !linux,!windows |
|
2 | 2 |
|
3 | 3 |
package sysinfo |
4 | 4 |
|
5 |
-// New returns an empty SysInfo for non linux nor solaris for now. |
|
5 |
+// New returns an empty SysInfo for non linux for now. |
|
6 | 6 |
func New(quiet bool) *SysInfo { |
7 | 7 |
sysInfo := &SysInfo{} |
8 | 8 |
return sysInfo |