Skip to content

Commit

Permalink
fix(edge stack) start unpacker container to delete host folder EE-5638 (
Browse files Browse the repository at this point in the history
  • Loading branch information
cmenginnz authored Jul 17, 2023
1 parent 35379a4 commit 15f18b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docker/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,15 @@ func ContainerDelete(name string, opts types.ContainerRemoveOptions) error {
return cli.ContainerRemove(context.Background(), name, opts)
})
}

func ContainerWait(name string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) {
var statusCh <-chan container.WaitResponse
var errCh <-chan error

withCli(func(cli *client.Client) error {
statusCh, errCh = cli.ContainerWait(context.Background(), name, condition)
return nil
})

return statusCh, errCh
}
13 changes: 13 additions & 0 deletions docker/docker_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ func removeAndCopy(src, dst string, stackID int, stackName, assetPath string, ne

defer removeUnpackerContainer(unpackerContainer)

if err = ContainerStart(unpackerContainer.ID, types.ContainerStartOptions{}); err != nil {
return err
}

statusCh, errCh := ContainerWait(unpackerContainer.ID, container.WaitConditionNotRunning)
select {
case err := <-errCh:
if err != nil {
return err
}
case <-statusCh:
}

if needCopy {
err = copyToContainer(assetPath, src, unpackerContainer.ID, dst)
}
Expand Down

0 comments on commit 15f18b6

Please sign in to comment.