Skip to content

Commit

Permalink
Update error message when docker is not available (#2217)
Browse files Browse the repository at this point in the history
* Update error message when docker is not available

Signed-off-by: Tanmay Chaudhry <tanmay.chaudhry@gmail.com>

* simplify error return code

Signed-off-by: Tanmay Chaudhry <tanmay.chaudhry@gmail.com>
  • Loading branch information
tchaudhry91 authored Jul 5, 2022
1 parent 59c4a56 commit d7edd6b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/storage/plugins/mongodb_docker/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ func EnsureMongoIsRunning(ctx context.Context, c *portercontext.Context, contain
ctx, span := tracing.StartSpan(ctx)
defer span.EndSpan()

if err := checkDockerAvailability(ctx); err != nil {
return nil, span.Error(errors.New("Docker is not available"))
}

if dataVol != "" {
err := exec.Command("docker", "volume", "inspect", dataVol).Run()
if err != nil {
Expand Down Expand Up @@ -238,3 +242,8 @@ func EnsureMongoIsRunning(ctx context.Context, c *portercontext.Context, contain
}
}
}

func checkDockerAvailability(ctx context.Context) error {
_, err := exec.Command("docker", "info").Output()
return err
}

0 comments on commit d7edd6b

Please sign in to comment.