mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #938 from brendandburns/exec
Address some follow up comments.
This commit is contained in:
commit
a110fec51e
@ -158,7 +158,8 @@ type ExecProbe struct {
|
|||||||
// Command is the command line to execute inside the container, the working directory for the
|
// 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
|
// 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
|
// 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"`
|
Command []string `yaml:"command,omitempty" json:"command,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package health
|
package health
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
@ -36,16 +38,32 @@ type HealthChecker interface {
|
|||||||
HealthCheck(podFullName string, currentState api.PodState, container api.Container) (Status, error)
|
HealthCheck(podFullName string, currentState api.PodState, container api.Container) (Status, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// protects checkers
|
||||||
|
var checkerLock = sync.Mutex{}
|
||||||
var checkers = map[string]HealthChecker{}
|
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) {
|
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
|
checkers[key] = checker
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHealthChecker creates a new HealthChecker which supports multiple types of liveness probes.
|
// NewHealthChecker creates a new HealthChecker which supports multiple types of liveness probes.
|
||||||
func NewHealthChecker() HealthChecker {
|
func NewHealthChecker() HealthChecker {
|
||||||
|
checkerLock.Lock()
|
||||||
|
defer checkerLock.Unlock()
|
||||||
|
input := map[string]HealthChecker{}
|
||||||
|
for key, value := range checkers {
|
||||||
|
input[key] = value
|
||||||
|
}
|
||||||
return &muxHealthChecker{
|
return &muxHealthChecker{
|
||||||
checkers: checkers,
|
checkers: input,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user