Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
ContainerDevice: add AttachError to handle device attach error
Browse files Browse the repository at this point in the history
Got "docker: Error response from daemon: OCI runtime create failed:
QMP command failed: unknown." when "docker run --privileged" with kata.
The cause is a device got a error when attach to sandbox.

This error doesn't affect the execution of kata.  So just output the
error and record it in AttachError let kataAgent ignore it.

Signed-off-by: Hui Zhu <[email protected]>
  • Loading branch information
teawater committed Oct 17, 2018
1 parent d00742f commit 1d029e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ type ContainerDevice struct {
ID string
// ContainerPath is device path displayed in container
ContainerPath string
// True if device attach get error but ignored
AttachError bool
}

// Container is composed of a set of containers and a runtime environment.
Expand Down Expand Up @@ -1142,9 +1144,14 @@ func (c *Container) attachDevices() error {
// there's no need to do rollback when error happens,
// because if attachDevices fails, container creation will fail too,
// and rollbackFailingContainerCreation could do all the rollbacks
for _, dev := range c.devices {
for id, dev := range c.devices {
if err := c.sandbox.devManager.AttachDevice(dev.ID, c.sandbox); err != nil {
return err
c.devices[id].AttachError = true
c.Logger().WithFields(logrus.Fields{
"container": c.id,
"device-id": dev.ID,
"device-containerpath": dev.ContainerPath,
}).WithError(err).Error("attach device failed but ignored")
}
}

Expand Down
3 changes: 3 additions & 0 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,9 @@ func (k *kataAgent) handleShm(grpcSpec *grpc.Spec, sandbox *Sandbox) {

func (k *kataAgent) appendDevices(deviceList []*grpc.Device, c *Container) []*grpc.Device {
for _, dev := range c.devices {
if dev.AttachError {
continue
}
device := c.sandbox.devManager.GetDeviceByID(dev.ID)
if device == nil {
k.Logger().WithField("device", dev.ID).Error("failed to find device by id")
Expand Down

0 comments on commit 1d029e4

Please sign in to comment.