Skip to content

Commit

Permalink
fix: unzip not waited before removing container
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Nov 13, 2023
1 parent 389a5f2 commit 43a3ba6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
17 changes: 17 additions & 0 deletions docker_executor/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ type DockerClient struct {

const networkName = "cyanprint"

func (d *DockerClient) WaitContainer(ref DockerContainerReference) error {

name := DockerContainerToString(ref)

statusCh, errCh := d.Docker.ContainerWait(d.Context, name, container.WaitConditionNotRunning)
select {
case e := <-errCh:
if e != nil {
return e
}
case <-statusCh:
}

return nil

}

func (d *DockerClient) ListImages() ([]DockerImageReference, error) {

f := filters.NewArgs()
Expand Down
8 changes: 7 additions & 1 deletion docker_executor/template_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,19 @@ func (de TemplateExecutor) startVolume(volRef DockerVolumeReference) error {

fmt.Println("🚧 Unzipping volume ", volRef.CyanId)
err = d.CreateContainerWithVolume(unzipContainer, volRef, unzipImage)
if err != nil {
fmt.Println("🚨 Failed to start unzip container", volRef.CyanId)
return err
} else {
fmt.Println("⚙️ Still unzipping...", volRef.CyanId)
}
err = d.WaitContainer(unzipContainer)
if err != nil {
fmt.Println("🚨 Failed to unzip volume", volRef.CyanId)
return err
} else {
fmt.Println("✅ Volume unzipped", volRef.CyanId)
}

fmt.Println("🧹 Removing unzip container", volRef.CyanId)
err = d.RemoveContainer(unzipContainer)
if err != nil {
Expand Down

0 comments on commit 43a3ba6

Please sign in to comment.