make container aliveness check part of the ipam & dns API
...rather than conducting it implicitly when an ID "looks like" a container ID. Closes #971
This commit is contained in:
1 parent
5559f1df2e
commit
6596c8b1a7
4 files changed
+19
-25
No files matched your search
@@ -1,20 +1,10 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/fsouza/go-dockerclient"
|
||||
. "github.com/weaveworks/weave/common"
|
||||
)
|
||||
|
||||
// Regexp that matches container IDs
|
||||
var containerIDregexp = regexp.MustCompile("^[a-f0-9]+$")
|
||||
|
||||
// IsContainerID returns True if the string provided is a valid container id
|
||||
func IsContainerID(idStr string) bool {
|
||||
return containerIDregexp.MatchString(idStr)
|
||||
}
|
||||
|
||||
// An observer for container events
|
||||
type ContainerObserver interface {
|
||||
ContainerDied(ident string) error
|
||||
@@ -62,12 +52,6 @@ func (c *Client) AddObserver(ob ContainerObserver) error {
|
||||
|
||||
// IsContainerNotRunning returns true if we have checked with Docker that the ID is not running
|
||||
func (c *Client) IsContainerNotRunning(idStr string) bool {
|
||||
if !IsContainerID(idStr) {
|
||||
Log.Debugf("[docker] '%s' does not seem to be a container id", idStr)
|
||||
return false
|
||||
}
|
||||
|
||||
// check with Docker whether the container is really running
|
||||
container, err := c.InspectContainer(idStr)
|
||||
if err == nil {
|
||||
return !container.State.Running
|
||||
|
||||
Reference in new issue
Block a user