Merge pull request #938 from brendandburns/exec

Address some follow up comments.
This commit is contained in:
Tim Hockin 2014-08-18 13:00:31 -07:00
commit a110fec51e
2 changed files with 21 additions and 2 deletions

View File

@ -158,7 +158,8 @@ type ExecProbe struct {
// Command is the command line to execute inside the container, the working directory for the
// command is root ('/') in the container's filesystem. The command is simply exec'd, it is
// not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use
// a shell, you need to explicitly call out to that shell
// a shell, you need to explicitly call out to that shell.
// A return code of zero is treated as 'Healthy', non-zero is 'Unhealthy'
Command []string `yaml:"command,omitempty" json:"command,omitempty"`
}

View File

@ -17,6 +17,8 @@ limitations under the License.
package health
import (
"sync"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/golang/glog"
)
@ -36,16 +38,32 @@ type HealthChecker interface {
HealthCheck(podFullName string, currentState api.PodState, container api.Container) (Status, error)
}
// protects checkers
var checkerLock = sync.Mutex{}
var checkers = map[string]HealthChecker{}
// Add a health checker to the list of known HealthChecker objects. Any subsequent call to
// NewHealthChecker will know about this HealthChecker.
// panics if 'key' is already present.
func AddHealthChecker(key string, checker HealthChecker) {
checkerLock.Lock()
defer checkerLock.Unlock()
if _, found := checkers[key]; found {
glog.Fatalf("HealthChecker already defined for key %s.", key)
}
checkers[key] = checker
}
// NewHealthChecker creates a new HealthChecker which supports multiple types of liveness probes.
func NewHealthChecker() HealthChecker {
checkerLock.Lock()
defer checkerLock.Unlock()
input := map[string]HealthChecker{}
for key, value := range checkers {
input[key] = value
}
return &muxHealthChecker{
checkers: checkers,
checkers: input,
}
}