Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
09a3231e
Commit
09a3231e
authored
Sep 28, 2014
by
bgrant0607
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1480 from thockin/caps
Capitalize string constants
parents
cf266288
f2cf9585
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
200 additions
and
155 deletions
+200
-155
kubelet.go
cmd/kubelet/kubelet.go
+5
-3
errors_test.go
pkg/api/errors/errors_test.go
+6
-6
validation.go
pkg/api/errors/validation.go
+6
-5
types.go
pkg/api/types.go
+30
-22
types.go
pkg/api/v1beta1/types.go
+29
-21
types.go
pkg/api/v1beta2/types.go
+30
-22
types.go
pkg/api/v1beta3/types.go
+30
-22
validation.go
pkg/api/validation/validation.go
+3
-3
apiserver_test.go
pkg/apiserver/apiserver_test.go
+1
-1
errors_test.go
pkg/apiserver/errors_test.go
+2
-2
exec.go
pkg/health/exec.go
+4
-0
exec_test.go
pkg/health/exec_test.go
+1
-4
health.go
pkg/health/health.go
+26
-19
health_test.go
pkg/health/health_test.go
+7
-12
http.go
pkg/health/http.go
+4
-0
http_test.go
pkg/health/http_test.go
+0
-2
tcp.go
pkg/health/tcp.go
+4
-0
tcp_test.go
pkg/health/tcp_test.go
+0
-2
kubelet.go
pkg/kubelet/kubelet.go
+1
-1
kubelet_test.go
pkg/kubelet/kubelet_test.go
+5
-2
proxier.go
pkg/proxy/proxier.go
+4
-4
rest.go
pkg/registry/service/rest.go
+2
-2
No files found.
cmd/kubelet/kubelet.go
View file @
09a3231e
...
@@ -163,9 +163,11 @@ func main() {
...
@@ -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
)
...
...
pkg/api/errors/errors_test.go
View file @
09a3231e
...
@@ -29,26 +29,26 @@ import (
...
@@ -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) {
...
@@ -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
)
}
}
}
}
}
}
...
...
pkg/api/errors/validation.go
View file @
09a3231e
...
@@ -28,22 +28,23 @@ import (
...
@@ -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
=
"
f
ieldValueNotFound"
ValidationErrorTypeNotFound
ValidationErrorType
=
"
F
ieldValueNotFound"
// 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
=
"
f
ieldValueRequired"
ValidationErrorTypeRequired
ValidationErrorType
=
"
F
ieldValueRequired"
// 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
=
"
f
ieldValueDuplicate"
ValidationErrorTypeDuplicate
ValidationErrorType
=
"
F
ieldValueDuplicate"
// 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
=
"
f
ieldValueInvalid"
ValidationErrorTypeInvalid
ValidationErrorType
=
"
F
ieldValueInvalid"
// 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
=
"
f
ieldValueNotSupported"
ValidationErrorTypeNotSupported
ValidationErrorType
=
"
F
ieldValueNotSupported"
)
)
func
ValueOf
(
t
ValidationErrorType
)
string
{
func
ValueOf
(
t
ValidationErrorType
)
string
{
...
...
pkg/api/types.go
View file @
09a3231e
...
@@ -100,6 +100,16 @@ type HostDirectory struct {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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() {}
...
@@ -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", "w
orking" (for operations not yet completed)
// One of: "
Success", "Failure", "W
orking" (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 "w
orking" status. If this value is empty there
// "
Failure" or "W
orking" 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 {
...
@@ -487,9 +495,9 @@ type StatusDetails struct {
// Values of Status.Status
// Values of Status.Status
const
(
const
(
StatusSuccess
=
"
s
uccess"
StatusSuccess
=
"
S
uccess"
StatusFailure
=
"
f
ailure"
StatusFailure
=
"
F
ailure"
StatusWorking
=
"
w
orking"
StatusWorking
=
"
W
orking"
)
)
// 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 (
...
@@ -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
=
"
w
orking"
StatusReasonWorking
StatusReason
=
"
W
orking"
// 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 (
...
@@ -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_f
ound"
StatusReasonNotFound
StatusReason
=
"
NotF
ound"
// 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_e
xists"
StatusReasonAlreadyExists
StatusReason
=
"
AlreadyE
xists"
// 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
=
"
c
onflict"
StatusReasonConflict
StatusReason
=
"
C
onflict"
// 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 (
...
@@ -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
=
"
i
nvalid"
StatusReasonInvalid
StatusReason
=
"
I
nvalid"
)
)
// 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 {
...
@@ -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 w
orking).
// status (whether
Failure, Success, or W
orking).
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
=
"
f
ieldValueNotFound"
CauseTypeFieldValueNotFound
CauseType
=
"
F
ieldValueNotFound"
// 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
=
"
f
ieldValueRequired"
CauseTypeFieldValueRequired
CauseType
=
"
F
ieldValueRequired"
// 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
=
"
f
ieldValueDuplicate"
CauseTypeFieldValueDuplicate
CauseType
=
"
F
ieldValueDuplicate"
// 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
=
"
f
ieldValueInvalid"
CauseTypeFieldValueInvalid
CauseType
=
"
F
ieldValueInvalid"
// 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
=
"
f
ieldValueNotSupported"
CauseTypeFieldValueNotSupported
CauseType
=
"
F
ieldValueNotSupported"
)
)
// ServerOp is an operation delivered to API clients.
// ServerOp is an operation delivered to API clients.
...
...
pkg/api/v1beta1/types.go
View file @
09a3231e
...
@@ -100,6 +100,16 @@ type HostDirectory struct {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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() {}
...
@@ -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", "w
orking" (for operations not yet completed)
// One of: "
Success", "Failure", "W
orking" (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 "w
orking" status. If this value is empty there
// "
Failure" or "W
orking" 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 {
...
@@ -503,9 +511,9 @@ type StatusDetails struct {
// Values of Status.Status
// Values of Status.Status
const
(
const
(
StatusSuccess
=
"
s
uccess"
StatusSuccess
=
"
S
uccess"
StatusFailure
=
"
f
ailure"
StatusFailure
=
"
F
ailure"
StatusWorking
=
"
w
orking"
StatusWorking
=
"
W
orking"
)
)
// 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 (
...
@@ -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
=
"
w
orking"
StatusReasonWorking
StatusReason
=
"
W
orking"
// 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 (
...
@@ -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
=
"
n
otFound"
StatusReasonNotFound
StatusReason
=
"
N
otFound"
// 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
=
"
a
lreadyExists"
StatusReasonAlreadyExists
StatusReason
=
"
A
lreadyExists"
// 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
=
"
c
onflict"
StatusReasonConflict
StatusReason
=
"
C
onflict"
)
)
// 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 {
...
@@ -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 w
orking).
// status (whether
Failure, Success, or W
orking).
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
=
"
f
ieldValueNotFound"
CauseTypeFieldValueNotFound
CauseType
=
"
F
ieldValueNotFound"
// 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
=
"
f
ieldValueRequired"
CauseTypeFieldValueRequired
CauseType
=
"
F
ieldValueRequired"
// 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
=
"
f
ieldValueDuplicate"
CauseTypeFieldValueDuplicate
CauseType
=
"
F
ieldValueDuplicate"
// 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
=
"
f
ieldValueInvalid"
CauseTypeFieldValueInvalid
CauseType
=
"
F
ieldValueInvalid"
// 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
=
"
f
ieldValueNotSupported"
CauseTypeFieldValueNotSupported
CauseType
=
"
F
ieldValueNotSupported"
)
)
// ServerOp is an operation delivered to API clients.
// ServerOp is an operation delivered to API clients.
...
...
pkg/api/v1beta2/types.go
View file @
09a3231e
...
@@ -100,6 +100,16 @@ type HostDirectory struct {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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() {}
...
@@ -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", "w
orking" (for operations not yet completed)
// One of: "
Success", "Failure", "W
orking" (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 "w
orking" status. If this value is empty there
// "
Failure" or "W
orking" 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 {
...
@@ -500,9 +508,9 @@ type StatusDetails struct {
// Values of Status.Status
// Values of Status.Status
const
(
const
(
StatusSuccess
=
"
s
uccess"
StatusSuccess
=
"
S
uccess"
StatusFailure
=
"
f
ailure"
StatusFailure
=
"
F
ailure"
StatusWorking
=
"
w
orking"
StatusWorking
=
"
W
orking"
)
)
// 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 (
...
@@ -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
=
"
w
orking"
StatusReasonWorking
StatusReason
=
"
W
orking"
// 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 (
...
@@ -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_f
ound"
StatusReasonNotFound
StatusReason
=
"
NotF
ound"
// 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_e
xists"
StatusReasonAlreadyExists
StatusReason
=
"
AlreadyE
xists"
// 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
=
"
c
onflict"
StatusReasonConflict
StatusReason
=
"
C
onflict"
// 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 (
...
@@ -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
=
"
i
nvalid"
StatusReasonInvalid
StatusReason
=
"
I
nvalid"
)
)
// 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 {
...
@@ -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 w
orking).
// status (whether
Failure, Success, or W
orking).
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
=
"
f
ieldValueNotFound"
CauseTypeFieldValueNotFound
CauseType
=
"
F
ieldValueNotFound"
// 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
=
"
f
ieldValueRequired"
CauseTypeFieldValueRequired
CauseType
=
"
F
ieldValueRequired"
// 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
=
"
f
ieldValueDuplicate"
CauseTypeFieldValueDuplicate
CauseType
=
"
F
ieldValueDuplicate"
// 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
=
"
f
ieldValueInvalid"
CauseTypeFieldValueInvalid
CauseType
=
"
F
ieldValueInvalid"
// 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
=
"
f
ieldValueNotSupported"
CauseTypeFieldValueNotSupported
CauseType
=
"
F
ieldValueNotSupported"
)
)
// ServerOp is an operation delivered to API clients.
// ServerOp is an operation delivered to API clients.
...
...
pkg/api/v1beta3/types.go
View file @
09a3231e
...
@@ -100,6 +100,16 @@ type HostDirectory struct {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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() {}
...
@@ -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", "w
orking" (for operations not yet completed)
// One of: "
Success", "Failure", "W
orking" (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 "w
orking" status. If this value is empty there
// "
Failure" or "W
orking" 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 {
...
@@ -496,9 +504,9 @@ type StatusDetails struct {
// Values of Status.Status
// Values of Status.Status
const
(
const
(
StatusSuccess
=
"
s
uccess"
StatusSuccess
=
"
S
uccess"
StatusFailure
=
"
f
ailure"
StatusFailure
=
"
F
ailure"
StatusWorking
=
"
w
orking"
StatusWorking
=
"
W
orking"
)
)
// 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 (
...
@@ -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
=
"
w
orking"
StatusReasonWorking
StatusReason
=
"
W
orking"
// 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 (
...
@@ -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_f
ound"
StatusReasonNotFound
StatusReason
=
"
NotF
ound"
// 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_e
xists"
StatusReasonAlreadyExists
StatusReason
=
"
AlreadyE
xists"
// 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
=
"
c
onflict"
StatusReasonConflict
StatusReason
=
"
C
onflict"
// 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 (
...
@@ -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
=
"
i
nvalid"
StatusReasonInvalid
StatusReason
=
"
I
nvalid"
)
)
// 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 {
...
@@ -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 w
orking).
// status (whether
Failure, Success, or W
orking).
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
=
"
f
ieldValueNotFound"
CauseTypeFieldValueNotFound
CauseType
=
"
F
ieldValueNotFound"
// 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
=
"
f
ieldValueRequired"
CauseTypeFieldValueRequired
CauseType
=
"
F
ieldValueRequired"
// 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
=
"
f
ieldValueDuplicate"
CauseTypeFieldValueDuplicate
CauseType
=
"
F
ieldValueDuplicate"
// 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
=
"
f
ieldValueInvalid"
CauseTypeFieldValueInvalid
CauseType
=
"
F
ieldValueInvalid"
// 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
=
"
f
ieldValueNotSupported"
CauseTypeFieldValueNotSupported
CauseType
=
"
F
ieldValueNotSupported"
)
)
// ServerOp is an operation delivered to API clients.
// ServerOp is an operation delivered to API clients.
...
...
pkg/api/validation/validation.go
View file @
09a3231e
...
@@ -78,7 +78,7 @@ func validateHostDir(hostDir *api.HostDirectory) errs.ErrorList {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
(
s
ervice
.
Protocol
))
{
}
else
if
!
supportedPortProtocols
.
Has
(
strings
.
ToUpper
(
s
tring
(
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
()
{
...
...
pkg/apiserver/apiserver_test.go
View file @
09a3231e
...
@@ -706,7 +706,7 @@ func TestAsyncCreateError(t *testing.T) {
...
@@ -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_e
xists"
,
Reason
:
"
AlreadyE
xists"
,
Message
:
expectedErr
.
Error
(),
Message
:
expectedErr
.
Error
(),
Details
:
&
api
.
StatusDetails
{
Details
:
&
api
.
StatusDetails
{
Kind
:
"foo"
,
Kind
:
"foo"
,
...
...
pkg/apiserver/errors_test.go
View file @
09a3231e
...
@@ -39,7 +39,7 @@ func TestErrorsToAPIStatus(t *testing.T) {
...
@@ -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_e
xists"
,
Reason
:
"
AlreadyE
xists"
,
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) {
...
@@ -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
:
"
c
onflict"
,
Reason
:
"
C
onflict"
,
Message
:
"foo
\"
bar
\"
cannot be updated: failure"
,
Message
:
"foo
\"
bar
\"
cannot be updated: failure"
,
Details
:
&
api
.
StatusDetails
{
Details
:
&
api
.
StatusDetails
{
Kind
:
"foo"
,
Kind
:
"foo"
,
...
...
pkg/health/exec.go
View file @
09a3231e
...
@@ -57,3 +57,7 @@ func (e *ExecHealthChecker) HealthCheck(podFullName string, currentState api.Pod
...
@@ -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
}
pkg/health/exec_test.go
View file @
09a3231e
...
@@ -49,22 +49,19 @@ func TestExec(t *testing.T) {
...
@@ -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"
},
},
},
...
...
pkg/health/health.go
View file @
09a3231e
...
@@ -36,54 +36,61 @@ const (
...
@@ -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
c
heckers
// protects
allC
heckers
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
.
Typ
e
)
glog
.
Warningf
(
"Failed to find health checker for %s %
+v"
,
container
.
Name
,
container
.
LivenessProb
e
)
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
{
...
...
pkg/health/health_test.go
View file @
09a3231e
...
@@ -30,7 +30,7 @@ import (
...
@@ -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) {
...
@@ -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
()
...
@@ -100,19 +99,16 @@ func TestFindPortByName(t *testing.T) {
...
@@ -100,19 +99,16 @@ 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) {
...
@@ -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
)
...
...
pkg/health/http.go
View file @
09a3231e
...
@@ -105,3 +105,7 @@ func (h *HTTPHealthChecker) HealthCheck(podFullName string, currentState api.Pod
...
@@ -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
}
pkg/health/http_test.go
View file @
09a3231e
...
@@ -51,7 +51,6 @@ func TestGetURLParts(t *testing.T) {
...
@@ -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) {
...
@@ -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
...
...
pkg/health/tcp.go
View file @
09a3231e
...
@@ -81,3 +81,7 @@ func (t *TCPHealthChecker) HealthCheck(podFullName string, currentState api.PodS
...
@@ -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
}
pkg/health/tcp_test.go
View file @
09a3231e
...
@@ -49,7 +49,6 @@ func TestGetTCPAddrParts(t *testing.T) {
...
@@ -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) {
...
@@ -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
...
...
pkg/kubelet/kubelet.go
View file @
09a3231e
...
@@ -222,7 +222,7 @@ func makePortsAndBindings(container *api.Container) (map[docker.Port]struct{}, m
...
@@ -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"
:
...
...
pkg/kubelet/kubelet_test.go
View file @
09a3231e
...
@@ -457,6 +457,10 @@ func (f *FalseHealthChecker) HealthCheck(podFullName string, state api.PodState,
...
@@ -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
{}
...
@@ -522,8 +526,7 @@ func TestSyncPodUnhealthy(t *testing.T) {
...
@@ -522,8 +526,7 @@ func TestSyncPodUnhealthy(t *testing.T) {
Containers
:
[]
api
.
Container
{
Containers
:
[]
api
.
Container
{
{
Name
:
"bar"
,
{
Name
:
"bar"
,
LivenessProbe
:
&
api
.
LivenessProbe
{
LivenessProbe
:
&
api
.
LivenessProbe
{
// Always returns healthy == false
// Always returns healthy == false
Type
:
"false"
,
},
},
},
},
},
},
...
...
pkg/proxy/proxier.go
View file @
09a3231e
...
@@ -32,7 +32,7 @@ import (
...
@@ -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 {
...
@@ -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) {
...
@@ -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
...
...
pkg/registry/service/rest.go
View file @
09a3231e
...
@@ -222,9 +222,9 @@ func makeEnvVariableName(str string) string {
...
@@ -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
=
s
ervice
.
Protocol
protocol
=
s
tring
(
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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment