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")
|
||||
)
|
||||
|
||||
// AttachError represents errors of attach
|
||||
type AttachError interface {
|
||||
IsDetached() bool
|
||||
}
|
||||
// DetachError is special error which returned in case of container detach.
|
||||
type DetachError struct{}
|
||||
|
||||
type detachError struct{}
|
||||
|
||||
func (e detachError) IsDetached() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (e detachError) Error() string {
|
||||
func (DetachError) Error() string {
|
||||
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 {
|
||||
src.Close()
|
||||
return 0, detachError{}
|
||||
return 0, DetachError{}
|
||||
}
|
||||
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)
|
||||
if err != nil {
|
||||
e, ok := err.(container.AttachError)
|
||||
if ok && e.IsDetached() {
|
||||
if _, ok := err.(container.DetachError); ok {
|
||||
daemon.LogContainerEvent(c, "detach")
|
||||
} else {
|
||||
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")
|
||||
case err := <-attachErr:
|
||||
if err != nil {
|
||||
e, ok := err.(container.AttachError)
|
||||
if !ok || !e.IsDetached() {
|
||||
return fmt.Errorf("attach failed with error: %v", err)
|
||||
if _, ok := err.(container.DetachError); !ok {
|
||||
return fmt.Errorf("exec attach failed with error: %v", err)
|
||||
}
|
||||
d.LogContainerEvent(c, "detach")
|
||||
d.LogContainerEvent(c, "exec_detach")
|
||||
}
|
||||
}
|
||||
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`
|
||||
* **exec_create** emitted by `docker exec`
|
||||
* **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.
|
||||
|
||||
|
@ -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 /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 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`.
|
||||
* `POST /containers/(id or name)/start` no longer accepts a `HostConfig`.
|
||||
* `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:
|
||||
|
||||
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:
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ parent = "smn_cli"
|
|||
|
||||
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:
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ information and real-time information.
|
|||
|
||||
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:
|
||||
|
||||
|
|
Loading…
Reference in a new issue