Skip to content

Commit

Permalink
Fix recreating container when the container don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinguidee committed Sep 27, 2023
1 parent a507e07 commit f8855da
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions services/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/antelman107/net-wait-go/wait"
"github.com/go-git/go-git/v5"
"github.com/google/uuid"
"github.com/vertex-center/vertex/adapter"
"github.com/vertex-center/vertex/config"
"github.com/vertex-center/vertex/pkg/log"
"github.com/vertex-center/vertex/pkg/storage"
Expand Down Expand Up @@ -714,8 +715,17 @@ func (s *InstanceService) RecreateContainer(instance *types.Instance) error {
}

err := s.dockerRunnerAdapter.Delete(instance)
if err != nil {
if err != nil && !errors.Is(err, adapter.ErrContainerNotFound) {
return err
}
return s.Start(instance.UUID)

go func() {
err := s.Start(instance.UUID)
if err != nil {
log.Error(err)
return
}
}()

return nil
}

0 comments on commit f8855da

Please sign in to comment.