mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
attach: replace interface with simple type
Also add docs to detach events Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
c80a2f2937
commit
3accde6dee
7 changed files with 15 additions and 21 deletions
|
@ -48,18 +48,10 @@ var (
|
||||||
errInvalidNetwork = fmt.Errorf("invalid network settings while building port map info")
|
errInvalidNetwork = fmt.Errorf("invalid network settings while building port map info")
|
||||||
)
|
)
|
||||||
|
|
||||||
// AttachError represents errors of attach
|
// DetachError is special error which returned in case of container detach.
|
||||||
type AttachError interface {
|
type DetachError struct{}
|
||||||
IsDetached() bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type detachError struct{}
|
func (DetachError) Error() string {
|
||||||
|
|
||||||
func (e detachError) IsDetached() bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e detachError) Error() string {
|
|
||||||
return "detached from container"
|
return "detached from container"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +499,7 @@ func copyEscapable(dst io.Writer, src io.ReadCloser, keys []byte) (written int64
|
||||||
}
|
}
|
||||||
if i == len(keys)-1 {
|
if i == len(keys)-1 {
|
||||||
src.Close()
|
src.Close()
|
||||||
return 0, detachError{}
|
return 0, DetachError{}
|
||||||
}
|
}
|
||||||
nr, er = src.Read(buf)
|
nr, er = src.Read(buf)
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,8 +121,7 @@ func (daemon *Daemon) containerAttach(c *container.Container, stdin io.ReadClose
|
||||||
}
|
}
|
||||||
err := <-c.Attach(stdinPipe, stdout, stderr, keys)
|
err := <-c.Attach(stdinPipe, stdout, stderr, keys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e, ok := err.(container.AttachError)
|
if _, ok := err.(container.DetachError); ok {
|
||||||
if ok && e.IsDetached() {
|
|
||||||
daemon.LogContainerEvent(c, "detach")
|
daemon.LogContainerEvent(c, "detach")
|
||||||
} else {
|
} else {
|
||||||
logrus.Errorf("attach failed with error: %v", err)
|
logrus.Errorf("attach failed with error: %v", err)
|
||||||
|
|
|
@ -222,11 +222,10 @@ func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.R
|
||||||
return fmt.Errorf("context cancelled")
|
return fmt.Errorf("context cancelled")
|
||||||
case err := <-attachErr:
|
case err := <-attachErr:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e, ok := err.(container.AttachError)
|
if _, ok := err.(container.DetachError); !ok {
|
||||||
if !ok || !e.IsDetached() {
|
return fmt.Errorf("exec attach failed with error: %v", err)
|
||||||
return fmt.Errorf("attach failed with error: %v", err)
|
|
||||||
}
|
}
|
||||||
d.LogContainerEvent(c, "detach")
|
d.LogContainerEvent(c, "exec_detach")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -99,6 +99,8 @@ Some container-related events are not affected by container state, so they are n
|
||||||
* **export** emitted by `docker export`
|
* **export** emitted by `docker export`
|
||||||
* **exec_create** emitted by `docker exec`
|
* **exec_create** emitted by `docker exec`
|
||||||
* **exec_start** emitted by `docker exec` after **exec_create**
|
* **exec_start** emitted by `docker exec` after **exec_create**
|
||||||
|
* **detach** emitted when client is detached from container process
|
||||||
|
* **exec_detach** emitted when client is detached from exec process
|
||||||
|
|
||||||
Running `docker rmi` emits an **untag** event when removing an image name. The `rmi` command may also emit **delete** events when images are deleted by ID directly or by deleting the last tag referring to the image.
|
Running `docker rmi` emits an **untag** event when removing an image name. The `rmi` command may also emit **delete** events when images are deleted by ID directly or by deleting the last tag referring to the image.
|
||||||
|
|
||||||
|
@ -121,6 +123,8 @@ This section lists each version from latest to oldest. Each listing includes a
|
||||||
* `GET /images/search` now takes a `filters` query parameter.
|
* `GET /images/search` now takes a `filters` query parameter.
|
||||||
* `GET /events` now supports a `reload` event that is emitted when the daemon configuration is reloaded.
|
* `GET /events` now supports a `reload` event that is emitted when the daemon configuration is reloaded.
|
||||||
* `GET /events` now supports filtering by daemon name or ID.
|
* `GET /events` now supports filtering by daemon name or ID.
|
||||||
|
* `GET /events` now supports a `detach` event that is emitted on detaching from container process.
|
||||||
|
* `GET /events` now supports an `exec_detach ` event that is emitted on detaching from exec process.
|
||||||
* `GET /images/json` now supports filters `since` and `before`.
|
* `GET /images/json` now supports filters `since` and `before`.
|
||||||
* `POST /containers/(id or name)/start` no longer accepts a `HostConfig`.
|
* `POST /containers/(id or name)/start` no longer accepts a `HostConfig`.
|
||||||
* `POST /images/(name)/tag` no longer has a `force` query parameter.
|
* `POST /images/(name)/tag` no longer has a `force` query parameter.
|
||||||
|
|
|
@ -2404,7 +2404,7 @@ Get container events from docker, either in real time via streaming, or via poll
|
||||||
|
|
||||||
Docker containers report the following events:
|
Docker containers report the following events:
|
||||||
|
|
||||||
attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
|
attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
|
||||||
|
|
||||||
Docker images report the following events:
|
Docker images report the following events:
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ parent = "smn_cli"
|
||||||
|
|
||||||
Docker containers report the following events:
|
Docker containers report the following events:
|
||||||
|
|
||||||
attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
|
attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
|
||||||
|
|
||||||
Docker images report the following events:
|
Docker images report the following events:
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ information and real-time information.
|
||||||
|
|
||||||
Docker containers will report the following events:
|
Docker containers will report the following events:
|
||||||
|
|
||||||
attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
|
attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
|
||||||
|
|
||||||
Docker images report the following events:
|
Docker images report the following events:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue