Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions containerd/containerd-shim/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (
)

// NewConsole returns an initialized console that can be used within a container by copying bytes
// from the master side to the slave that is attached as the tty for the container's init process.
// from the main side to the subordinate that is attached as the tty for the container's init process.
func newConsole(uid, gid int) (*os.File, string, error) {
master, err := os.OpenFile("/dev/ptmx", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0)
main, err := os.OpenFile("/dev/ptmx", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0)
if err != nil {
return nil, "", err
}
console, err := ptsname(master)
console, err := ptsname(main)
if err != nil {
return nil, "", err
}
if err := unlockpt(master); err != nil {
if err := unlockpt(main); err != nil {
return nil, "", err
}
if err := os.Chmod(console, 0600); err != nil {
Expand All @@ -29,7 +29,7 @@ func newConsole(uid, gid int) (*os.File, string, error) {
if err := os.Chown(console, uid, gid); err != nil {
return nil, "", err
}
return master, console, nil
return main, console, nil
}

func ioctl(fd uintptr, flag, data uintptr) error {
Expand All @@ -39,14 +39,14 @@ func ioctl(fd uintptr, flag, data uintptr) error {
return nil
}

// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
// unlockpt should be called before opening the slave side of a pty.
// unlockpt unlocks the subordinate pseudoterminal device corresponding to the main pseudoterminal referred to by f.
// unlockpt should be called before opening the subordinate side of a pty.
func unlockpt(f *os.File) error {
var u int32
return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u)))
}

// ptsname retrieves the name of the first available pts for the given master.
// ptsname retrieves the name of the first available pts for the given main.
func ptsname(f *os.File) (string, error) {
var n int32
if err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion containerd/containerd-shim/console_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// NewConsole returns an initalized console that can be used within a container by copying bytes
// from the master side to the slave that is attached as the tty for the container's init process.
// from the main side to the subordinate that is attached as the tty for the container's init process.
func newConsole(uid, gid int) (*os.File, string, error) {
return nil, "", errors.New("newConsole not implemented on Solaris")
}
12 changes: 6 additions & 6 deletions containerd/containerd-shim/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ func (p *process) openIO() error {
p.stdinCloser = stdinCloser

if p.state.Terminal {
master, console, err := newConsole(uid, gid)
main, console, err := newConsole(uid, gid)
if err != nil {
return err
}
p.console = master
p.console = main
p.consolePath = console
stdin, err := fifo.OpenFifo(ctx, p.state.Stdin, syscall.O_RDONLY, 0)
if err != nil {
return err
}

//io.Copy将stdin/stdout与master相连
//io.Copy将stdin/stdout与main相连
//p.state.Stdout和p.state.Stderr(方式为可读写)分别与i.Stdou和i.Stderr相连。接着打开p.state.Stdin为只读模式,再将i.Stdin和p.state.Stdin相连
go io.Copy(master, stdin)
go io.Copy(main, stdin)
stdoutw, err := fifo.OpenFifo(ctx, p.state.Stdout, syscall.O_WRONLY, 0)
if err != nil {
return err
Expand All @@ -64,8 +64,8 @@ func (p *process) openIO() error {
}
p.Add(1)
go func() {
io.Copy(stdoutw, master)
master.Close()
io.Copy(stdoutw, main)
main.Close()
stdoutr.Close()
stdoutw.Close()
p.Done()
Expand Down
12 changes: 6 additions & 6 deletions containerd/integration-test/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (cs *ContainerdSuite) StopDaemon(kill bool) {
select {
case err := <-cs.syncChild:
if err != nil {
fmt.Printf("master containerd did not exit cleanly: %v\n", err)
fmt.Printf("main containerd did not exit cleanly: %v\n", err)
}
done = true
case <-time.After(3 * time.Second):
Expand Down Expand Up @@ -203,17 +203,17 @@ func (cs *ContainerdSuite) SetUpSuite(c *check.C) {
// Create our output directory
cs.outputDir = fmt.Sprintf(utils.OutputDirFormat, time.Now().Format("2006-01-02_150405.000000"))

cs.stateDir = filepath.Join(cs.outputDir, "containerd-master")
cs.stateDir = filepath.Join(cs.outputDir, "containerd-main")
if err := os.MkdirAll(cs.stateDir, 0755); err != nil {
c.Fatalf("Unable to created output directory '%s': %v", cs.stateDir, err)
}

cs.grpcSocket = "unix://" + filepath.Join(cs.outputDir, "containerd-master", "containerd.sock")
cdLogFile := filepath.Join(cs.outputDir, "containerd-master", "containerd.log")
cs.grpcSocket = "unix://" + filepath.Join(cs.outputDir, "containerd-main", "containerd.sock")
cdLogFile := filepath.Join(cs.outputDir, "containerd-main", "containerd.log")

f, err := os.OpenFile(cdLogFile, os.O_CREATE|os.O_TRUNC|os.O_RDWR|os.O_SYNC, 0777)
if err != nil {
c.Fatalf("Failed to create master containerd log file: %v", err)
c.Fatalf("Failed to create main containerd log file: %v", err)
}
cs.logFile = f

Expand All @@ -232,7 +232,7 @@ func (cs *ContainerdSuite) TearDownSuite(c *check.C) {
select {
case err := <-cs.syncChild:
if err != nil {
c.Errorf("master containerd did not exit cleanly: %v", err)
c.Errorf("main containerd did not exit cleanly: %v", err)
}
done = true
case <-time.After(3 * time.Second):
Expand Down
12 changes: 6 additions & 6 deletions docker/moby-17.05.0-ce/api/types/mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ const (
PropagationRShared Propagation = "rshared"
// PropagationShared SHARED
PropagationShared Propagation = "shared"
// PropagationRSlave RSLAVE
PropagationRSlave Propagation = "rslave"
// PropagationSlave SLAVE
PropagationSlave Propagation = "slave"
// PropagationRSubordinate RSLAVE
PropagationRSubordinate Propagation = "rsubordinate"
// PropagationSubordinate SLAVE
PropagationSubordinate Propagation = "subordinate"
)

// Propagations is the list of all valid mount propagations
Expand All @@ -57,8 +57,8 @@ var Propagations = []Propagation{
PropagationPrivate,
PropagationRShared,
PropagationShared,
PropagationRSlave,
PropagationSlave,
PropagationRSubordinate,
PropagationSubordinate,
}

// Consistency represents the consistency requirements of a mount.
Expand Down
2 changes: 1 addition & 1 deletion docker/moby-17.05.0-ce/cli/command/network/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
flags.StringVar(&opts.ipamDriver, "ipam-driver", "default", "IP Address Management Driver")
flags.StringSliceVar(&opts.ipamSubnet, "subnet", []string{}, "Subnet in CIDR format that represents a network segment")
flags.StringSliceVar(&opts.ipamIPRange, "ip-range", []string{}, "Allocate container ip from a sub-range")
flags.StringSliceVar(&opts.ipamGateway, "gateway", []string{}, "IPv4 or IPv6 Gateway for the master subnet")
flags.StringSliceVar(&opts.ipamGateway, "gateway", []string{}, "IPv4 or IPv6 Gateway for the main subnet")

flags.Var(&opts.ipamAux, "aux-address", "Auxiliary IPv4 or IPv6 addresses used by Network driver")
flags.Var(&opts.ipamOpt, "ipam-opt", "Set IPAM driver specific options")
Expand Down
2 changes: 1 addition & 1 deletion docker/moby-17.05.0-ce/cli/compose/convert/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestConvertVolumeToMountConflictingOptionsBind(t *testing.T) {
Source: "foo",
Target: "/target",
Bind: &composetypes.ServiceVolumeBind{
Propagation: "slave",
Propagation: "subordinate",
},
}
_, err := convertVolumeToMount(config, volumes{}, namespace)
Expand Down
4 changes: 2 additions & 2 deletions docker/moby-17.05.0-ce/cli/compose/loader/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ func TestParseVolumeRelativeBindMountWindows(t *testing.T) {
}

func TestParseVolumeWithBindOptions(t *testing.T) {
volume, err := parseVolume("/source:/target:slave")
volume, err := parseVolume("/source:/target:subordinate")
expected := types.ServiceVolumeConfig{
Type: "bind",
Source: "/source",
Target: "/target",
Bind: &types.ServiceVolumeBind{Propagation: "slave"},
Bind: &types.ServiceVolumeBind{Propagation: "subordinate"},
}
assert.NilError(t, err)
assert.DeepEqual(t, volume, expected)
Expand Down
2 changes: 1 addition & 1 deletion docker/moby-17.05.0-ce/daemon/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig) (conta
}

/*
root@fd-mesos-master04.gz01:/var/lib/docker/containers/9be24974a6a7cf064f4a238f70260b13b15359248b3267602bfc49e00f13d670$ ls
root@fd-mesos-main04.gz01:/var/lib/docker/containers/9be24974a6a7cf064f4a238f70260b13b15359248b3267602bfc49e00f13d670$ ls
9be24974a6a7cf064f4a238f70260b13b15359248b3267602bfc49e00f13d670-json.log checkpoints config.v2.json hostconfig.json hostname hosts resolv.conf resolv.conf.hash shm

这些配置文件包含了9be24974a6a7cf064f4a238f70260b13b15359248b3267602bfc49e00f13d670这个容器的所有元数据
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ type transaction struct {
}

/*
root@fd-xxx-slave38.gz01:/var/lib/docker/devicemapper/metadata$ cat 73566c5a5e7f6cb18378dac0f4f0415b9d982f4231418fc2321de9395d386ab2-init
root@fd-xxx-subordinate38.gz01:/var/lib/docker/devicemapper/metadata$ cat 73566c5a5e7f6cb18378dac0f4f0415b9d982f4231418fc2321de9395d386ab2-init
{"device_id":39,"size":42949672960,"transaction_id":61,"initialized":false,"deleted":false}
root@fd-mesos-slave38.gz01:/var/lib/docker/devicemapper/metadata$
root@fd-mesos-subordinate38.gz01:/var/lib/docker/devicemapper/metadata$
*/
// /var/lib/docker/devicemapper/metadata 文件夹中的json文件内容反序列号后存入devInfo结构的各个变量中,赋值初始化见 loadMetadata
// DeviceSet:thin pool数据结构 DevInfo:thin device数据结构
Expand Down Expand Up @@ -1878,7 +1878,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
// - If <inode> is defined, use that file inside the device as a loopback image. Otherwise use the device itself.

/*
root@ob-slave-465.gz01:/var/lib/docker/devicemapper$ stat /var/lib/docker/devicemapper/
root@ob-subordinate-465.gz01:/var/lib/docker/devicemapper$ stat /var/lib/docker/devicemapper/
File: '/var/lib/docker/devicemapper/'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 804h/2052d Inode: 1184401 Links: 4
Expand Down Expand Up @@ -1916,7 +1916,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
// If the pool doesn't exist, create it
//dockerd -D -s devicemapper,并且不要配置/etc/docker/daemon.json的时候会走到这个流程
/*
root@ob-slave-465.gz01:/home/odin/yangyazhou$ cat /etc/docker/daemon.json
root@ob-subordinate-465.gz01:/home/odin/yangyazhou$ cat /etc/docker/daemon.json
{
"storage-driver": "devicemapper",
"storage-opts": [
Expand Down
2 changes: 1 addition & 1 deletion docker/moby-17.05.0-ce/daemon/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (daemon *Daemon) ContainerInspectCurrent(name string, size bool) (*types.Co
}, nil
}

// containerInspect120 serializes the master version of a container into a json type.
// containerInspect120 serializes the main version of a container into a json type.
func (daemon *Daemon) containerInspect120(name string) (*v1p20.ContainerJSON, error) {
container, err := daemon.GetContainer(name)
if err != nil {
Expand Down
28 changes: 14 additions & 14 deletions docker/moby-17.05.0-ce/daemon/oci_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,10 @@ func ensureShared(path string) error {
return nil
}

// Ensure mount point on which path is mounted, is either shared or slave.
func ensureSharedOrSlave(path string) error {
// Ensure mount point on which path is mounted, is either shared or subordinate.
func ensureSharedOrSubordinate(path string) error {
sharedMount := false
slaveMount := false
subordinateMount := false

sourceMount, optionalOpts, err := getSourceMount(path)
if err != nil {
Expand All @@ -443,14 +443,14 @@ func ensureSharedOrSlave(path string) error {
if strings.HasPrefix(opt, "shared:") {
sharedMount = true
break
} else if strings.HasPrefix(opt, "master:") {
slaveMount = true
} else if strings.HasPrefix(opt, "main:") {
subordinateMount = true
break
}
}

if !sharedMount && !slaveMount {
return fmt.Errorf("Path %s is mounted on %s but it is not a shared or slave mount.", path, sourceMount)
if !sharedMount && !subordinateMount {
return fmt.Errorf("Path %s is mounted on %s but it is not a shared or subordinate mount.", path, sourceMount)
}
return nil
}
Expand All @@ -461,17 +461,17 @@ var (
"rprivate": mount.RPRIVATE,
"shared": mount.SHARED,
"rshared": mount.RSHARED,
"slave": mount.SLAVE,
"rslave": mount.RSLAVE,
"subordinate": mount.SLAVE,
"rsubordinate": mount.RSLAVE,
}

mountPropagationReverseMap = map[int]string{
mount.PRIVATE: "private",
mount.RPRIVATE: "rprivate",
mount.SHARED: "shared",
mount.RSHARED: "rshared",
mount.SLAVE: "slave",
mount.RSLAVE: "rslave",
mount.SLAVE: "subordinate",
mount.RSLAVE: "rsubordinate",
}
)

Expand Down Expand Up @@ -521,9 +521,9 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c

// Determine property of RootPropagation based on volume
// properties. If a volume is shared, then keep root propagation
// shared. This should work for slave and private volumes too.
// shared. This should work for subordinate and private volumes too.
//
// For slave volumes, it can be either [r]shared/[r]slave.
// For subordinate volumes, it can be either [r]shared/[r]subordinate.
//
// For private volumes any root propagation value should work.
pFlag := mountPropagationMap[m.Propagation]
Expand All @@ -536,7 +536,7 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c
s.Linux.RootfsPropagation = mountPropagationReverseMap[mount.SHARED]
}
} else if pFlag == mount.SLAVE || pFlag == mount.RSLAVE {
if err := ensureSharedOrSlave(m.Source); err != nil {
if err := ensureSharedOrSubordinate(m.Source); err != nil {
return err
}
rootpg := mountPropagationMap[s.Linux.RootfsPropagation]
Expand Down
16 changes: 8 additions & 8 deletions docker/moby-17.05.0-ce/distribution/xfer/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Transfer interface {
Close()
Done() <-chan struct{}
Released() <-chan struct{}
Broadcast(masterProgressChan <-chan progress.Progress)
Broadcast(mainProgressChan <-chan progress.Progress)
}

type transfer struct {
Expand All @@ -67,7 +67,7 @@ type transfer struct {
// the transfer is no longer tracked by the transfer manager.
released chan struct{}

// broadcastDone is true if the master progress channel has closed.
// broadcastDone is true if the main progress channel has closed.
broadcastDone bool
// closed is true if Close has been called
closed bool
Expand Down Expand Up @@ -96,22 +96,22 @@ func NewTransfer() Transfer {
}

// Broadcast copies the progress and error output to all viewers.
func (t *transfer) Broadcast(masterProgressChan <-chan progress.Progress) {
func (t *transfer) Broadcast(mainProgressChan <-chan progress.Progress) {
for {
var (
p progress.Progress
ok bool
)
select {
case p, ok = <-masterProgressChan:
case p, ok = <-mainProgressChan:
default:
// We've depleted the channel, so now we can handle
// reads on broadcastSyncChan to let detaching watchers
// know we're caught up.
select {
case <-t.broadcastSyncChan:
continue
case p, ok = <-masterProgressChan:
case p, ok = <-mainProgressChan:
}
}

Expand Down Expand Up @@ -356,11 +356,11 @@ func (tm *transferManager) Transfer(key string, xferFunc DoFunc, progressOutput
tm.waitingTransfers = append(tm.waitingTransfers, start)
}

masterProgressChan := make(chan progress.Progress)
mainProgressChan := make(chan progress.Progress)
//(ldm *LayerDownloadManager) makeDownloadFunc
xfer := xferFunc(masterProgressChan, start, inactive)
xfer := xferFunc(mainProgressChan, start, inactive)
watcher := xfer.Watch(progressOutput)
go xfer.Broadcast(masterProgressChan)
go xfer.Broadcast(mainProgressChan)
tm.transfers[key] = xfer

// When the transfer is finished, remove from the map.
Expand Down
Loading