forked from kubernetes-sigs/kind
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a preflight check that asserts docker connectivity
Assert that the docker daemon is running, and that we're able to connect to it. This is done by executing 'docker ps', and checking the exit code. This updates kubernetes-sigs#39 This fixes kubernetes-sigs#554
- Loading branch information
Showing
8 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package runtime | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"os/exec" | ||
) | ||
|
||
// Preflight runs checks to make sure that the container runtime | ||
// is working as expected | ||
func Preflight() error { | ||
checks := []func() error{ | ||
dockerIsRunning, | ||
} | ||
|
||
for _, check := range checks { | ||
if err := check(); err != nil { | ||
return errors.Wrap(err, "Preflight check failed") | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// dockerIsRunning asserts that the docker daemon is running and is responsive | ||
func dockerIsRunning() error { | ||
err := exec.Command("docker", "ps").Run() | ||
if err != nil { | ||
return errors.Wrap(err, "Could not connect to a docker daemon") | ||
} | ||
return nil | ||
} |