mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
commit
09a3231e67
@ -163,9 +163,11 @@ func main() {
|
|||||||
float32(*registryPullQPS),
|
float32(*registryPullQPS),
|
||||||
*registryBurst)
|
*registryBurst)
|
||||||
|
|
||||||
health.AddHealthChecker("exec", health.NewExecHealthChecker(k))
|
// TODO: These should probably become more plugin-ish: register a factory func
|
||||||
health.AddHealthChecker("http", health.NewHTTPHealthChecker(&http.Client{}))
|
// in each checker's init(), iterate those here.
|
||||||
health.AddHealthChecker("tcp", &health.TCPHealthChecker{})
|
health.AddHealthChecker(health.NewExecHealthChecker(k))
|
||||||
|
health.AddHealthChecker(health.NewHTTPHealthChecker(&http.Client{}))
|
||||||
|
health.AddHealthChecker(&health.TCPHealthChecker{})
|
||||||
|
|
||||||
// start the kubelet
|
// start the kubelet
|
||||||
go util.Forever(func() { k.Run(cfg.Updates()) }, 0)
|
go util.Forever(func() { k.Run(cfg.Updates()) }, 0)
|
||||||
|
@ -29,26 +29,26 @@ import (
|
|||||||
func TestErrorNew(t *testing.T) {
|
func TestErrorNew(t *testing.T) {
|
||||||
err := NewAlreadyExists("test", "1")
|
err := NewAlreadyExists("test", "1")
|
||||||
if !IsAlreadyExists(err) {
|
if !IsAlreadyExists(err) {
|
||||||
t.Errorf("expected to be already_exists")
|
t.Errorf("expected to be %s", api.StatusReasonAlreadyExists)
|
||||||
}
|
}
|
||||||
if IsConflict(err) {
|
if IsConflict(err) {
|
||||||
t.Errorf("expected to not be confict")
|
t.Errorf("expected to not be %s", api.StatusReasonConflict)
|
||||||
}
|
}
|
||||||
if IsNotFound(err) {
|
if IsNotFound(err) {
|
||||||
t.Errorf(fmt.Sprintf("expected to not be %s", api.StatusReasonNotFound))
|
t.Errorf(fmt.Sprintf("expected to not be %s", api.StatusReasonNotFound))
|
||||||
}
|
}
|
||||||
if IsInvalid(err) {
|
if IsInvalid(err) {
|
||||||
t.Errorf("expected to not be invalid")
|
t.Errorf("expected to not be %s", api.StatusReasonInvalid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !IsConflict(NewConflict("test", "2", errors.New("message"))) {
|
if !IsConflict(NewConflict("test", "2", errors.New("message"))) {
|
||||||
t.Errorf("expected to be conflict")
|
t.Errorf("expected to be conflict")
|
||||||
}
|
}
|
||||||
if !IsNotFound(NewNotFound("test", "3")) {
|
if !IsNotFound(NewNotFound("test", "3")) {
|
||||||
t.Errorf("expected to be not found")
|
t.Errorf("expected to be %s", api.StatusReasonNotFound)
|
||||||
}
|
}
|
||||||
if !IsInvalid(NewInvalid("test", "2", nil)) {
|
if !IsInvalid(NewInvalid("test", "2", nil)) {
|
||||||
t.Errorf("expected to be invalid")
|
t.Errorf("expected to be %s", api.StatusReasonInvalid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ func TestNewInvalid(t *testing.T) {
|
|||||||
t.Errorf("%d: unexpected status: %#v", i, status)
|
t.Errorf("%d: unexpected status: %#v", i, status)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(expected, status.Details) {
|
if !reflect.DeepEqual(expected, status.Details) {
|
||||||
t.Errorf("%d: expected %#v, got %#v", expected, status.Details)
|
t.Errorf("%d: expected %#v, got %#v", i, expected, status.Details)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,22 +28,23 @@ import (
|
|||||||
// CauseType in api/types.go.
|
// CauseType in api/types.go.
|
||||||
type ValidationErrorType string
|
type ValidationErrorType string
|
||||||
|
|
||||||
|
// TODO: These values are duplicated in api/types.go, but there's a circular dep. Fix it.
|
||||||
const (
|
const (
|
||||||
// ValidationErrorTypeNotFound is used to report failure to find a requested value
|
// ValidationErrorTypeNotFound is used to report failure to find a requested value
|
||||||
// (e.g. looking up an ID).
|
// (e.g. looking up an ID).
|
||||||
ValidationErrorTypeNotFound ValidationErrorType = "fieldValueNotFound"
|
ValidationErrorTypeNotFound ValidationErrorType = "FieldValueNotFound"
|
||||||
// ValidationErrorTypeRequired is used to report required values that are not
|
// ValidationErrorTypeRequired is used to report required values that are not
|
||||||
// provided (e.g. empty strings, null values, or empty arrays).
|
// provided (e.g. empty strings, null values, or empty arrays).
|
||||||
ValidationErrorTypeRequired ValidationErrorType = "fieldValueRequired"
|
ValidationErrorTypeRequired ValidationErrorType = "FieldValueRequired"
|
||||||
// ValidationErrorTypeDuplicate is used to report collisions of values that must be
|
// ValidationErrorTypeDuplicate is used to report collisions of values that must be
|
||||||
// unique (e.g. unique IDs).
|
// unique (e.g. unique IDs).
|
||||||
ValidationErrorTypeDuplicate ValidationErrorType = "fieldValueDuplicate"
|
ValidationErrorTypeDuplicate ValidationErrorType = "FieldValueDuplicate"
|
||||||
// ValidationErrorTypeInvalid is used to report malformed values (e.g. failed regex
|
// ValidationErrorTypeInvalid is used to report malformed values (e.g. failed regex
|
||||||
// match).
|
// match).
|
||||||
ValidationErrorTypeInvalid ValidationErrorType = "fieldValueInvalid"
|
ValidationErrorTypeInvalid ValidationErrorType = "FieldValueInvalid"
|
||||||
// ValidationErrorTypeNotSupported is used to report valid (as per formatting rules)
|
// ValidationErrorTypeNotSupported is used to report valid (as per formatting rules)
|
||||||
// values that can not be handled (e.g. an enumerated string).
|
// values that can not be handled (e.g. an enumerated string).
|
||||||
ValidationErrorTypeNotSupported ValidationErrorType = "fieldValueNotSupported"
|
ValidationErrorTypeNotSupported ValidationErrorType = "FieldValueNotSupported"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ValueOf(t ValidationErrorType) string {
|
func ValueOf(t ValidationErrorType) string {
|
||||||
|
@ -100,6 +100,16 @@ type HostDirectory struct {
|
|||||||
|
|
||||||
type EmptyDirectory struct{}
|
type EmptyDirectory struct{}
|
||||||
|
|
||||||
|
// Protocol defines network protocols supported for things like conatiner ports.
|
||||||
|
type Protocol string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ProtocolTCP is the TCP protocol.
|
||||||
|
ProtocolTCP Protocol = "TCP"
|
||||||
|
// ProtocolUDP is the UDP protocol.
|
||||||
|
ProtocolUDP Protocol = "UDP"
|
||||||
|
)
|
||||||
|
|
||||||
// Port represents a network port in a single container.
|
// Port represents a network port in a single container.
|
||||||
type Port struct {
|
type Port struct {
|
||||||
// Optional: If specified, this must be a DNS_LABEL. Each named port
|
// Optional: If specified, this must be a DNS_LABEL. Each named port
|
||||||
@ -109,8 +119,8 @@ type Port struct {
|
|||||||
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
|
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
|
||||||
// Required: This must be a valid port number, 0 < x < 65536.
|
// Required: This must be a valid port number, 0 < x < 65536.
|
||||||
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
||||||
// Optional: Supports "TCP" and "UDP". Defaults to "TCP".
|
// Optional: Defaults to "TCP".
|
||||||
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||||
// Optional: What host IP to bind the external port to.
|
// Optional: What host IP to bind the external port to.
|
||||||
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
||||||
}
|
}
|
||||||
@ -161,8 +171,6 @@ type ExecAction struct {
|
|||||||
// LivenessProbe describes a liveness probe to be examined to the container.
|
// LivenessProbe describes a liveness probe to be examined to the container.
|
||||||
// TODO: pass structured data to the actions, and document that data here.
|
// TODO: pass structured data to the actions, and document that data here.
|
||||||
type LivenessProbe struct {
|
type LivenessProbe struct {
|
||||||
// Type of liveness probe. Current legal values "http", "tcp"
|
|
||||||
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
|
||||||
// HTTPGetProbe parameters, required if Type == 'http'
|
// HTTPGetProbe parameters, required if Type == 'http'
|
||||||
HTTPGet *HTTPGetAction `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
|
HTTPGet *HTTPGetAction `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
|
||||||
// TCPSocketProbe parameter, required if Type == 'tcp'
|
// TCPSocketProbe parameter, required if Type == 'tcp'
|
||||||
@ -381,8 +389,8 @@ type Service struct {
|
|||||||
|
|
||||||
// Required.
|
// Required.
|
||||||
Port int `json:"port" yaml:"port"`
|
Port int `json:"port" yaml:"port"`
|
||||||
// Optional: Supports "TCP" and "UDP". Defaults to "TCP".
|
// Optional: Defaults to "TCP".
|
||||||
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||||
|
|
||||||
// This service's labels.
|
// This service's labels.
|
||||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||||
@ -447,12 +455,12 @@ func (*Binding) IsAnAPIObject() {}
|
|||||||
// import both.
|
// import both.
|
||||||
type Status struct {
|
type Status struct {
|
||||||
JSONBase `json:",inline" yaml:",inline"`
|
JSONBase `json:",inline" yaml:",inline"`
|
||||||
// One of: "success", "failure", "working" (for operations not yet completed)
|
// One of: "Success", "Failure", "Working" (for operations not yet completed)
|
||||||
Status string `json:"status,omitempty" yaml:"status,omitempty"`
|
Status string `json:"status,omitempty" yaml:"status,omitempty"`
|
||||||
// A human-readable description of the status of this operation.
|
// A human-readable description of the status of this operation.
|
||||||
Message string `json:"message,omitempty" yaml:"message,omitempty"`
|
Message string `json:"message,omitempty" yaml:"message,omitempty"`
|
||||||
// A machine-readable description of why this operation is in the
|
// A machine-readable description of why this operation is in the
|
||||||
// "failure" or "working" status. If this value is empty there
|
// "Failure" or "Working" status. If this value is empty there
|
||||||
// is no information available. A Reason clarifies an HTTP status
|
// is no information available. A Reason clarifies an HTTP status
|
||||||
// code but does not override it.
|
// code but does not override it.
|
||||||
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty"`
|
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty"`
|
||||||
@ -487,9 +495,9 @@ type StatusDetails struct {
|
|||||||
|
|
||||||
// Values of Status.Status
|
// Values of Status.Status
|
||||||
const (
|
const (
|
||||||
StatusSuccess = "success"
|
StatusSuccess = "Success"
|
||||||
StatusFailure = "failure"
|
StatusFailure = "Failure"
|
||||||
StatusWorking = "working"
|
StatusWorking = "Working"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatusReason is an enumeration of possible failure causes. Each StatusReason
|
// StatusReason is an enumeration of possible failure causes. Each StatusReason
|
||||||
@ -514,7 +522,7 @@ const (
|
|||||||
// "Location" - HTTP header populated with a URL that can retrieved the final
|
// "Location" - HTTP header populated with a URL that can retrieved the final
|
||||||
// status of this operation.
|
// status of this operation.
|
||||||
// Status code 202
|
// Status code 202
|
||||||
StatusReasonWorking StatusReason = "working"
|
StatusReasonWorking StatusReason = "Working"
|
||||||
|
|
||||||
// StatusReasonNotFound means one or more resources required for this operation
|
// StatusReasonNotFound means one or more resources required for this operation
|
||||||
// could not be found.
|
// could not be found.
|
||||||
@ -524,21 +532,21 @@ const (
|
|||||||
// resource.
|
// resource.
|
||||||
// "id" string - the identifier of the missing resource
|
// "id" string - the identifier of the missing resource
|
||||||
// Status code 404
|
// Status code 404
|
||||||
StatusReasonNotFound StatusReason = "not_found"
|
StatusReasonNotFound StatusReason = "NotFound"
|
||||||
|
|
||||||
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
||||||
// Details (optional):
|
// Details (optional):
|
||||||
// "kind" string - the kind attribute of the conflicting resource
|
// "kind" string - the kind attribute of the conflicting resource
|
||||||
// "id" string - the identifier of the conflicting resource
|
// "id" string - the identifier of the conflicting resource
|
||||||
// Status code 409
|
// Status code 409
|
||||||
StatusReasonAlreadyExists StatusReason = "already_exists"
|
StatusReasonAlreadyExists StatusReason = "AlreadyExists"
|
||||||
|
|
||||||
// StatusReasonConflict means the requested update operation cannot be completed
|
// StatusReasonConflict means the requested update operation cannot be completed
|
||||||
// due to a conflict in the operation. The client may need to alter the request.
|
// due to a conflict in the operation. The client may need to alter the request.
|
||||||
// Each resource may define custom details that indicate the nature of the
|
// Each resource may define custom details that indicate the nature of the
|
||||||
// conflict.
|
// conflict.
|
||||||
// Status code 409
|
// Status code 409
|
||||||
StatusReasonConflict StatusReason = "conflict"
|
StatusReasonConflict StatusReason = "Conflict"
|
||||||
|
|
||||||
// StatusReasonInvalid means the requested create or update operation cannot be
|
// StatusReasonInvalid means the requested create or update operation cannot be
|
||||||
// completed due to invalid data provided as part of the request. The client may
|
// completed due to invalid data provided as part of the request. The client may
|
||||||
@ -551,7 +559,7 @@ const (
|
|||||||
// provided resource that was invalid. The code, message, and
|
// provided resource that was invalid. The code, message, and
|
||||||
// field attributes will be set.
|
// field attributes will be set.
|
||||||
// Status code 422
|
// Status code 422
|
||||||
StatusReasonInvalid StatusReason = "invalid"
|
StatusReasonInvalid StatusReason = "Invalid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatusCause provides more information about an api.Status failure, including
|
// StatusCause provides more information about an api.Status failure, including
|
||||||
@ -577,25 +585,25 @@ type StatusCause struct {
|
|||||||
|
|
||||||
// CauseType is a machine readable value providing more detail about what
|
// CauseType is a machine readable value providing more detail about what
|
||||||
// occured in a status response. An operation may have multiple causes for a
|
// occured in a status response. An operation may have multiple causes for a
|
||||||
// status (whether failure, success, or working).
|
// status (whether Failure, Success, or Working).
|
||||||
type CauseType string
|
type CauseType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
|
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
|
||||||
// (e.g. looking up an ID).
|
// (e.g. looking up an ID).
|
||||||
CauseTypeFieldValueNotFound CauseType = "fieldValueNotFound"
|
CauseTypeFieldValueNotFound CauseType = "FieldValueNotFound"
|
||||||
// CauseTypeFieldValueInvalid is used to report required values that are not
|
// CauseTypeFieldValueInvalid is used to report required values that are not
|
||||||
// provided (e.g. empty strings, null values, or empty arrays).
|
// provided (e.g. empty strings, null values, or empty arrays).
|
||||||
CauseTypeFieldValueRequired CauseType = "fieldValueRequired"
|
CauseTypeFieldValueRequired CauseType = "FieldValueRequired"
|
||||||
// CauseTypeFieldValueDuplicate is used to report collisions of values that must be
|
// CauseTypeFieldValueDuplicate is used to report collisions of values that must be
|
||||||
// unique (e.g. unique IDs).
|
// unique (e.g. unique IDs).
|
||||||
CauseTypeFieldValueDuplicate CauseType = "fieldValueDuplicate"
|
CauseTypeFieldValueDuplicate CauseType = "FieldValueDuplicate"
|
||||||
// CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex
|
// CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex
|
||||||
// match).
|
// match).
|
||||||
CauseTypeFieldValueInvalid CauseType = "fieldValueInvalid"
|
CauseTypeFieldValueInvalid CauseType = "FieldValueInvalid"
|
||||||
// CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules)
|
// CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules)
|
||||||
// values that can not be handled (e.g. an enumerated string).
|
// values that can not be handled (e.g. an enumerated string).
|
||||||
CauseTypeFieldValueNotSupported CauseType = "fieldValueNotSupported"
|
CauseTypeFieldValueNotSupported CauseType = "FieldValueNotSupported"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServerOp is an operation delivered to API clients.
|
// ServerOp is an operation delivered to API clients.
|
||||||
|
@ -100,6 +100,16 @@ type HostDirectory struct {
|
|||||||
|
|
||||||
type EmptyDirectory struct{}
|
type EmptyDirectory struct{}
|
||||||
|
|
||||||
|
// Protocol defines network protocols supported for things like conatiner ports.
|
||||||
|
type Protocol string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ProtocolTCP is the TCP protocol.
|
||||||
|
ProtocolTCP Protocol = "TCP"
|
||||||
|
// ProtocolUDP is the UDP protocol.
|
||||||
|
ProtocolUDP Protocol = "UDP"
|
||||||
|
)
|
||||||
|
|
||||||
// Port represents a network port in a single container.
|
// Port represents a network port in a single container.
|
||||||
type Port struct {
|
type Port struct {
|
||||||
// Optional: If specified, this must be a DNS_LABEL. Each named port
|
// Optional: If specified, this must be a DNS_LABEL. Each named port
|
||||||
@ -109,8 +119,8 @@ type Port struct {
|
|||||||
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
|
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
|
||||||
// Required: This must be a valid port number, 0 < x < 65536.
|
// Required: This must be a valid port number, 0 < x < 65536.
|
||||||
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
||||||
// Optional: Supports "TCP" and "UDP". Defaults to "TCP".
|
// Optional: Defaults to "TCP".
|
||||||
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||||
// Optional: What host IP to bind the external port to.
|
// Optional: What host IP to bind the external port to.
|
||||||
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
||||||
}
|
}
|
||||||
@ -171,8 +181,6 @@ type ExecAction struct {
|
|||||||
// LivenessProbe describes a liveness probe to be examined to the container.
|
// LivenessProbe describes a liveness probe to be examined to the container.
|
||||||
// TODO: pass structured data to the actions, and document that data here.
|
// TODO: pass structured data to the actions, and document that data here.
|
||||||
type LivenessProbe struct {
|
type LivenessProbe struct {
|
||||||
// Type of liveness probe. Current legal values "http", "tcp"
|
|
||||||
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
|
||||||
// HTTPGetProbe parameters, required if Type == 'http'
|
// HTTPGetProbe parameters, required if Type == 'http'
|
||||||
HTTPGet *HTTPGetAction `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
|
HTTPGet *HTTPGetAction `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
|
||||||
// TCPSocketProbe parameter, required if Type == 'tcp'
|
// TCPSocketProbe parameter, required if Type == 'tcp'
|
||||||
@ -394,8 +402,8 @@ type Service struct {
|
|||||||
|
|
||||||
// Required.
|
// Required.
|
||||||
Port int `json:"port" yaml:"port"`
|
Port int `json:"port" yaml:"port"`
|
||||||
// Optional: Supports "TCP" and "UDP". Defaults to "TCP".
|
// Optional: Defaults to "TCP".
|
||||||
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||||
|
|
||||||
// This service's labels.
|
// This service's labels.
|
||||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||||
@ -463,12 +471,12 @@ func (*Binding) IsAnAPIObject() {}
|
|||||||
// import both.
|
// import both.
|
||||||
type Status struct {
|
type Status struct {
|
||||||
JSONBase `json:",inline" yaml:",inline"`
|
JSONBase `json:",inline" yaml:",inline"`
|
||||||
// One of: "success", "failure", "working" (for operations not yet completed)
|
// One of: "Success", "Failure", "Working" (for operations not yet completed)
|
||||||
Status string `json:"status,omitempty" yaml:"status,omitempty"`
|
Status string `json:"status,omitempty" yaml:"status,omitempty"`
|
||||||
// A human-readable description of the status of this operation.
|
// A human-readable description of the status of this operation.
|
||||||
Message string `json:"message,omitempty" yaml:"message,omitempty"`
|
Message string `json:"message,omitempty" yaml:"message,omitempty"`
|
||||||
// A machine-readable description of why this operation is in the
|
// A machine-readable description of why this operation is in the
|
||||||
// "failure" or "working" status. If this value is empty there
|
// "Failure" or "Working" status. If this value is empty there
|
||||||
// is no information available. A Reason clarifies an HTTP status
|
// is no information available. A Reason clarifies an HTTP status
|
||||||
// code but does not override it.
|
// code but does not override it.
|
||||||
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty"`
|
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty"`
|
||||||
@ -503,9 +511,9 @@ type StatusDetails struct {
|
|||||||
|
|
||||||
// Values of Status.Status
|
// Values of Status.Status
|
||||||
const (
|
const (
|
||||||
StatusSuccess = "success"
|
StatusSuccess = "Success"
|
||||||
StatusFailure = "failure"
|
StatusFailure = "Failure"
|
||||||
StatusWorking = "working"
|
StatusWorking = "Working"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatusReason is an enumeration of possible failure causes. Each StatusReason
|
// StatusReason is an enumeration of possible failure causes. Each StatusReason
|
||||||
@ -530,7 +538,7 @@ const (
|
|||||||
// "Location" - HTTP header populated with a URL that can retrieved the final
|
// "Location" - HTTP header populated with a URL that can retrieved the final
|
||||||
// status of this operation.
|
// status of this operation.
|
||||||
// Status code 202
|
// Status code 202
|
||||||
StatusReasonWorking StatusReason = "working"
|
StatusReasonWorking StatusReason = "Working"
|
||||||
|
|
||||||
// StatusReasonNotFound means one or more resources required for this operation
|
// StatusReasonNotFound means one or more resources required for this operation
|
||||||
// could not be found.
|
// could not be found.
|
||||||
@ -540,21 +548,21 @@ const (
|
|||||||
// resource.
|
// resource.
|
||||||
// "id" string - the identifier of the missing resource
|
// "id" string - the identifier of the missing resource
|
||||||
// Status code 404
|
// Status code 404
|
||||||
StatusReasonNotFound StatusReason = "notFound"
|
StatusReasonNotFound StatusReason = "NotFound"
|
||||||
|
|
||||||
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
||||||
// Details (optional):
|
// Details (optional):
|
||||||
// "kind" string - the kind attribute of the conflicting resource
|
// "kind" string - the kind attribute of the conflicting resource
|
||||||
// "id" string - the identifier of the conflicting resource
|
// "id" string - the identifier of the conflicting resource
|
||||||
// Status code 409
|
// Status code 409
|
||||||
StatusReasonAlreadyExists StatusReason = "alreadyExists"
|
StatusReasonAlreadyExists StatusReason = "AlreadyExists"
|
||||||
|
|
||||||
// StatusReasonConflict means the requested update operation cannot be completed
|
// StatusReasonConflict means the requested update operation cannot be completed
|
||||||
// due to a conflict in the operation. The client may need to alter the request.
|
// due to a conflict in the operation. The client may need to alter the request.
|
||||||
// Each resource may define custom details that indicate the nature of the
|
// Each resource may define custom details that indicate the nature of the
|
||||||
// conflict.
|
// conflict.
|
||||||
// Status code 409
|
// Status code 409
|
||||||
StatusReasonConflict StatusReason = "conflict"
|
StatusReasonConflict StatusReason = "Conflict"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatusCause provides more information about an api.Status failure, including
|
// StatusCause provides more information about an api.Status failure, including
|
||||||
@ -580,25 +588,25 @@ type StatusCause struct {
|
|||||||
|
|
||||||
// CauseType is a machine readable value providing more detail about what
|
// CauseType is a machine readable value providing more detail about what
|
||||||
// occured in a status response. An operation may have multiple causes for a
|
// occured in a status response. An operation may have multiple causes for a
|
||||||
// status (whether failure, success, or working).
|
// status (whether Failure, Success, or Working).
|
||||||
type CauseType string
|
type CauseType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
|
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
|
||||||
// (e.g. looking up an ID).
|
// (e.g. looking up an ID).
|
||||||
CauseTypeFieldValueNotFound CauseType = "fieldValueNotFound"
|
CauseTypeFieldValueNotFound CauseType = "FieldValueNotFound"
|
||||||
// CauseTypeFieldValueInvalid is used to report required values that are not
|
// CauseTypeFieldValueInvalid is used to report required values that are not
|
||||||
// provided (e.g. empty strings, null values, or empty arrays).
|
// provided (e.g. empty strings, null values, or empty arrays).
|
||||||
CauseTypeFieldValueRequired CauseType = "fieldValueRequired"
|
CauseTypeFieldValueRequired CauseType = "FieldValueRequired"
|
||||||
// CauseTypeFieldValueDuplicate is used to report collisions of values that must be
|
// CauseTypeFieldValueDuplicate is used to report collisions of values that must be
|
||||||
// unique (e.g. unique IDs).
|
// unique (e.g. unique IDs).
|
||||||
CauseTypeFieldValueDuplicate CauseType = "fieldValueDuplicate"
|
CauseTypeFieldValueDuplicate CauseType = "FieldValueDuplicate"
|
||||||
// CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex
|
// CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex
|
||||||
// match).
|
// match).
|
||||||
CauseTypeFieldValueInvalid CauseType = "fieldValueInvalid"
|
CauseTypeFieldValueInvalid CauseType = "FieldValueInvalid"
|
||||||
// CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules)
|
// CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules)
|
||||||
// values that can not be handled (e.g. an enumerated string).
|
// values that can not be handled (e.g. an enumerated string).
|
||||||
CauseTypeFieldValueNotSupported CauseType = "fieldValueNotSupported"
|
CauseTypeFieldValueNotSupported CauseType = "FieldValueNotSupported"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServerOp is an operation delivered to API clients.
|
// ServerOp is an operation delivered to API clients.
|
||||||
|
@ -100,6 +100,16 @@ type HostDirectory struct {
|
|||||||
|
|
||||||
type EmptyDirectory struct{}
|
type EmptyDirectory struct{}
|
||||||
|
|
||||||
|
// Protocol defines network protocols supported for things like conatiner ports.
|
||||||
|
type Protocol string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ProtocolTCP is the TCP protocol.
|
||||||
|
ProtocolTCP Protocol = "TCP"
|
||||||
|
// ProtocolUDP is the UDP protocol.
|
||||||
|
ProtocolUDP Protocol = "UDP"
|
||||||
|
)
|
||||||
|
|
||||||
// Port represents a network port in a single container.
|
// Port represents a network port in a single container.
|
||||||
type Port struct {
|
type Port struct {
|
||||||
// Optional: If specified, this must be a DNS_LABEL. Each named port
|
// Optional: If specified, this must be a DNS_LABEL. Each named port
|
||||||
@ -109,8 +119,8 @@ type Port struct {
|
|||||||
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
|
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
|
||||||
// Required: This must be a valid port number, 0 < x < 65536.
|
// Required: This must be a valid port number, 0 < x < 65536.
|
||||||
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
||||||
// Optional: Supports "TCP" and "UDP". Defaults to "TCP".
|
// Optional: Defaults to "TCP".
|
||||||
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||||
// Optional: What host IP to bind the external port to.
|
// Optional: What host IP to bind the external port to.
|
||||||
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
||||||
}
|
}
|
||||||
@ -170,8 +180,6 @@ type ExecAction struct {
|
|||||||
// LivenessProbe describes a liveness probe to be examined to the container.
|
// LivenessProbe describes a liveness probe to be examined to the container.
|
||||||
// TODO: pass structured data to the actions, and document that data here.
|
// TODO: pass structured data to the actions, and document that data here.
|
||||||
type LivenessProbe struct {
|
type LivenessProbe struct {
|
||||||
// Type of liveness probe. Current legal values "http", "tcp"
|
|
||||||
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
|
||||||
// HTTPGetProbe parameters, required if Type == 'http'
|
// HTTPGetProbe parameters, required if Type == 'http'
|
||||||
HTTPGet *HTTPGetAction `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
|
HTTPGet *HTTPGetAction `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
|
||||||
// TCPSocketProbe parameter, required if Type == 'tcp'
|
// TCPSocketProbe parameter, required if Type == 'tcp'
|
||||||
@ -391,8 +399,8 @@ type Service struct {
|
|||||||
|
|
||||||
// Required.
|
// Required.
|
||||||
Port int `json:"port" yaml:"port"`
|
Port int `json:"port" yaml:"port"`
|
||||||
// Optional: Supports "TCP" and "UDP". Defaults to "TCP".
|
// Optional: Defaults to "TCP".
|
||||||
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||||
|
|
||||||
// This service's labels.
|
// This service's labels.
|
||||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||||
@ -460,12 +468,12 @@ func (*Binding) IsAnAPIObject() {}
|
|||||||
// import both.
|
// import both.
|
||||||
type Status struct {
|
type Status struct {
|
||||||
JSONBase `json:",inline" yaml:",inline"`
|
JSONBase `json:",inline" yaml:",inline"`
|
||||||
// One of: "success", "failure", "working" (for operations not yet completed)
|
// One of: "Success", "Failure", "Working" (for operations not yet completed)
|
||||||
Status string `json:"status,omitempty" yaml:"status,omitempty"`
|
Status string `json:"status,omitempty" yaml:"status,omitempty"`
|
||||||
// A human-readable description of the status of this operation.
|
// A human-readable description of the status of this operation.
|
||||||
Message string `json:"message,omitempty" yaml:"message,omitempty"`
|
Message string `json:"message,omitempty" yaml:"message,omitempty"`
|
||||||
// A machine-readable description of why this operation is in the
|
// A machine-readable description of why this operation is in the
|
||||||
// "failure" or "working" status. If this value is empty there
|
// "Failure" or "Working" status. If this value is empty there
|
||||||
// is no information available. A Reason clarifies an HTTP status
|
// is no information available. A Reason clarifies an HTTP status
|
||||||
// code but does not override it.
|
// code but does not override it.
|
||||||
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty"`
|
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty"`
|
||||||
@ -500,9 +508,9 @@ type StatusDetails struct {
|
|||||||
|
|
||||||
// Values of Status.Status
|
// Values of Status.Status
|
||||||
const (
|
const (
|
||||||
StatusSuccess = "success"
|
StatusSuccess = "Success"
|
||||||
StatusFailure = "failure"
|
StatusFailure = "Failure"
|
||||||
StatusWorking = "working"
|
StatusWorking = "Working"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatusReason is an enumeration of possible failure causes. Each StatusReason
|
// StatusReason is an enumeration of possible failure causes. Each StatusReason
|
||||||
@ -527,7 +535,7 @@ const (
|
|||||||
// "Location" - HTTP header populated with a URL that can retrieved the final
|
// "Location" - HTTP header populated with a URL that can retrieved the final
|
||||||
// status of this operation.
|
// status of this operation.
|
||||||
// Status code 202
|
// Status code 202
|
||||||
StatusReasonWorking StatusReason = "working"
|
StatusReasonWorking StatusReason = "Working"
|
||||||
|
|
||||||
// StatusReasonNotFound means one or more resources required for this operation
|
// StatusReasonNotFound means one or more resources required for this operation
|
||||||
// could not be found.
|
// could not be found.
|
||||||
@ -537,21 +545,21 @@ const (
|
|||||||
// resource.
|
// resource.
|
||||||
// "id" string - the identifier of the missing resource
|
// "id" string - the identifier of the missing resource
|
||||||
// Status code 404
|
// Status code 404
|
||||||
StatusReasonNotFound StatusReason = "not_found"
|
StatusReasonNotFound StatusReason = "NotFound"
|
||||||
|
|
||||||
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
||||||
// Details (optional):
|
// Details (optional):
|
||||||
// "kind" string - the kind attribute of the conflicting resource
|
// "kind" string - the kind attribute of the conflicting resource
|
||||||
// "id" string - the identifier of the conflicting resource
|
// "id" string - the identifier of the conflicting resource
|
||||||
// Status code 409
|
// Status code 409
|
||||||
StatusReasonAlreadyExists StatusReason = "already_exists"
|
StatusReasonAlreadyExists StatusReason = "AlreadyExists"
|
||||||
|
|
||||||
// StatusReasonConflict means the requested update operation cannot be completed
|
// StatusReasonConflict means the requested update operation cannot be completed
|
||||||
// due to a conflict in the operation. The client may need to alter the request.
|
// due to a conflict in the operation. The client may need to alter the request.
|
||||||
// Each resource may define custom details that indicate the nature of the
|
// Each resource may define custom details that indicate the nature of the
|
||||||
// conflict.
|
// conflict.
|
||||||
// Status code 409
|
// Status code 409
|
||||||
StatusReasonConflict StatusReason = "conflict"
|
StatusReasonConflict StatusReason = "Conflict"
|
||||||
|
|
||||||
// StatusReasonInvalid means the requested create or update operation cannot be
|
// StatusReasonInvalid means the requested create or update operation cannot be
|
||||||
// completed due to invalid data provided as part of the request. The client may
|
// completed due to invalid data provided as part of the request. The client may
|
||||||
@ -564,7 +572,7 @@ const (
|
|||||||
// provided resource that was invalid. The code, message, and
|
// provided resource that was invalid. The code, message, and
|
||||||
// field attributes will be set.
|
// field attributes will be set.
|
||||||
// Status code 422
|
// Status code 422
|
||||||
StatusReasonInvalid StatusReason = "invalid"
|
StatusReasonInvalid StatusReason = "Invalid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatusCause provides more information about an api.Status failure, including
|
// StatusCause provides more information about an api.Status failure, including
|
||||||
@ -590,25 +598,25 @@ type StatusCause struct {
|
|||||||
|
|
||||||
// CauseType is a machine readable value providing more detail about what
|
// CauseType is a machine readable value providing more detail about what
|
||||||
// occured in a status response. An operation may have multiple causes for a
|
// occured in a status response. An operation may have multiple causes for a
|
||||||
// status (whether failure, success, or working).
|
// status (whether Failure, Success, or Working).
|
||||||
type CauseType string
|
type CauseType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
|
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
|
||||||
// (e.g. looking up an ID).
|
// (e.g. looking up an ID).
|
||||||
CauseTypeFieldValueNotFound CauseType = "fieldValueNotFound"
|
CauseTypeFieldValueNotFound CauseType = "FieldValueNotFound"
|
||||||
// CauseTypeFieldValueInvalid is used to report required values that are not
|
// CauseTypeFieldValueInvalid is used to report required values that are not
|
||||||
// provided (e.g. empty strings, null values, or empty arrays).
|
// provided (e.g. empty strings, null values, or empty arrays).
|
||||||
CauseTypeFieldValueRequired CauseType = "fieldValueRequired"
|
CauseTypeFieldValueRequired CauseType = "FieldValueRequired"
|
||||||
// CauseTypeFieldValueDuplicate is used to report collisions of values that must be
|
// CauseTypeFieldValueDuplicate is used to report collisions of values that must be
|
||||||
// unique (e.g. unique IDs).
|
// unique (e.g. unique IDs).
|
||||||
CauseTypeFieldValueDuplicate CauseType = "fieldValueDuplicate"
|
CauseTypeFieldValueDuplicate CauseType = "FieldValueDuplicate"
|
||||||
// CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex
|
// CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex
|
||||||
// match).
|
// match).
|
||||||
CauseTypeFieldValueInvalid CauseType = "fieldValueInvalid"
|
CauseTypeFieldValueInvalid CauseType = "FieldValueInvalid"
|
||||||
// CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules)
|
// CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules)
|
||||||
// values that can not be handled (e.g. an enumerated string).
|
// values that can not be handled (e.g. an enumerated string).
|
||||||
CauseTypeFieldValueNotSupported CauseType = "fieldValueNotSupported"
|
CauseTypeFieldValueNotSupported CauseType = "FieldValueNotSupported"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServerOp is an operation delivered to API clients.
|
// ServerOp is an operation delivered to API clients.
|
||||||
|
@ -100,6 +100,16 @@ type HostDirectory struct {
|
|||||||
|
|
||||||
type EmptyDirectory struct{}
|
type EmptyDirectory struct{}
|
||||||
|
|
||||||
|
// Protocol defines network protocols supported for things like conatiner ports.
|
||||||
|
type Protocol string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ProtocolTCP is the TCP protocol.
|
||||||
|
ProtocolTCP Protocol = "TCP"
|
||||||
|
// ProtocolUDP is the UDP protocol.
|
||||||
|
ProtocolUDP Protocol = "UDP"
|
||||||
|
)
|
||||||
|
|
||||||
// Port represents a network port in a single container.
|
// Port represents a network port in a single container.
|
||||||
type Port struct {
|
type Port struct {
|
||||||
// Optional: If specified, this must be a DNS_LABEL. Each named port
|
// Optional: If specified, this must be a DNS_LABEL. Each named port
|
||||||
@ -109,8 +119,8 @@ type Port struct {
|
|||||||
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
|
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
|
||||||
// Required: This must be a valid port number, 0 < x < 65536.
|
// Required: This must be a valid port number, 0 < x < 65536.
|
||||||
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
||||||
// Optional: Supports "TCP" and "UDP". Defaults to "TCP".
|
// Optional: Defaults to "TCP".
|
||||||
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||||
// Optional: What host IP to bind the external port to.
|
// Optional: What host IP to bind the external port to.
|
||||||
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
||||||
}
|
}
|
||||||
@ -161,8 +171,6 @@ type ExecAction struct {
|
|||||||
// LivenessProbe describes a liveness probe to be examined to the container.
|
// LivenessProbe describes a liveness probe to be examined to the container.
|
||||||
// TODO: pass structured data to the actions, and document that data here.
|
// TODO: pass structured data to the actions, and document that data here.
|
||||||
type LivenessProbe struct {
|
type LivenessProbe struct {
|
||||||
// Type of liveness probe. Current legal values "http", "tcp"
|
|
||||||
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
|
||||||
// HTTPGetProbe parameters, required if Type == 'http'
|
// HTTPGetProbe parameters, required if Type == 'http'
|
||||||
HTTPGet *HTTPGetAction `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
|
HTTPGet *HTTPGetAction `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
|
||||||
// TCPSocketProbe parameter, required if Type == 'tcp'
|
// TCPSocketProbe parameter, required if Type == 'tcp'
|
||||||
@ -390,8 +398,8 @@ type Service struct {
|
|||||||
|
|
||||||
// Required.
|
// Required.
|
||||||
Port int `json:"port" yaml:"port"`
|
Port int `json:"port" yaml:"port"`
|
||||||
// Optional: Supports "TCP" and "UDP". Defaults to "TCP".
|
// Optional: Defaults to "TCP".
|
||||||
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||||
|
|
||||||
// This service's labels.
|
// This service's labels.
|
||||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||||
@ -456,12 +464,12 @@ func (*Binding) IsAnAPIObject() {}
|
|||||||
// import both.
|
// import both.
|
||||||
type Status struct {
|
type Status struct {
|
||||||
JSONBase `json:",inline" yaml:",inline"`
|
JSONBase `json:",inline" yaml:",inline"`
|
||||||
// One of: "success", "failure", "working" (for operations not yet completed)
|
// One of: "Success", "Failure", "Working" (for operations not yet completed)
|
||||||
Status string `json:"status,omitempty" yaml:"status,omitempty"`
|
Status string `json:"status,omitempty" yaml:"status,omitempty"`
|
||||||
// A human-readable description of the status of this operation.
|
// A human-readable description of the status of this operation.
|
||||||
Message string `json:"message,omitempty" yaml:"message,omitempty"`
|
Message string `json:"message,omitempty" yaml:"message,omitempty"`
|
||||||
// A machine-readable description of why this operation is in the
|
// A machine-readable description of why this operation is in the
|
||||||
// "failure" or "working" status. If this value is empty there
|
// "Failure" or "Working" status. If this value is empty there
|
||||||
// is no information available. A Reason clarifies an HTTP status
|
// is no information available. A Reason clarifies an HTTP status
|
||||||
// code but does not override it.
|
// code but does not override it.
|
||||||
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty"`
|
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty"`
|
||||||
@ -496,9 +504,9 @@ type StatusDetails struct {
|
|||||||
|
|
||||||
// Values of Status.Status
|
// Values of Status.Status
|
||||||
const (
|
const (
|
||||||
StatusSuccess = "success"
|
StatusSuccess = "Success"
|
||||||
StatusFailure = "failure"
|
StatusFailure = "Failure"
|
||||||
StatusWorking = "working"
|
StatusWorking = "Working"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatusReason is an enumeration of possible failure causes. Each StatusReason
|
// StatusReason is an enumeration of possible failure causes. Each StatusReason
|
||||||
@ -523,7 +531,7 @@ const (
|
|||||||
// "Location" - HTTP header populated with a URL that can retrieved the final
|
// "Location" - HTTP header populated with a URL that can retrieved the final
|
||||||
// status of this operation.
|
// status of this operation.
|
||||||
// Status code 202
|
// Status code 202
|
||||||
StatusReasonWorking StatusReason = "working"
|
StatusReasonWorking StatusReason = "Working"
|
||||||
|
|
||||||
// StatusReasonNotFound means one or more resources required for this operation
|
// StatusReasonNotFound means one or more resources required for this operation
|
||||||
// could not be found.
|
// could not be found.
|
||||||
@ -533,21 +541,21 @@ const (
|
|||||||
// resource.
|
// resource.
|
||||||
// "id" string - the identifier of the missing resource
|
// "id" string - the identifier of the missing resource
|
||||||
// Status code 404
|
// Status code 404
|
||||||
StatusReasonNotFound StatusReason = "not_found"
|
StatusReasonNotFound StatusReason = "NotFound"
|
||||||
|
|
||||||
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
||||||
// Details (optional):
|
// Details (optional):
|
||||||
// "kind" string - the kind attribute of the conflicting resource
|
// "kind" string - the kind attribute of the conflicting resource
|
||||||
// "id" string - the identifier of the conflicting resource
|
// "id" string - the identifier of the conflicting resource
|
||||||
// Status code 409
|
// Status code 409
|
||||||
StatusReasonAlreadyExists StatusReason = "already_exists"
|
StatusReasonAlreadyExists StatusReason = "AlreadyExists"
|
||||||
|
|
||||||
// StatusReasonConflict means the requested update operation cannot be completed
|
// StatusReasonConflict means the requested update operation cannot be completed
|
||||||
// due to a conflict in the operation. The client may need to alter the request.
|
// due to a conflict in the operation. The client may need to alter the request.
|
||||||
// Each resource may define custom details that indicate the nature of the
|
// Each resource may define custom details that indicate the nature of the
|
||||||
// conflict.
|
// conflict.
|
||||||
// Status code 409
|
// Status code 409
|
||||||
StatusReasonConflict StatusReason = "conflict"
|
StatusReasonConflict StatusReason = "Conflict"
|
||||||
|
|
||||||
// StatusReasonInvalid means the requested create or update operation cannot be
|
// StatusReasonInvalid means the requested create or update operation cannot be
|
||||||
// completed due to invalid data provided as part of the request. The client may
|
// completed due to invalid data provided as part of the request. The client may
|
||||||
@ -560,7 +568,7 @@ const (
|
|||||||
// provided resource that was invalid. The code, message, and
|
// provided resource that was invalid. The code, message, and
|
||||||
// field attributes will be set.
|
// field attributes will be set.
|
||||||
// Status code 422
|
// Status code 422
|
||||||
StatusReasonInvalid StatusReason = "invalid"
|
StatusReasonInvalid StatusReason = "Invalid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatusCause provides more information about an api.Status failure, including
|
// StatusCause provides more information about an api.Status failure, including
|
||||||
@ -586,25 +594,25 @@ type StatusCause struct {
|
|||||||
|
|
||||||
// CauseType is a machine readable value providing more detail about what
|
// CauseType is a machine readable value providing more detail about what
|
||||||
// occured in a status response. An operation may have multiple causes for a
|
// occured in a status response. An operation may have multiple causes for a
|
||||||
// status (whether failure, success, or working).
|
// status (whether Failure, Success, or Working).
|
||||||
type CauseType string
|
type CauseType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
|
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
|
||||||
// (e.g. looking up an ID).
|
// (e.g. looking up an ID).
|
||||||
CauseTypeFieldValueNotFound CauseType = "fieldValueNotFound"
|
CauseTypeFieldValueNotFound CauseType = "FieldValueNotFound"
|
||||||
// CauseTypeFieldValueInvalid is used to report required values that are not
|
// CauseTypeFieldValueInvalid is used to report required values that are not
|
||||||
// provided (e.g. empty strings, null values, or empty arrays).
|
// provided (e.g. empty strings, null values, or empty arrays).
|
||||||
CauseTypeFieldValueRequired CauseType = "fieldValueRequired"
|
CauseTypeFieldValueRequired CauseType = "FieldValueRequired"
|
||||||
// CauseTypeFieldValueDuplicate is used to report collisions of values that must be
|
// CauseTypeFieldValueDuplicate is used to report collisions of values that must be
|
||||||
// unique (e.g. unique IDs).
|
// unique (e.g. unique IDs).
|
||||||
CauseTypeFieldValueDuplicate CauseType = "fieldValueDuplicate"
|
CauseTypeFieldValueDuplicate CauseType = "FieldValueDuplicate"
|
||||||
// CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex
|
// CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex
|
||||||
// match).
|
// match).
|
||||||
CauseTypeFieldValueInvalid CauseType = "fieldValueInvalid"
|
CauseTypeFieldValueInvalid CauseType = "FieldValueInvalid"
|
||||||
// CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules)
|
// CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules)
|
||||||
// values that can not be handled (e.g. an enumerated string).
|
// values that can not be handled (e.g. an enumerated string).
|
||||||
CauseTypeFieldValueNotSupported CauseType = "fieldValueNotSupported"
|
CauseTypeFieldValueNotSupported CauseType = "FieldValueNotSupported"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServerOp is an operation delivered to API clients.
|
// ServerOp is an operation delivered to API clients.
|
||||||
|
@ -78,7 +78,7 @@ func validateHostDir(hostDir *api.HostDirectory) errs.ErrorList {
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
var supportedPortProtocols = util.NewStringSet("TCP", "UDP")
|
var supportedPortProtocols = util.NewStringSet(string(api.ProtocolTCP), string(api.ProtocolUDP))
|
||||||
|
|
||||||
func validatePorts(ports []api.Port) errs.ErrorList {
|
func validatePorts(ports []api.Port) errs.ErrorList {
|
||||||
allErrs := errs.ErrorList{}
|
allErrs := errs.ErrorList{}
|
||||||
@ -106,7 +106,7 @@ func validatePorts(ports []api.Port) errs.ErrorList {
|
|||||||
}
|
}
|
||||||
if len(port.Protocol) == 0 {
|
if len(port.Protocol) == 0 {
|
||||||
port.Protocol = "TCP"
|
port.Protocol = "TCP"
|
||||||
} else if !supportedPortProtocols.Has(strings.ToUpper(port.Protocol)) {
|
} else if !supportedPortProtocols.Has(strings.ToUpper(string(port.Protocol))) {
|
||||||
pErrs = append(pErrs, errs.NewFieldNotSupported("protocol", port.Protocol))
|
pErrs = append(pErrs, errs.NewFieldNotSupported("protocol", port.Protocol))
|
||||||
}
|
}
|
||||||
allErrs = append(allErrs, pErrs.PrefixIndex(i)...)
|
allErrs = append(allErrs, pErrs.PrefixIndex(i)...)
|
||||||
@ -330,7 +330,7 @@ func ValidateService(service *api.Service) errs.ErrorList {
|
|||||||
}
|
}
|
||||||
if len(service.Protocol) == 0 {
|
if len(service.Protocol) == 0 {
|
||||||
service.Protocol = "TCP"
|
service.Protocol = "TCP"
|
||||||
} else if !supportedPortProtocols.Has(strings.ToUpper(service.Protocol)) {
|
} else if !supportedPortProtocols.Has(strings.ToUpper(string(service.Protocol))) {
|
||||||
allErrs = append(allErrs, errs.NewFieldNotSupported("protocol", service.Protocol))
|
allErrs = append(allErrs, errs.NewFieldNotSupported("protocol", service.Protocol))
|
||||||
}
|
}
|
||||||
if labels.Set(service.Selector).AsSelector().Empty() {
|
if labels.Set(service.Selector).AsSelector().Empty() {
|
||||||
|
@ -706,7 +706,7 @@ func TestAsyncCreateError(t *testing.T) {
|
|||||||
expectedStatus := &api.Status{
|
expectedStatus := &api.Status{
|
||||||
Status: api.StatusFailure,
|
Status: api.StatusFailure,
|
||||||
Code: http.StatusConflict,
|
Code: http.StatusConflict,
|
||||||
Reason: "already_exists",
|
Reason: "AlreadyExists",
|
||||||
Message: expectedErr.Error(),
|
Message: expectedErr.Error(),
|
||||||
Details: &api.StatusDetails{
|
Details: &api.StatusDetails{
|
||||||
Kind: "foo",
|
Kind: "foo",
|
||||||
|
@ -39,7 +39,7 @@ func TestErrorsToAPIStatus(t *testing.T) {
|
|||||||
errors.NewAlreadyExists("foo", "bar"): {
|
errors.NewAlreadyExists("foo", "bar"): {
|
||||||
Status: api.StatusFailure,
|
Status: api.StatusFailure,
|
||||||
Code: http.StatusConflict,
|
Code: http.StatusConflict,
|
||||||
Reason: "already_exists",
|
Reason: "AlreadyExists",
|
||||||
Message: "foo \"bar\" already exists",
|
Message: "foo \"bar\" already exists",
|
||||||
Details: &api.StatusDetails{
|
Details: &api.StatusDetails{
|
||||||
Kind: "foo",
|
Kind: "foo",
|
||||||
@ -49,7 +49,7 @@ func TestErrorsToAPIStatus(t *testing.T) {
|
|||||||
errors.NewConflict("foo", "bar", stderrs.New("failure")): {
|
errors.NewConflict("foo", "bar", stderrs.New("failure")): {
|
||||||
Status: api.StatusFailure,
|
Status: api.StatusFailure,
|
||||||
Code: http.StatusConflict,
|
Code: http.StatusConflict,
|
||||||
Reason: "conflict",
|
Reason: "Conflict",
|
||||||
Message: "foo \"bar\" cannot be updated: failure",
|
Message: "foo \"bar\" cannot be updated: failure",
|
||||||
Details: &api.StatusDetails{
|
Details: &api.StatusDetails{
|
||||||
Kind: "foo",
|
Kind: "foo",
|
||||||
|
@ -57,3 +57,7 @@ func (e *ExecHealthChecker) HealthCheck(podFullName string, currentState api.Pod
|
|||||||
}
|
}
|
||||||
return Healthy, nil
|
return Healthy, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *ExecHealthChecker) CanCheck(probe *api.LivenessProbe) bool {
|
||||||
|
return probe.Exec != nil
|
||||||
|
}
|
||||||
|
@ -49,22 +49,19 @@ func TestExec(t *testing.T) {
|
|||||||
checker := ExecHealthChecker{&fake}
|
checker := ExecHealthChecker{&fake}
|
||||||
tests := []healthCheckTest{
|
tests := []healthCheckTest{
|
||||||
// Missing parameters
|
// Missing parameters
|
||||||
{Unknown, &api.LivenessProbe{Type: "exec"}, true, nil, nil},
|
{Unknown, &api.LivenessProbe{}, true, nil, nil},
|
||||||
// Ok
|
// Ok
|
||||||
{Healthy, &api.LivenessProbe{
|
{Healthy, &api.LivenessProbe{
|
||||||
Type: "exec",
|
|
||||||
Exec: &api.ExecAction{Command: []string{"ls", "-l"}},
|
Exec: &api.ExecAction{Command: []string{"ls", "-l"}},
|
||||||
}, false, []byte("OK"), nil},
|
}, false, []byte("OK"), nil},
|
||||||
// Run returns error
|
// Run returns error
|
||||||
{Unknown, &api.LivenessProbe{
|
{Unknown, &api.LivenessProbe{
|
||||||
Type: "exec",
|
|
||||||
Exec: &api.ExecAction{
|
Exec: &api.ExecAction{
|
||||||
Command: []string{"ls", "-l"},
|
Command: []string{"ls", "-l"},
|
||||||
},
|
},
|
||||||
}, true, []byte("OK, NOT"), fmt.Errorf("test error")},
|
}, true, []byte("OK, NOT"), fmt.Errorf("test error")},
|
||||||
// Command error
|
// Command error
|
||||||
{Unhealthy, &api.LivenessProbe{
|
{Unhealthy, &api.LivenessProbe{
|
||||||
Type: "exec",
|
|
||||||
Exec: &api.ExecAction{
|
Exec: &api.ExecAction{
|
||||||
Command: []string{"ls", "-l"},
|
Command: []string{"ls", "-l"},
|
||||||
},
|
},
|
||||||
|
@ -36,54 +36,61 @@ const (
|
|||||||
// HealthChecker defines an abstract interface for checking container health.
|
// HealthChecker defines an abstract interface for checking container health.
|
||||||
type HealthChecker interface {
|
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)
|
||||||
|
CanCheck(probe *api.LivenessProbe) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// protects checkers
|
// protects allCheckers
|
||||||
var checkerLock = sync.Mutex{}
|
var checkerLock = sync.Mutex{}
|
||||||
var checkers = map[string]HealthChecker{}
|
var allCheckers = []HealthChecker{}
|
||||||
|
|
||||||
// AddHealthChecker adds a health checker to the list of known HealthChecker objects.
|
// AddHealthChecker adds a health checker to the list of known HealthChecker objects.
|
||||||
// Any subsequent call to NewHealthChecker will know about this HealthChecker.
|
// Any subsequent call to NewHealthChecker will know about this HealthChecker.
|
||||||
// Panics if 'key' is already present.
|
func AddHealthChecker(checker HealthChecker) {
|
||||||
func AddHealthChecker(key string, checker HealthChecker) {
|
|
||||||
checkerLock.Lock()
|
checkerLock.Lock()
|
||||||
defer checkerLock.Unlock()
|
defer checkerLock.Unlock()
|
||||||
if _, found := checkers[key]; found {
|
allCheckers = append(allCheckers, checker)
|
||||||
glog.Fatalf("HealthChecker already defined for key %s.", key)
|
|
||||||
}
|
|
||||||
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()
|
checkerLock.Lock()
|
||||||
defer checkerLock.Unlock()
|
defer checkerLock.Unlock()
|
||||||
input := map[string]HealthChecker{}
|
|
||||||
for key, value := range checkers {
|
|
||||||
input[key] = value
|
|
||||||
}
|
|
||||||
return &muxHealthChecker{
|
return &muxHealthChecker{
|
||||||
checkers: input,
|
checkers: append([]HealthChecker{}, allCheckers...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// muxHealthChecker bundles multiple implementations of HealthChecker of different types.
|
// muxHealthChecker bundles multiple implementations of HealthChecker of different types.
|
||||||
type muxHealthChecker struct {
|
type muxHealthChecker struct {
|
||||||
checkers map[string]HealthChecker
|
// Given a LivenessProbe, cycle through each known checker and see if it supports
|
||||||
|
// the specific kind of probe (by returning non-nil).
|
||||||
|
checkers []HealthChecker
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *muxHealthChecker) findCheckerFor(probe *api.LivenessProbe) HealthChecker {
|
||||||
|
for i := range m.checkers {
|
||||||
|
if m.checkers[i].CanCheck(probe) {
|
||||||
|
return m.checkers[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// HealthCheck delegates the health-checking of the container to one of the bundled implementations.
|
// 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 health checker that can check container it returns Unknown, nil.
|
||||||
// If there is no matching health checker it returns Unknown, nil.
|
|
||||||
func (m *muxHealthChecker) HealthCheck(podFullName string, currentState api.PodState, container api.Container) (Status, error) {
|
func (m *muxHealthChecker) HealthCheck(podFullName string, currentState api.PodState, container api.Container) (Status, error) {
|
||||||
checker, ok := m.checkers[container.LivenessProbe.Type]
|
checker := m.findCheckerFor(container.LivenessProbe)
|
||||||
if !ok || checker == nil {
|
if checker == nil {
|
||||||
glog.Warningf("Failed to find health checker for %s %s", container.Name, container.LivenessProbe.Type)
|
glog.Warningf("Failed to find health checker for %s %+v", container.Name, container.LivenessProbe)
|
||||||
return Unknown, nil
|
return Unknown, nil
|
||||||
}
|
}
|
||||||
return checker.HealthCheck(podFullName, currentState, container)
|
return checker.HealthCheck(podFullName, currentState, container)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *muxHealthChecker) CanCheck(probe *api.LivenessProbe) bool {
|
||||||
|
return m.findCheckerFor(probe) != nil
|
||||||
|
}
|
||||||
|
|
||||||
// findPortByName is a helper function to look up a port in a container by name.
|
// findPortByName is a helper function to look up a port in a container by name.
|
||||||
// Returns the HostPort if found, -1 if not found.
|
// Returns the HostPort if found, -1 if not found.
|
||||||
func findPortByName(container api.Container, portName string) int {
|
func findPortByName(container api.Container, portName string) int {
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
const statusServerEarlyShutdown = -1
|
const statusServerEarlyShutdown = -1
|
||||||
|
|
||||||
func TestHealthChecker(t *testing.T) {
|
func TestHealthChecker(t *testing.T) {
|
||||||
AddHealthChecker("http", &HTTPHealthChecker{client: &http.Client{}})
|
AddHealthChecker(&HTTPHealthChecker{client: &http.Client{}})
|
||||||
var healthCheckerTests = []struct {
|
var healthCheckerTests = []struct {
|
||||||
status int
|
status int
|
||||||
health Status
|
health Status
|
||||||
@ -64,7 +64,6 @@ func TestHealthChecker(t *testing.T) {
|
|||||||
Path: "/foo/bar",
|
Path: "/foo/bar",
|
||||||
Host: host,
|
Host: host,
|
||||||
},
|
},
|
||||||
Type: "http",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
hc := NewHealthChecker()
|
hc := NewHealthChecker()
|
||||||
@ -101,18 +100,15 @@ func TestFindPortByName(t *testing.T) {
|
|||||||
func TestMuxHealthChecker(t *testing.T) {
|
func TestMuxHealthChecker(t *testing.T) {
|
||||||
muxHealthCheckerTests := []struct {
|
muxHealthCheckerTests := []struct {
|
||||||
health Status
|
health Status
|
||||||
probeType string
|
|
||||||
}{
|
}{
|
||||||
{Healthy, "http"},
|
// TODO: This test should run through a few different checker types.
|
||||||
{Unknown, "ftp"},
|
{Healthy},
|
||||||
}
|
}
|
||||||
mc := &muxHealthChecker{
|
mc := &muxHealthChecker{
|
||||||
checkers: make(map[string]HealthChecker),
|
checkers: []HealthChecker{
|
||||||
|
&HTTPHealthChecker{client: &http.Client{}},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
hc := &HTTPHealthChecker{
|
|
||||||
client: &http.Client{},
|
|
||||||
}
|
|
||||||
mc.checkers["http"] = hc
|
|
||||||
for _, muxHealthCheckerTest := range muxHealthCheckerTests {
|
for _, muxHealthCheckerTest := range muxHealthCheckerTests {
|
||||||
tt := muxHealthCheckerTest
|
tt := muxHealthCheckerTest
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -131,7 +127,6 @@ func TestMuxHealthChecker(t *testing.T) {
|
|||||||
HTTPGet: &api.HTTPGetAction{},
|
HTTPGet: &api.HTTPGetAction{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
container.LivenessProbe.Type = tt.probeType
|
|
||||||
container.LivenessProbe.HTTPGet.Port = util.NewIntOrStringFromString(port)
|
container.LivenessProbe.HTTPGet.Port = util.NewIntOrStringFromString(port)
|
||||||
container.LivenessProbe.HTTPGet.Host = host
|
container.LivenessProbe.HTTPGet.Host = host
|
||||||
health, err := mc.HealthCheck("test", api.PodState{}, container)
|
health, err := mc.HealthCheck("test", api.PodState{}, container)
|
||||||
|
@ -105,3 +105,7 @@ func (h *HTTPHealthChecker) HealthCheck(podFullName string, currentState api.Pod
|
|||||||
}
|
}
|
||||||
return DoHTTPCheck(formatURL(host, port, path), h.client)
|
return DoHTTPCheck(formatURL(host, port, path), h.client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *HTTPHealthChecker) CanCheck(probe *api.LivenessProbe) bool {
|
||||||
|
return probe.HTTPGet != nil
|
||||||
|
}
|
||||||
|
@ -51,7 +51,6 @@ func TestGetURLParts(t *testing.T) {
|
|||||||
Ports: []api.Port{{Name: "found", HostPort: 93}},
|
Ports: []api.Port{{Name: "found", HostPort: 93}},
|
||||||
LivenessProbe: &api.LivenessProbe{
|
LivenessProbe: &api.LivenessProbe{
|
||||||
HTTPGet: test.probe,
|
HTTPGet: test.probe,
|
||||||
Type: "http",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
host, port, path, err := getURLParts(state, container)
|
host, port, path, err := getURLParts(state, container)
|
||||||
@ -117,7 +116,6 @@ func TestHTTPHealthChecker(t *testing.T) {
|
|||||||
container := api.Container{
|
container := api.Container{
|
||||||
LivenessProbe: &api.LivenessProbe{
|
LivenessProbe: &api.LivenessProbe{
|
||||||
HTTPGet: test.probe,
|
HTTPGet: test.probe,
|
||||||
Type: "http",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
params := container.LivenessProbe.HTTPGet
|
params := container.LivenessProbe.HTTPGet
|
||||||
|
@ -81,3 +81,7 @@ func (t *TCPHealthChecker) HealthCheck(podFullName string, currentState api.PodS
|
|||||||
}
|
}
|
||||||
return DoTCPCheck(net.JoinHostPort(host, strconv.Itoa(port)))
|
return DoTCPCheck(net.JoinHostPort(host, strconv.Itoa(port)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TCPHealthChecker) CanCheck(probe *api.LivenessProbe) bool {
|
||||||
|
return probe.TCPSocket != nil
|
||||||
|
}
|
||||||
|
@ -49,7 +49,6 @@ func TestGetTCPAddrParts(t *testing.T) {
|
|||||||
Ports: []api.Port{{Name: "found", HostPort: 93}},
|
Ports: []api.Port{{Name: "found", HostPort: 93}},
|
||||||
LivenessProbe: &api.LivenessProbe{
|
LivenessProbe: &api.LivenessProbe{
|
||||||
TCPSocket: test.probe,
|
TCPSocket: test.probe,
|
||||||
Type: "tcp",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
host, port, err := getTCPAddrParts(state, container)
|
host, port, err := getTCPAddrParts(state, container)
|
||||||
@ -95,7 +94,6 @@ func TestTcpHealthChecker(t *testing.T) {
|
|||||||
container := api.Container{
|
container := api.Container{
|
||||||
LivenessProbe: &api.LivenessProbe{
|
LivenessProbe: &api.LivenessProbe{
|
||||||
TCPSocket: test.probe,
|
TCPSocket: test.probe,
|
||||||
Type: "tcp",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
params := container.LivenessProbe.TCPSocket
|
params := container.LivenessProbe.TCPSocket
|
||||||
|
@ -222,7 +222,7 @@ func makePortsAndBindings(container *api.Container) (map[docker.Port]struct{}, m
|
|||||||
// Some of this port stuff is under-documented voodoo.
|
// Some of this port stuff is under-documented voodoo.
|
||||||
// See http://stackoverflow.com/questions/20428302/binding-a-port-to-a-host-interface-using-the-rest-api
|
// See http://stackoverflow.com/questions/20428302/binding-a-port-to-a-host-interface-using-the-rest-api
|
||||||
var protocol string
|
var protocol string
|
||||||
switch strings.ToUpper(port.Protocol) {
|
switch strings.ToUpper(string(port.Protocol)) {
|
||||||
case "UDP":
|
case "UDP":
|
||||||
protocol = "/udp"
|
protocol = "/udp"
|
||||||
case "TCP":
|
case "TCP":
|
||||||
|
@ -457,6 +457,10 @@ func (f *FalseHealthChecker) HealthCheck(podFullName string, state api.PodState,
|
|||||||
return health.Unhealthy, nil
|
return health.Unhealthy, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *FalseHealthChecker) CanCheck(probe *api.LivenessProbe) bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func TestSyncPodBadHash(t *testing.T) {
|
func TestSyncPodBadHash(t *testing.T) {
|
||||||
kubelet, _, fakeDocker := newTestKubelet(t)
|
kubelet, _, fakeDocker := newTestKubelet(t)
|
||||||
kubelet.healthChecker = &FalseHealthChecker{}
|
kubelet.healthChecker = &FalseHealthChecker{}
|
||||||
@ -523,7 +527,6 @@ func TestSyncPodUnhealthy(t *testing.T) {
|
|||||||
{Name: "bar",
|
{Name: "bar",
|
||||||
LivenessProbe: &api.LivenessProbe{
|
LivenessProbe: &api.LivenessProbe{
|
||||||
// Always returns healthy == false
|
// Always returns healthy == false
|
||||||
Type: "false",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
|
|
||||||
type serviceInfo struct {
|
type serviceInfo struct {
|
||||||
port int
|
port int
|
||||||
protocol string
|
protocol api.Protocol
|
||||||
socket proxySocket
|
socket proxySocket
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
mu sync.Mutex // protects active
|
mu sync.Mutex // protects active
|
||||||
@ -276,8 +276,8 @@ func logTimeout(err error) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func newProxySocket(protocol string, host string, port int) (proxySocket, error) {
|
func newProxySocket(protocol api.Protocol, host string, port int) (proxySocket, error) {
|
||||||
switch strings.ToUpper(protocol) {
|
switch strings.ToUpper(string(protocol)) {
|
||||||
case "TCP":
|
case "TCP":
|
||||||
listener, err := net.Listen("tcp", net.JoinHostPort(host, strconv.Itoa(port)))
|
listener, err := net.Listen("tcp", net.JoinHostPort(host, strconv.Itoa(port)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -350,7 +350,7 @@ func (proxier *Proxier) setServiceInfo(service string, info *serviceInfo) {
|
|||||||
// addServiceOnUnusedPort starts listening for a new service, returning the
|
// addServiceOnUnusedPort starts listening for a new service, returning the
|
||||||
// port it's using. For testing on a system with unknown ports used. The timeout only applies to UDP
|
// port it's using. For testing on a system with unknown ports used. The timeout only applies to UDP
|
||||||
// connections, for now.
|
// connections, for now.
|
||||||
func (proxier *Proxier) addServiceOnUnusedPort(service, protocol string, timeout time.Duration) (string, error) {
|
func (proxier *Proxier) addServiceOnUnusedPort(service string, protocol api.Protocol, timeout time.Duration) (string, error) {
|
||||||
sock, err := newProxySocket(protocol, proxier.address, 0)
|
sock, err := newProxySocket(protocol, proxier.address, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -222,9 +222,9 @@ func makeEnvVariableName(str string) string {
|
|||||||
|
|
||||||
func makeLinkVariables(service api.Service, machine string) []api.EnvVar {
|
func makeLinkVariables(service api.Service, machine string) []api.EnvVar {
|
||||||
prefix := makeEnvVariableName(service.ID)
|
prefix := makeEnvVariableName(service.ID)
|
||||||
protocol := "TCP"
|
protocol := string(api.ProtocolTCP)
|
||||||
if service.Protocol != "" {
|
if service.Protocol != "" {
|
||||||
protocol = service.Protocol
|
protocol = string(service.Protocol)
|
||||||
}
|
}
|
||||||
portPrefix := fmt.Sprintf("%s_PORT_%d_%s", prefix, service.Port, strings.ToUpper(protocol))
|
portPrefix := fmt.Sprintf("%s_PORT_%d_%s", prefix, service.Port, strings.ToUpper(protocol))
|
||||||
return []api.EnvVar{
|
return []api.EnvVar{
|
||||||
|
Loading…
Reference in New Issue
Block a user