Skip to content

Commit

Permalink
fix(Job-Engine): Fixed a bug where the auxiliary container for the jo…
Browse files Browse the repository at this point in the history
…b-engine would not be downloaded (#100)
  • Loading branch information
ignacio-penas authored Nov 11, 2024
1 parent e422c08 commit 42127d1
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions workers/job_processor/executors/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package executors
import (
"context"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/mount"
docker "github.com/docker/docker/client"
log "github.com/sirupsen/logrus"
"nuvlaedge-go/common/constants"
)

Expand All @@ -20,9 +22,19 @@ func (d *Docker) Reboot() error {
return err
}

result, err := client.ImagePull(ctx, constants.BaseImage, image.PullOptions{})
if err != nil {
log.Errorf("Failed to pull image: %s", err)
return err
}

if err = result.Close(); err != nil {
log.Warnf("Failed to close image pull response: %s", err)
}

// Run a basic common container with the command "-c 'sleep 10 && echo b > /sysrq'"
// This will reboot the system after 10 seconds
_, err = client.ContainerCreate(ctx, &container.Config{
response, err := client.ContainerCreate(ctx, &container.Config{
Image: constants.BaseImage,
Cmd: []string{"sh", "-c", "sleep 10 && echo b > /sysrq"},
}, &container.HostConfig{
Expand All @@ -36,7 +48,18 @@ func (d *Docker) Reboot() error {
},
}, nil, nil, "")

return err
if err != nil {
return err
}

log.Infof("Reboot container created: %s", response.ID)
if len(response.Warnings) > 0 {
for _, warning := range response.Warnings {
log.Warnf("Warning creting Reboot container: %s", warning)
}
}

return client.ContainerStart(ctx, response.ID, container.StartOptions{})
}

func (d *Docker) InstallSSHKey(sshPub, user string) error {
Expand Down

0 comments on commit 42127d1

Please sign in to comment.