mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Reduce and comment exports
This commit is contained in:
parent
7beac7a9af
commit
bca90f4866
@ -40,7 +40,7 @@ type HealthChecker interface {
|
||||
|
||||
// NewHealthChecker creates a new HealthChecker which supports multiple types of liveness probes.
|
||||
func NewHealthChecker() HealthChecker {
|
||||
return &MuxHealthChecker{
|
||||
return &muxHealthChecker{
|
||||
checkers: map[string]HealthChecker{
|
||||
"http": &HTTPHealthChecker{
|
||||
client: &http.Client{},
|
||||
@ -50,15 +50,15 @@ func NewHealthChecker() HealthChecker {
|
||||
}
|
||||
}
|
||||
|
||||
// MuxHealthChecker bundles multiple implementations of HealthChecker of different types.
|
||||
type MuxHealthChecker struct {
|
||||
// muxHealthChecker bundles multiple implementations of HealthChecker of different types.
|
||||
type muxHealthChecker struct {
|
||||
checkers map[string]HealthChecker
|
||||
}
|
||||
|
||||
// HealthCheck delegates the health-checking of the container to one of the bundled implementations.
|
||||
// It chooses an implementation according to container.LivenessProbe.Type.
|
||||
// If there is no matching health checker it returns Unknown, nil.
|
||||
func (m *MuxHealthChecker) HealthCheck(currentState api.PodState, container api.Container) (Status, error) {
|
||||
func (m *muxHealthChecker) HealthCheck(currentState api.PodState, container api.Container) (Status, error) {
|
||||
checker, ok := m.checkers[container.LivenessProbe.Type]
|
||||
if !ok || checker == nil {
|
||||
glog.Warningf("Failed to find health checker for %s %s", container.Name, container.LivenessProbe.Type)
|
||||
|
@ -105,7 +105,7 @@ func TestMuxHealthChecker(t *testing.T) {
|
||||
{Healthy, "http"},
|
||||
{Unknown, "ftp"},
|
||||
}
|
||||
mc := &MuxHealthChecker{
|
||||
mc := &muxHealthChecker{
|
||||
checkers: make(map[string]HealthChecker),
|
||||
}
|
||||
hc := &HTTPHealthChecker{
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
)
|
||||
|
||||
// HTTPGetInterface is an abstract interface for testability. It abstracts the interface of http.Client.Get.
|
||||
// This is exported because some other packages may want to do direct HTTP checks.
|
||||
type HTTPGetInterface interface {
|
||||
Get(url string) (*http.Response, error)
|
||||
}
|
||||
@ -78,6 +79,7 @@ func formatURL(host string, port int, path string) string {
|
||||
// If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Healthy.
|
||||
// If the HTTP response code is unsuccessful, it returns Unhealthy.
|
||||
// It returns Unknown and err if the HTTP communication itself fails.
|
||||
// This is exported because some other packages may want to do direct HTTP checks.
|
||||
func DoHTTPCheck(url string, client HTTPGetInterface) (Status, error) {
|
||||
res, err := client.Get(url)
|
||||
if err != nil {
|
||||
|
@ -61,6 +61,7 @@ func getTCPAddrParts(currentState api.PodState, container api.Container) (string
|
||||
// DoTCPCheck checks that a TCP socket to the address can be opened.
|
||||
// If the socket can be opened, it returns Healthy.
|
||||
// If the socket fails to open, it returns Unhealthy.
|
||||
// This is exported because some other packages may want to do direct TCP checks.
|
||||
func DoTCPCheck(addr string) (Status, error) {
|
||||
conn, err := net.Dial("tcp", addr)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user