Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Removing video container even if it is not running (fixes #597)
Browse files Browse the repository at this point in the history
  • Loading branch information
vania-pooh committed Jul 1, 2019
1 parent d2ec073 commit c3b4eb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 0 additions & 2 deletions docs/log-files.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ The following statuses are available:
| DEVTOOLS_SESSION_CLOSED | Sending devtools traffic was stopped
| DOWNLOADING_FILE | User requested to download file from browser container
| ENVIRONMENT_NOT_AVAILABLE | Browser with desired name and version does not exist
| FAILED_TO_KILL_VIDEO_CONTAINER | Failed to kill video container after timeout
| FAILED_TO_REMOVE_CONTAINER | Failed to remove Docker container
| FAILED_TO_TERMINATE_PROCESS | An error occurred while terminating driver process
| INIT | Server is starting
| KILLED_VIDEO_CONTAINER | Waiting for video container to stop timed out and it was killed
| LOG_LISTING | Received a request to list all log files
| LOG_ERROR | An error occurred when post-processing session logs
| METADATA | Metadata processing messages
Expand Down
16 changes: 7 additions & 9 deletions service/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (d *Docker) StartWithCancel() (*StartedService, error) {
ShmSize: getShmSize(d.Service),
Privileged: d.Privileged,
Resources: ctr.Resources{
Memory: mem,
Memory: mem,
NanoCPUs: cpu,
},
ExtraHosts: getExtraHosts(d.Service, d.Caps),
Expand Down Expand Up @@ -218,7 +218,7 @@ func (d *Docker) StartWithCancel() (*StartedService, error) {

var publishedPortsInfo map[string]string
if d.Service.PublishAllPorts {
publishedPortsInfo = getContainerPorts(d.Environment.Network, stat)
publishedPortsInfo = getContainerPorts(stat)
}

s := StartedService{
Expand Down Expand Up @@ -460,7 +460,7 @@ func getHostPort(env Environment, servicePort string, caps session.Caps, stat ty
return hp
}

func getContainerPorts(networkName string, stat types.ContainerJSON) map[string]string {
func getContainerPorts(stat types.ContainerJSON) map[string]string {
ns := stat.NetworkSettings

var exposedPorts = make(map[string]string)
Expand Down Expand Up @@ -562,14 +562,12 @@ func stopVideoContainer(ctx context.Context, cli *client.Client, requestId uint6
}
notRunning, doesNotExist := cli.ContainerWait(ctx, containerId, ctr.WaitConditionNotRunning)
select {
case <-notRunning:
case <-doesNotExist:
case <-notRunning:
removeContainer(ctx, cli, requestId, containerId)
return
case <-time.After(env.SessionDeleteTimeout):
err = cli.ContainerRemove(ctx, containerId, types.ContainerRemoveOptions{Force: true})
if err != nil {
log.Printf("[%d] [FAILED_TO_KILL_VIDEO_CONTAINER] [%s] [%v]", requestId, containerId, err)
}
log.Printf("[%d] [KILLED_VIDEO_CONTAINER] [%s] [%v]", requestId, containerId, err)
removeContainer(ctx, cli, requestId, containerId)
return
}
log.Printf("[%d] [STOPPED_VIDEO_CONTAINER] [%s]", requestId, containerId)
Expand Down

0 comments on commit c3b4eb7

Please sign in to comment.