mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 21:50:05 +00:00
Merge pull request #5477 from dchen1107/clean
Convert RestartPolicy to string for v1beta3.
This commit is contained in:
@@ -52,11 +52,6 @@ func init() {
|
||||
obj.TerminationMessagePath = TerminationMessagePathDefault
|
||||
}
|
||||
},
|
||||
func(obj *RestartPolicy) {
|
||||
if util.AllPtrFieldsNil(obj) {
|
||||
obj.Always = &RestartPolicyAlways{}
|
||||
}
|
||||
},
|
||||
func(obj *Service) {
|
||||
if obj.Spec.Protocol == "" {
|
||||
obj.Spec.Protocol = ProtocolTCP
|
||||
@@ -69,6 +64,9 @@ func init() {
|
||||
if obj.DNSPolicy == "" {
|
||||
obj.DNSPolicy = DNSClusterFirst
|
||||
}
|
||||
if obj.RestartPolicy == "" {
|
||||
obj.RestartPolicy = RestartPolicyAlways
|
||||
}
|
||||
},
|
||||
func(obj *Probe) {
|
||||
if obj.TimeoutSeconds == 0 {
|
||||
|
@@ -62,7 +62,7 @@ func TestSetDefaulPodSpec(t *testing.T) {
|
||||
t.Errorf("Expected default dns policy :%s, got: %s", current.DNSClusterFirst, bp2.Spec.DNSPolicy)
|
||||
}
|
||||
policy := bp2.Spec.RestartPolicy
|
||||
if policy.Never != nil || policy.OnFailure != nil || policy.Always == nil {
|
||||
if policy != current.RestartPolicyAlways {
|
||||
t.Errorf("Expected only policy.Always is set, got: %s", policy)
|
||||
}
|
||||
vsource := bp2.Spec.Volumes[0].VolumeSource
|
||||
|
@@ -522,22 +522,17 @@ type PodCondition struct {
|
||||
// PodInfo contains one entry for every container with available info.
|
||||
type PodInfo map[string]ContainerStatus
|
||||
|
||||
type RestartPolicyAlways struct{}
|
||||
// RestartPolicy describes how the container should be restarted.
|
||||
// Only one of the following restart policies may be specified.
|
||||
// If none of the following policies is specified, the default one
|
||||
// is RestartPolicyAlways.
|
||||
type RestartPolicy string
|
||||
|
||||
// TODO(dchen1107): Define what kinds of failures should restart.
|
||||
// TODO(dchen1107): Decide whether to support policy knobs, and, if so, which ones.
|
||||
type RestartPolicyOnFailure struct{}
|
||||
|
||||
type RestartPolicyNever struct{}
|
||||
|
||||
type RestartPolicy struct {
|
||||
// Only one of the following restart policies may be specified.
|
||||
// If none of the following policies is specified, the default one
|
||||
// is RestartPolicyAlways.
|
||||
Always *RestartPolicyAlways `json:"always,omitempty" description:"always restart the container after termination"`
|
||||
OnFailure *RestartPolicyOnFailure `json:"onFailure,omitempty" description:"restart the container if it fails for any reason, but not if it succeeds (exit 0)"`
|
||||
Never *RestartPolicyNever `json:"never,omitempty" description:"never restart the container"`
|
||||
}
|
||||
const (
|
||||
RestartPolicyAlways RestartPolicy = "Always"
|
||||
RestartPolicyOnFailure RestartPolicy = "OnFailure"
|
||||
RestartPolicyNever RestartPolicy = "Never"
|
||||
)
|
||||
|
||||
// DNSPolicy defines how a pod's DNS will be configured.
|
||||
type DNSPolicy string
|
||||
|
Reference in New Issue
Block a user