diff --git a/federation/apis/federation/deep_copy_generated.go b/federation/apis/federation/deep_copy_generated.go index 62f5c160b83..da4596384d2 100644 --- a/federation/apis/federation/deep_copy_generated.go +++ b/federation/apis/federation/deep_copy_generated.go @@ -30,6 +30,7 @@ import ( func init() { if err := api.Scheme.AddGeneratedDeepCopyFuncs( DeepCopy_federation_Cluster, + DeepCopy_federation_ClusterCondition, DeepCopy_federation_ClusterList, DeepCopy_federation_ClusterMeta, DeepCopy_federation_ClusterSpec, @@ -56,6 +57,20 @@ func DeepCopy_federation_Cluster(in Cluster, out *Cluster, c *conversion.Cloner) return nil } +func DeepCopy_federation_ClusterCondition(in ClusterCondition, out *ClusterCondition, c *conversion.Cloner) error { + out.Type = in.Type + out.Status = in.Status + if err := unversioned.DeepCopy_unversioned_Time(in.LastProbeTime, &out.LastProbeTime, c); err != nil { + return err + } + if err := unversioned.DeepCopy_unversioned_Time(in.LastTransitionTime, &out.LastTransitionTime, c); err != nil { + return err + } + out.Reason = in.Reason + out.Message = in.Message + return nil +} + func DeepCopy_federation_ClusterList(in ClusterList, out *ClusterList, c *conversion.Cloner) error { if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { return err @@ -99,7 +114,17 @@ func DeepCopy_federation_ClusterSpec(in ClusterSpec, out *ClusterSpec, c *conver } func DeepCopy_federation_ClusterStatus(in ClusterStatus, out *ClusterStatus, c *conversion.Cloner) error { - out.Phase = in.Phase + if in.Conditions != nil { + in, out := in.Conditions, &out.Conditions + *out = make([]ClusterCondition, len(in)) + for i := range in { + if err := DeepCopy_federation_ClusterCondition(in[i], &(*out)[i], c); err != nil { + return err + } + } + } else { + out.Conditions = nil + } if in.Capacity != nil { in, out := in.Capacity, &out.Capacity *out = make(api.ResourceList) diff --git a/federation/apis/federation/types.generated.go b/federation/apis/federation/types.generated.go index 07a5bd86049..311acfb716d 100644 --- a/federation/apis/federation/types.generated.go +++ b/federation/apis/federation/types.generated.go @@ -65,7 +65,7 @@ func init() { panic(err) } if false { // reference the types, but skip this branch at build/run time - var v0 pkg2_api.ResourceList + var v0 pkg2_api.ConditionStatus var v1 pkg3_resource.Quantity var v2 pkg1_unversioned.ServerAddressByClientCIDR var v3 pkg5_types.UID @@ -305,7 +305,7 @@ func (x *ClusterSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } -func (x ClusterPhase) CodecEncodeSelf(e *codec1978.Encoder) { +func (x ClusterConditionType) CodecEncodeSelf(e *codec1978.Encoder) { var h codecSelfer1234 z, r := codec1978.GenHelperEncoder(e) _, _, _ = h, z, r @@ -318,7 +318,7 @@ func (x ClusterPhase) CodecEncodeSelf(e *codec1978.Encoder) { } } -func (x *ClusterPhase) CodecDecodeSelf(d *codec1978.Decoder) { +func (x *ClusterConditionType) CodecDecodeSelf(d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r @@ -331,6 +331,451 @@ func (x *ClusterPhase) CodecDecodeSelf(d *codec1978.Decoder) { } } +func (x *ClusterCondition) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + var yyq2 [6]bool + _, _, _ = yysep2, yyq2, yy2arr2 + const yyr2 bool = false + yyq2[2] = true + yyq2[3] = true + yyq2[4] = x.Reason != "" + yyq2[5] = x.Message != "" + var yynn2 int + if yyr2 || yy2arr2 { + r.EncodeArrayStart(6) + } else { + yynn2 = 2 + for _, b := range yyq2 { + if b { + yynn2++ + } + } + r.EncodeMapStart(yynn2) + yynn2 = 0 + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + x.Type.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("type")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + x.Type.CodecEncodeSelf(e) + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yysf7 := &x.Status + yysf7.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("status")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yysf8 := &x.Status + yysf8.CodecEncodeSelf(e) + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[2] { + yy10 := &x.LastProbeTime + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(yy10) { + } else if yym11 { + z.EncBinaryMarshal(yy10) + } else if !yym11 && z.IsJSONHandle() { + z.EncJSONMarshal(yy10) + } else { + z.EncFallback(yy10) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[2] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("lastProbeTime")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy12 := &x.LastProbeTime + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(yy12) { + } else if yym13 { + z.EncBinaryMarshal(yy12) + } else if !yym13 && z.IsJSONHandle() { + z.EncJSONMarshal(yy12) + } else { + z.EncFallback(yy12) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[3] { + yy15 := &x.LastTransitionTime + yym16 := z.EncBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.EncExt(yy15) { + } else if yym16 { + z.EncBinaryMarshal(yy15) + } else if !yym16 && z.IsJSONHandle() { + z.EncJSONMarshal(yy15) + } else { + z.EncFallback(yy15) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[3] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("lastTransitionTime")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy17 := &x.LastTransitionTime + yym18 := z.EncBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.EncExt(yy17) { + } else if yym18 { + z.EncBinaryMarshal(yy17) + } else if !yym18 && z.IsJSONHandle() { + z.EncJSONMarshal(yy17) + } else { + z.EncFallback(yy17) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[4] { + yym20 := z.EncBinary() + _ = yym20 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Reason)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[4] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("reason")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym21 := z.EncBinary() + _ = yym21 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Reason)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[5] { + yym23 := z.EncBinary() + _ = yym23 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Message)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[5] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("message")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym24 := z.EncBinary() + _ = yym24 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Message)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *ClusterCondition) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap1234 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray1234 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *ClusterCondition) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys3Slc = r.DecodeBytes(yys3Slc, true, true) + yys3 := string(yys3Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys3 { + case "type": + if r.TryDecodeAsNil() { + x.Type = "" + } else { + x.Type = ClusterConditionType(r.DecodeString()) + } + case "status": + if r.TryDecodeAsNil() { + x.Status = "" + } else { + x.Status = pkg2_api.ConditionStatus(r.DecodeString()) + } + case "lastProbeTime": + if r.TryDecodeAsNil() { + x.LastProbeTime = pkg1_unversioned.Time{} + } else { + yyv6 := &x.LastProbeTime + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else if yym7 { + z.DecBinaryUnmarshal(yyv6) + } else if !yym7 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv6) + } else { + z.DecFallback(yyv6, false) + } + } + case "lastTransitionTime": + if r.TryDecodeAsNil() { + x.LastTransitionTime = pkg1_unversioned.Time{} + } else { + yyv8 := &x.LastTransitionTime + yym9 := z.DecBinary() + _ = yym9 + if false { + } else if z.HasExtensions() && z.DecExt(yyv8) { + } else if yym9 { + z.DecBinaryUnmarshal(yyv8) + } else if !yym9 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv8) + } else { + z.DecFallback(yyv8, false) + } + } + case "reason": + if r.TryDecodeAsNil() { + x.Reason = "" + } else { + x.Reason = string(r.DecodeString()) + } + case "message": + if r.TryDecodeAsNil() { + x.Message = "" + } else { + x.Message = string(r.DecodeString()) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *ClusterCondition) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj12 int + var yyb12 bool + var yyhl12 bool = l >= 0 + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Type = "" + } else { + x.Type = ClusterConditionType(r.DecodeString()) + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Status = "" + } else { + x.Status = pkg2_api.ConditionStatus(r.DecodeString()) + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.LastProbeTime = pkg1_unversioned.Time{} + } else { + yyv15 := &x.LastProbeTime + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else if yym16 { + z.DecBinaryUnmarshal(yyv15) + } else if !yym16 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv15) + } else { + z.DecFallback(yyv15, false) + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.LastTransitionTime = pkg1_unversioned.Time{} + } else { + yyv17 := &x.LastTransitionTime + yym18 := z.DecBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.DecExt(yyv17) { + } else if yym18 { + z.DecBinaryUnmarshal(yyv17) + } else if !yym18 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv17) + } else { + z.DecFallback(yyv17, false) + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Reason = "" + } else { + x.Reason = string(r.DecodeString()) + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Message = "" + } else { + x.Message = string(r.DecodeString()) + } + for { + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj12-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + func (x *ClusterMeta) CodecEncodeSelf(e *codec1978.Encoder) { var h codecSelfer1234 z, r := codec1978.GenHelperEncoder(e) @@ -517,7 +962,7 @@ func (x *ClusterStatus) CodecEncodeSelf(e *codec1978.Encoder) { var yyq2 [4]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false - yyq2[0] = x.Phase != "" + yyq2[0] = len(x.Conditions) != 0 yyq2[1] = len(x.Capacity) != 0 yyq2[2] = len(x.Allocatable) != 0 yyq2[3] = x.Version != "" @@ -537,16 +982,34 @@ func (x *ClusterStatus) CodecEncodeSelf(e *codec1978.Encoder) { if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) if yyq2[0] { - x.Phase.CodecEncodeSelf(e) + if x.Conditions == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + h.encSliceClusterCondition(([]ClusterCondition)(x.Conditions), e) + } + } } else { - r.EncodeString(codecSelferC_UTF81234, "") + r.EncodeNil() } } else { if yyq2[0] { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("phase")) + r.EncodeString(codecSelferC_UTF81234, string("conditions")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - x.Phase.CodecEncodeSelf(e) + if x.Conditions == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + h.encSliceClusterCondition(([]ClusterCondition)(x.Conditions), e) + } + } } } if yyr2 || yy2arr2 { @@ -685,25 +1148,31 @@ func (x *ClusterStatus) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { yys3 := string(yys3Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) switch yys3 { - case "phase": + case "conditions": if r.TryDecodeAsNil() { - x.Phase = "" + x.Conditions = nil } else { - x.Phase = ClusterPhase(r.DecodeString()) + yyv4 := &x.Conditions + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + h.decSliceClusterCondition((*[]ClusterCondition)(yyv4), d) + } } case "capacity": if r.TryDecodeAsNil() { x.Capacity = nil } else { - yyv5 := &x.Capacity - yyv5.CodecDecodeSelf(d) + yyv6 := &x.Capacity + yyv6.CodecDecodeSelf(d) } case "allocatable": if r.TryDecodeAsNil() { x.Allocatable = nil } else { - yyv6 := &x.Allocatable - yyv6.CodecDecodeSelf(d) + yyv7 := &x.Allocatable + yyv7.CodecDecodeSelf(d) } case "version": if r.TryDecodeAsNil() { @@ -722,32 +1191,38 @@ func (x *ClusterStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj8 int - var yyb8 bool - var yyhl8 bool = l >= 0 - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + var yyj9 int + var yyb9 bool + var yyhl9 bool = l >= 0 + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } z.DecSendContainerState(codecSelfer_containerArrayElem1234) if r.TryDecodeAsNil() { - x.Phase = "" + x.Conditions = nil } else { - x.Phase = ClusterPhase(r.DecodeString()) + yyv10 := &x.Conditions + yym11 := z.DecBinary() + _ = yym11 + if false { + } else { + h.decSliceClusterCondition((*[]ClusterCondition)(yyv10), d) + } } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -755,16 +1230,16 @@ func (x *ClusterStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Capacity = nil } else { - yyv10 := &x.Capacity - yyv10.CodecDecodeSelf(d) + yyv12 := &x.Capacity + yyv12.CodecDecodeSelf(d) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -772,16 +1247,16 @@ func (x *ClusterStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Allocatable = nil } else { - yyv11 := &x.Allocatable - yyv11.CodecDecodeSelf(d) + yyv13 := &x.Allocatable + yyv13.CodecDecodeSelf(d) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -792,17 +1267,17 @@ func (x *ClusterStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { x.Version = string(r.DecodeString()) } for { - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj8-1, "") + z.DecStructFieldNotFound(yyj9-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -1637,6 +2112,125 @@ func (x codecSelfer1234) decSliceunversioned_ServerAddressByClientCIDR(v *[]pkg1 } } +func (x codecSelfer1234) encSliceClusterCondition(v []ClusterCondition, e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.EncodeArrayStart(len(v)) + for _, yyv1 := range v { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy2 := &yyv1 + yy2.CodecEncodeSelf(e) + } + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x codecSelfer1234) decSliceClusterCondition(v *[]ClusterCondition, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []ClusterCondition{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else if yyl1 > 0 { + var yyrr1, yyrl1 int + var yyrt1 bool + _, _ = yyrl1, yyrt1 + yyrr1 = yyl1 // len(yyv1) + if yyl1 > cap(yyv1) { + + yyrg1 := len(yyv1) > 0 + yyv21 := yyv1 + yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 112) + if yyrt1 { + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]ClusterCondition, yyrl1) + } + } else { + yyv1 = make([]ClusterCondition, yyrl1) + } + yyc1 = true + yyrr1 = len(yyv1) + if yyrg1 { + copy(yyv1, yyv21) + } + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + yyj1 := 0 + for ; yyj1 < yyrr1; yyj1++ { + yyh1.ElemContainerState(yyj1) + if r.TryDecodeAsNil() { + yyv1[yyj1] = ClusterCondition{} + } else { + yyv2 := &yyv1[yyj1] + yyv2.CodecDecodeSelf(d) + } + + } + if yyrt1 { + for ; yyj1 < yyl1; yyj1++ { + yyv1 = append(yyv1, ClusterCondition{}) + yyh1.ElemContainerState(yyj1) + if r.TryDecodeAsNil() { + yyv1[yyj1] = ClusterCondition{} + } else { + yyv3 := &yyv1[yyj1] + yyv3.CodecDecodeSelf(d) + } + + } + } + + } else { + yyj1 := 0 + for ; !r.CheckBreak(); yyj1++ { + + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, ClusterCondition{}) // var yyz1 ClusterCondition + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + if yyj1 < len(yyv1) { + if r.TryDecodeAsNil() { + yyv1[yyj1] = ClusterCondition{} + } else { + yyv4 := &yyv1[yyj1] + yyv4.CodecDecodeSelf(d) + } + + } else { + z.DecSwallow() + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = []ClusterCondition{} + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } +} + func (x codecSelfer1234) encSliceCluster(v []Cluster, e *codec1978.Encoder) { var h codecSelfer1234 z, r := codec1978.GenHelperEncoder(e) @@ -1676,7 +2270,7 @@ func (x codecSelfer1234) decSliceCluster(v *[]Cluster, d *codec1978.Decoder) { yyrg1 := len(yyv1) > 0 yyv21 := yyv1 - yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 280) + yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 288) if yyrt1 { if yyrl1 <= cap(yyv1) { yyv1 = yyv1[:yyrl1] diff --git a/federation/apis/federation/types.go b/federation/apis/federation/types.go index 2b26b2fab87..7ccbb9b2855 100644 --- a/federation/apis/federation/types.go +++ b/federation/apis/federation/types.go @@ -34,20 +34,32 @@ type ClusterSpec struct { Credential string `json:"credential,omitempty"` } -type ClusterPhase string +type ClusterConditionType string -// These are the valid phases of a cluster. +// These are valid conditions of a cluster. const ( - // Newly registered clusters or clusters suspended by admin for various reasons. They are not eligible for accepting workloads - ClusterPending ClusterPhase = "pending" - // Clusters in normal status that can accept workloads - ClusterRunning ClusterPhase = "running" - // Clusters temporarily down or not reachable - ClusterOffline ClusterPhase = "offline" - // Clusters removed from federation - ClusterTerminated ClusterPhase = "terminated" + // ClusterReady means the cluster is ready to accept workloads. + ClusterReady ClusterConditionType = "Ready" + // ClusterOffline means the cluster is temporarily down or not reachable + ClusterOffline ClusterConditionType = "Offline" ) +// ClusterCondition describes current state of a cluster. +type ClusterCondition struct { + // Type of cluster condition, Complete or Failed. + Type ClusterConditionType `json:"type"` + // Status of the condition, one of True, False, Unknown. + Status api.ConditionStatus `json:"status"` + // Last time the condition was checked. + LastProbeTime unversioned.Time `json:"lastProbeTime,omitempty"` + // Last time the condition transit from one status to another. + LastTransitionTime unversioned.Time `json:"lastTransitionTime,omitempty"` + // (brief) reason for the condition's last transition. + Reason string `json:"reason,omitempty"` + // Human readable message indicating details about last transition. + Message string `json:"message,omitempty"` +} + // Cluster metadata type ClusterMeta struct { // Release version of the cluster. @@ -56,8 +68,8 @@ type ClusterMeta struct { // ClusterStatus is information about the current status of a cluster updated by cluster controller peridocally. type ClusterStatus struct { - // Phase is the recently observed lifecycle phase of the cluster. - Phase ClusterPhase `json:"phase,omitempty"` + // Conditions is an array of current cluster conditions. + Conditions []ClusterCondition `json:"conditions,omitempty"` // Capacity represents the total resources of the cluster Capacity api.ResourceList `json:"capacity,omitempty"` // Allocatable represents the total resources of a cluster that are available for scheduling. diff --git a/federation/apis/federation/v1alpha1/conversion.go b/federation/apis/federation/v1alpha1/conversion.go index c2626849814..c4c8ebbb37f 100644 --- a/federation/apis/federation/v1alpha1/conversion.go +++ b/federation/apis/federation/v1alpha1/conversion.go @@ -27,8 +27,7 @@ func addConversionFuncs(scheme *runtime.Scheme) { err := api.Scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.String(), "Cluster", func(label, value string) (string, string, error) { switch label { - case "metadata.name", - "status.phase": + case "metadata.name": return label, value, nil default: return "", "", fmt.Errorf("field label not supported: %s", label) diff --git a/federation/apis/federation/v1alpha1/conversion_generated.go b/federation/apis/federation/v1alpha1/conversion_generated.go index a2f2c41d1b3..47d2da6b102 100644 --- a/federation/apis/federation/v1alpha1/conversion_generated.go +++ b/federation/apis/federation/v1alpha1/conversion_generated.go @@ -34,6 +34,8 @@ func init() { if err := api.Scheme.AddGeneratedConversionFuncs( Convert_v1alpha1_Cluster_To_federation_Cluster, Convert_federation_Cluster_To_v1alpha1_Cluster, + Convert_v1alpha1_ClusterCondition_To_federation_ClusterCondition, + Convert_federation_ClusterCondition_To_v1alpha1_ClusterCondition, Convert_v1alpha1_ClusterList_To_federation_ClusterList, Convert_federation_ClusterList_To_v1alpha1_ClusterList, Convert_v1alpha1_ClusterMeta_To_federation_ClusterMeta, @@ -96,6 +98,48 @@ func Convert_federation_Cluster_To_v1alpha1_Cluster(in *federation.Cluster, out return autoConvert_federation_Cluster_To_v1alpha1_Cluster(in, out, s) } +func autoConvert_v1alpha1_ClusterCondition_To_federation_ClusterCondition(in *ClusterCondition, out *federation.ClusterCondition, s conversion.Scope) error { + if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { + defaulting.(func(*ClusterCondition))(in) + } + out.Type = federation.ClusterConditionType(in.Type) + out.Status = api.ConditionStatus(in.Status) + if err := api.Convert_unversioned_Time_To_unversioned_Time(&in.LastProbeTime, &out.LastProbeTime, s); err != nil { + return err + } + if err := api.Convert_unversioned_Time_To_unversioned_Time(&in.LastTransitionTime, &out.LastTransitionTime, s); err != nil { + return err + } + out.Reason = in.Reason + out.Message = in.Message + return nil +} + +func Convert_v1alpha1_ClusterCondition_To_federation_ClusterCondition(in *ClusterCondition, out *federation.ClusterCondition, s conversion.Scope) error { + return autoConvert_v1alpha1_ClusterCondition_To_federation_ClusterCondition(in, out, s) +} + +func autoConvert_federation_ClusterCondition_To_v1alpha1_ClusterCondition(in *federation.ClusterCondition, out *ClusterCondition, s conversion.Scope) error { + if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { + defaulting.(func(*federation.ClusterCondition))(in) + } + out.Type = ClusterConditionType(in.Type) + out.Status = v1.ConditionStatus(in.Status) + if err := api.Convert_unversioned_Time_To_unversioned_Time(&in.LastProbeTime, &out.LastProbeTime, s); err != nil { + return err + } + if err := api.Convert_unversioned_Time_To_unversioned_Time(&in.LastTransitionTime, &out.LastTransitionTime, s); err != nil { + return err + } + out.Reason = in.Reason + out.Message = in.Message + return nil +} + +func Convert_federation_ClusterCondition_To_v1alpha1_ClusterCondition(in *federation.ClusterCondition, out *ClusterCondition, s conversion.Scope) error { + return autoConvert_federation_ClusterCondition_To_v1alpha1_ClusterCondition(in, out, s) +} + func autoConvert_v1alpha1_ClusterList_To_federation_ClusterList(in *ClusterList, out *federation.ClusterList, s conversion.Scope) error { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*ClusterList))(in) @@ -228,7 +272,17 @@ func autoConvert_v1alpha1_ClusterStatus_To_federation_ClusterStatus(in *ClusterS if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*ClusterStatus))(in) } - out.Phase = federation.ClusterPhase(in.Phase) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]federation.ClusterCondition, len(*in)) + for i := range *in { + if err := Convert_v1alpha1_ClusterCondition_To_federation_ClusterCondition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } if err := v1.Convert_v1_ResourceList_To_api_ResourceList(&in.Capacity, &out.Capacity, s); err != nil { return err } @@ -249,7 +303,17 @@ func autoConvert_federation_ClusterStatus_To_v1alpha1_ClusterStatus(in *federati if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*federation.ClusterStatus))(in) } - out.Phase = ClusterPhase(in.Phase) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]ClusterCondition, len(*in)) + for i := range *in { + if err := Convert_federation_ClusterCondition_To_v1alpha1_ClusterCondition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } if in.Capacity != nil { in, out := &in.Capacity, &out.Capacity *out = make(v1.ResourceList, len(*in)) diff --git a/federation/apis/federation/v1alpha1/deep_copy_generated.go b/federation/apis/federation/v1alpha1/deep_copy_generated.go index 51cd408a6ef..7eac37de3c3 100644 --- a/federation/apis/federation/v1alpha1/deep_copy_generated.go +++ b/federation/apis/federation/v1alpha1/deep_copy_generated.go @@ -31,6 +31,7 @@ import ( func init() { if err := api.Scheme.AddGeneratedDeepCopyFuncs( DeepCopy_v1alpha1_Cluster, + DeepCopy_v1alpha1_ClusterCondition, DeepCopy_v1alpha1_ClusterList, DeepCopy_v1alpha1_ClusterMeta, DeepCopy_v1alpha1_ClusterSpec, @@ -57,6 +58,20 @@ func DeepCopy_v1alpha1_Cluster(in Cluster, out *Cluster, c *conversion.Cloner) e return nil } +func DeepCopy_v1alpha1_ClusterCondition(in ClusterCondition, out *ClusterCondition, c *conversion.Cloner) error { + out.Type = in.Type + out.Status = in.Status + if err := unversioned.DeepCopy_unversioned_Time(in.LastProbeTime, &out.LastProbeTime, c); err != nil { + return err + } + if err := unversioned.DeepCopy_unversioned_Time(in.LastTransitionTime, &out.LastTransitionTime, c); err != nil { + return err + } + out.Reason = in.Reason + out.Message = in.Message + return nil +} + func DeepCopy_v1alpha1_ClusterList(in ClusterList, out *ClusterList, c *conversion.Cloner) error { if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { return err @@ -100,7 +115,17 @@ func DeepCopy_v1alpha1_ClusterSpec(in ClusterSpec, out *ClusterSpec, c *conversi } func DeepCopy_v1alpha1_ClusterStatus(in ClusterStatus, out *ClusterStatus, c *conversion.Cloner) error { - out.Phase = in.Phase + if in.Conditions != nil { + in, out := in.Conditions, &out.Conditions + *out = make([]ClusterCondition, len(in)) + for i := range in { + if err := DeepCopy_v1alpha1_ClusterCondition(in[i], &(*out)[i], c); err != nil { + return err + } + } + } else { + out.Conditions = nil + } if in.Capacity != nil { in, out := in.Capacity, &out.Capacity *out = make(v1.ResourceList) diff --git a/federation/apis/federation/v1alpha1/defaults.go b/federation/apis/federation/v1alpha1/defaults.go index 1ef685494be..d69bb7f0444 100644 --- a/federation/apis/federation/v1alpha1/defaults.go +++ b/federation/apis/federation/v1alpha1/defaults.go @@ -21,11 +21,4 @@ import ( ) func addDefaultingFuncs(scheme *runtime.Scheme) { - scheme.AddDefaultingFuncs( - func(obj *Cluster) { - if obj.Status.Phase == "" { - obj.Status.Phase = ClusterPending - } - }, - ) } diff --git a/federation/apis/federation/v1alpha1/types.generated.go b/federation/apis/federation/v1alpha1/types.generated.go index c736b2932de..2f4eac23372 100644 --- a/federation/apis/federation/v1alpha1/types.generated.go +++ b/federation/apis/federation/v1alpha1/types.generated.go @@ -67,7 +67,7 @@ func init() { if false { // reference the types, but skip this branch at build/run time var v0 pkg3_resource.Quantity var v1 pkg1_unversioned.ServerAddressByClientCIDR - var v2 pkg2_v1.ResourceList + var v2 pkg2_v1.ConditionStatus var v3 pkg5_types.UID var v4 pkg4_inf.Dec var v5 time.Time @@ -305,7 +305,7 @@ func (x *ClusterSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } -func (x ClusterPhase) CodecEncodeSelf(e *codec1978.Encoder) { +func (x ClusterConditionType) CodecEncodeSelf(e *codec1978.Encoder) { var h codecSelfer1234 z, r := codec1978.GenHelperEncoder(e) _, _, _ = h, z, r @@ -318,7 +318,7 @@ func (x ClusterPhase) CodecEncodeSelf(e *codec1978.Encoder) { } } -func (x *ClusterPhase) CodecDecodeSelf(d *codec1978.Decoder) { +func (x *ClusterConditionType) CodecDecodeSelf(d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r @@ -331,6 +331,451 @@ func (x *ClusterPhase) CodecDecodeSelf(d *codec1978.Decoder) { } } +func (x *ClusterCondition) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + var yyq2 [6]bool + _, _, _ = yysep2, yyq2, yy2arr2 + const yyr2 bool = false + yyq2[2] = true + yyq2[3] = true + yyq2[4] = x.Reason != "" + yyq2[5] = x.Message != "" + var yynn2 int + if yyr2 || yy2arr2 { + r.EncodeArrayStart(6) + } else { + yynn2 = 2 + for _, b := range yyq2 { + if b { + yynn2++ + } + } + r.EncodeMapStart(yynn2) + yynn2 = 0 + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + x.Type.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("type")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + x.Type.CodecEncodeSelf(e) + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yysf7 := &x.Status + yysf7.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("status")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yysf8 := &x.Status + yysf8.CodecEncodeSelf(e) + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[2] { + yy10 := &x.LastProbeTime + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(yy10) { + } else if yym11 { + z.EncBinaryMarshal(yy10) + } else if !yym11 && z.IsJSONHandle() { + z.EncJSONMarshal(yy10) + } else { + z.EncFallback(yy10) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[2] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("lastProbeTime")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy12 := &x.LastProbeTime + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(yy12) { + } else if yym13 { + z.EncBinaryMarshal(yy12) + } else if !yym13 && z.IsJSONHandle() { + z.EncJSONMarshal(yy12) + } else { + z.EncFallback(yy12) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[3] { + yy15 := &x.LastTransitionTime + yym16 := z.EncBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.EncExt(yy15) { + } else if yym16 { + z.EncBinaryMarshal(yy15) + } else if !yym16 && z.IsJSONHandle() { + z.EncJSONMarshal(yy15) + } else { + z.EncFallback(yy15) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[3] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("lastTransitionTime")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy17 := &x.LastTransitionTime + yym18 := z.EncBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.EncExt(yy17) { + } else if yym18 { + z.EncBinaryMarshal(yy17) + } else if !yym18 && z.IsJSONHandle() { + z.EncJSONMarshal(yy17) + } else { + z.EncFallback(yy17) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[4] { + yym20 := z.EncBinary() + _ = yym20 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Reason)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[4] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("reason")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym21 := z.EncBinary() + _ = yym21 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Reason)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[5] { + yym23 := z.EncBinary() + _ = yym23 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Message)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[5] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("message")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym24 := z.EncBinary() + _ = yym24 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Message)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *ClusterCondition) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap1234 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray1234 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *ClusterCondition) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys3Slc = r.DecodeBytes(yys3Slc, true, true) + yys3 := string(yys3Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys3 { + case "type": + if r.TryDecodeAsNil() { + x.Type = "" + } else { + x.Type = ClusterConditionType(r.DecodeString()) + } + case "status": + if r.TryDecodeAsNil() { + x.Status = "" + } else { + x.Status = pkg2_v1.ConditionStatus(r.DecodeString()) + } + case "lastProbeTime": + if r.TryDecodeAsNil() { + x.LastProbeTime = pkg1_unversioned.Time{} + } else { + yyv6 := &x.LastProbeTime + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else if yym7 { + z.DecBinaryUnmarshal(yyv6) + } else if !yym7 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv6) + } else { + z.DecFallback(yyv6, false) + } + } + case "lastTransitionTime": + if r.TryDecodeAsNil() { + x.LastTransitionTime = pkg1_unversioned.Time{} + } else { + yyv8 := &x.LastTransitionTime + yym9 := z.DecBinary() + _ = yym9 + if false { + } else if z.HasExtensions() && z.DecExt(yyv8) { + } else if yym9 { + z.DecBinaryUnmarshal(yyv8) + } else if !yym9 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv8) + } else { + z.DecFallback(yyv8, false) + } + } + case "reason": + if r.TryDecodeAsNil() { + x.Reason = "" + } else { + x.Reason = string(r.DecodeString()) + } + case "message": + if r.TryDecodeAsNil() { + x.Message = "" + } else { + x.Message = string(r.DecodeString()) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *ClusterCondition) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj12 int + var yyb12 bool + var yyhl12 bool = l >= 0 + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Type = "" + } else { + x.Type = ClusterConditionType(r.DecodeString()) + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Status = "" + } else { + x.Status = pkg2_v1.ConditionStatus(r.DecodeString()) + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.LastProbeTime = pkg1_unversioned.Time{} + } else { + yyv15 := &x.LastProbeTime + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else if yym16 { + z.DecBinaryUnmarshal(yyv15) + } else if !yym16 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv15) + } else { + z.DecFallback(yyv15, false) + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.LastTransitionTime = pkg1_unversioned.Time{} + } else { + yyv17 := &x.LastTransitionTime + yym18 := z.DecBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.DecExt(yyv17) { + } else if yym18 { + z.DecBinaryUnmarshal(yyv17) + } else if !yym18 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv17) + } else { + z.DecFallback(yyv17, false) + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Reason = "" + } else { + x.Reason = string(r.DecodeString()) + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Message = "" + } else { + x.Message = string(r.DecodeString()) + } + for { + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj12-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + func (x *ClusterMeta) CodecEncodeSelf(e *codec1978.Encoder) { var h codecSelfer1234 z, r := codec1978.GenHelperEncoder(e) @@ -517,7 +962,7 @@ func (x *ClusterStatus) CodecEncodeSelf(e *codec1978.Encoder) { var yyq2 [4]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false - yyq2[0] = x.Phase != "" + yyq2[0] = len(x.Conditions) != 0 yyq2[1] = len(x.Capacity) != 0 yyq2[2] = len(x.Allocatable) != 0 yyq2[3] = x.Version != "" @@ -537,16 +982,34 @@ func (x *ClusterStatus) CodecEncodeSelf(e *codec1978.Encoder) { if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) if yyq2[0] { - x.Phase.CodecEncodeSelf(e) + if x.Conditions == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + h.encSliceClusterCondition(([]ClusterCondition)(x.Conditions), e) + } + } } else { - r.EncodeString(codecSelferC_UTF81234, "") + r.EncodeNil() } } else { if yyq2[0] { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("phase")) + r.EncodeString(codecSelferC_UTF81234, string("conditions")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - x.Phase.CodecEncodeSelf(e) + if x.Conditions == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + h.encSliceClusterCondition(([]ClusterCondition)(x.Conditions), e) + } + } } } if yyr2 || yy2arr2 { @@ -685,25 +1148,31 @@ func (x *ClusterStatus) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { yys3 := string(yys3Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) switch yys3 { - case "phase": + case "conditions": if r.TryDecodeAsNil() { - x.Phase = "" + x.Conditions = nil } else { - x.Phase = ClusterPhase(r.DecodeString()) + yyv4 := &x.Conditions + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + h.decSliceClusterCondition((*[]ClusterCondition)(yyv4), d) + } } case "capacity": if r.TryDecodeAsNil() { x.Capacity = nil } else { - yyv5 := &x.Capacity - yyv5.CodecDecodeSelf(d) + yyv6 := &x.Capacity + yyv6.CodecDecodeSelf(d) } case "allocatable": if r.TryDecodeAsNil() { x.Allocatable = nil } else { - yyv6 := &x.Allocatable - yyv6.CodecDecodeSelf(d) + yyv7 := &x.Allocatable + yyv7.CodecDecodeSelf(d) } case "version": if r.TryDecodeAsNil() { @@ -722,32 +1191,38 @@ func (x *ClusterStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj8 int - var yyb8 bool - var yyhl8 bool = l >= 0 - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + var yyj9 int + var yyb9 bool + var yyhl9 bool = l >= 0 + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } z.DecSendContainerState(codecSelfer_containerArrayElem1234) if r.TryDecodeAsNil() { - x.Phase = "" + x.Conditions = nil } else { - x.Phase = ClusterPhase(r.DecodeString()) + yyv10 := &x.Conditions + yym11 := z.DecBinary() + _ = yym11 + if false { + } else { + h.decSliceClusterCondition((*[]ClusterCondition)(yyv10), d) + } } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -755,16 +1230,16 @@ func (x *ClusterStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Capacity = nil } else { - yyv10 := &x.Capacity - yyv10.CodecDecodeSelf(d) + yyv12 := &x.Capacity + yyv12.CodecDecodeSelf(d) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -772,16 +1247,16 @@ func (x *ClusterStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Allocatable = nil } else { - yyv11 := &x.Allocatable - yyv11.CodecDecodeSelf(d) + yyv13 := &x.Allocatable + yyv13.CodecDecodeSelf(d) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -792,17 +1267,17 @@ func (x *ClusterStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { x.Version = string(r.DecodeString()) } for { - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l } else { - yyb8 = r.CheckBreak() + yyb9 = r.CheckBreak() } - if yyb8 { + if yyb9 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj8-1, "") + z.DecStructFieldNotFound(yyj9-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -1637,6 +2112,125 @@ func (x codecSelfer1234) decSliceunversioned_ServerAddressByClientCIDR(v *[]pkg1 } } +func (x codecSelfer1234) encSliceClusterCondition(v []ClusterCondition, e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.EncodeArrayStart(len(v)) + for _, yyv1 := range v { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy2 := &yyv1 + yy2.CodecEncodeSelf(e) + } + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x codecSelfer1234) decSliceClusterCondition(v *[]ClusterCondition, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []ClusterCondition{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else if yyl1 > 0 { + var yyrr1, yyrl1 int + var yyrt1 bool + _, _ = yyrl1, yyrt1 + yyrr1 = yyl1 // len(yyv1) + if yyl1 > cap(yyv1) { + + yyrg1 := len(yyv1) > 0 + yyv21 := yyv1 + yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 112) + if yyrt1 { + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]ClusterCondition, yyrl1) + } + } else { + yyv1 = make([]ClusterCondition, yyrl1) + } + yyc1 = true + yyrr1 = len(yyv1) + if yyrg1 { + copy(yyv1, yyv21) + } + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + yyj1 := 0 + for ; yyj1 < yyrr1; yyj1++ { + yyh1.ElemContainerState(yyj1) + if r.TryDecodeAsNil() { + yyv1[yyj1] = ClusterCondition{} + } else { + yyv2 := &yyv1[yyj1] + yyv2.CodecDecodeSelf(d) + } + + } + if yyrt1 { + for ; yyj1 < yyl1; yyj1++ { + yyv1 = append(yyv1, ClusterCondition{}) + yyh1.ElemContainerState(yyj1) + if r.TryDecodeAsNil() { + yyv1[yyj1] = ClusterCondition{} + } else { + yyv3 := &yyv1[yyj1] + yyv3.CodecDecodeSelf(d) + } + + } + } + + } else { + yyj1 := 0 + for ; !r.CheckBreak(); yyj1++ { + + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, ClusterCondition{}) // var yyz1 ClusterCondition + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + if yyj1 < len(yyv1) { + if r.TryDecodeAsNil() { + yyv1[yyj1] = ClusterCondition{} + } else { + yyv4 := &yyv1[yyj1] + yyv4.CodecDecodeSelf(d) + } + + } else { + z.DecSwallow() + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = []ClusterCondition{} + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } +} + func (x codecSelfer1234) encSliceCluster(v []Cluster, e *codec1978.Encoder) { var h codecSelfer1234 z, r := codec1978.GenHelperEncoder(e) @@ -1676,7 +2270,7 @@ func (x codecSelfer1234) decSliceCluster(v *[]Cluster, d *codec1978.Decoder) { yyrg1 := len(yyv1) > 0 yyv21 := yyv1 - yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 280) + yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 288) if yyrt1 { if yyrl1 <= cap(yyv1) { yyv1 = yyv1[:yyrl1] diff --git a/federation/apis/federation/v1alpha1/types.go b/federation/apis/federation/v1alpha1/types.go index 14777925068..37894b88110 100644 --- a/federation/apis/federation/v1alpha1/types.go +++ b/federation/apis/federation/v1alpha1/types.go @@ -34,20 +34,32 @@ type ClusterSpec struct { Credential string `json:"credential,omitempty"` } -type ClusterPhase string +type ClusterConditionType string -// These are the valid phases of a cluster. +// These are valid conditions of a cluster. const ( - // Newly registered clusters or clusters suspended by admin for various reasons. They are not eligible for accepting workloads - ClusterPending ClusterPhase = "pending" - // Clusters in normal status that can accept workloads - ClusterRunning ClusterPhase = "running" - // Clusters temporarily down or not reachable - ClusterOffline ClusterPhase = "offline" - // Clusters removed from federation - ClusterTerminated ClusterPhase = "terminated" + // ClusterReady means the cluster is ready to accept workloads. + ClusterReady ClusterConditionType = "Ready" + // ClusterOffline means the cluster is temporarily down or not reachable + ClusterOffline ClusterConditionType = "Offline" ) +// ClusterCondition describes current state of a cluster. +type ClusterCondition struct { + // Type of cluster condition, Complete or Failed. + Type ClusterConditionType `json:"type"` + // Status of the condition, one of True, False, Unknown. + Status v1.ConditionStatus `json:"status"` + // Last time the condition was checked. + LastProbeTime unversioned.Time `json:"lastProbeTime,omitempty"` + // Last time the condition transit from one status to another. + LastTransitionTime unversioned.Time `json:"lastTransitionTime,omitempty"` + // (brief) reason for the condition's last transition. + Reason string `json:"reason,omitempty"` + // Human readable message indicating details about last transition. + Message string `json:"message,omitempty"` +} + // Cluster metadata type ClusterMeta struct { // Release version of the cluster. @@ -56,8 +68,8 @@ type ClusterMeta struct { // ClusterStatus is information about the current status of a cluster updated by cluster controller peridocally. type ClusterStatus struct { - // Phase is the recently observed lifecycle phase of the cluster. - Phase ClusterPhase `json:"phase,omitempty"` + // Conditions is an array of current cluster conditions. + Conditions []ClusterCondition `json:"conditions,omitempty"` // Capacity represents the total resources of the cluster Capacity v1.ResourceList `json:"capacity,omitempty"` // Allocatable represents the total resources of a cluster that are available for scheduling. diff --git a/federation/apis/federation/validation/validation.go b/federation/apis/federation/validation/validation.go index 0c656a0c853..f6f3dac4838 100644 --- a/federation/apis/federation/validation/validation.go +++ b/federation/apis/federation/validation/validation.go @@ -50,25 +50,7 @@ func ValidateClusterUpdate(cluster, oldCluster *federation.Cluster) field.ErrorL return allErrs } -func phaseTransitionAllowed(from, to federation.ClusterPhase) bool { - validPhaseTransition := map[federation.ClusterPhase][]federation.ClusterPhase{ - federation.ClusterPending: {federation.ClusterRunning, federation.ClusterOffline, federation.ClusterTerminated}, - federation.ClusterRunning: {federation.ClusterPending, federation.ClusterOffline, federation.ClusterTerminated}, - federation.ClusterOffline: {federation.ClusterRunning, federation.ClusterTerminated}, - federation.ClusterTerminated: {}, - } - for _, allowedPhase := range validPhaseTransition[from] { - if to == allowedPhase { - return true - } - } - return false -} func ValidateClusterStatusUpdate(cluster, oldCluster *federation.Cluster) field.ErrorList { allErrs := validation.ValidateObjectMetaUpdate(&cluster.ObjectMeta, &oldCluster.ObjectMeta, field.NewPath("metadata")) - if !phaseTransitionAllowed(oldCluster.Status.Phase, cluster.Status.Phase) { - allErrs = append(allErrs, field.Invalid(field.NewPath("status", "phase"), - oldCluster.Status.Phase+" => "+cluster.Status.Phase, "cluster phase transition not allowed")) - } return allErrs } diff --git a/federation/apis/federation/validation/validation_test.go b/federation/apis/federation/validation/validation_test.go index abc0c7457e9..d68883675cd 100644 --- a/federation/apis/federation/validation/validation_test.go +++ b/federation/apis/federation/validation/validation_test.go @@ -163,7 +163,9 @@ func TestValidateClusterStatusUpdate(t *testing.T) { }, }, Status: federation.ClusterStatus{ - Phase: federation.ClusterPending, + Conditions: []federation.ClusterCondition{ + {Type: federation.ClusterReady, Status: api.ConditionTrue}, + }, }, }, update: federation.Cluster{ @@ -177,7 +179,10 @@ func TestValidateClusterStatusUpdate(t *testing.T) { }, }, Status: federation.ClusterStatus{ - Phase: federation.ClusterRunning, + Conditions: []federation.ClusterCondition{ + {Type: federation.ClusterReady, Status: api.ConditionTrue}, + {Type: federation.ClusterOffline, Status: api.ConditionTrue}, + }, }, }, }, @@ -191,38 +196,7 @@ func TestValidateClusterStatusUpdate(t *testing.T) { } } - errorCases := map[string]clusterUpdateTest{ - "cluster phase transition not allowed": { - old: federation.Cluster{ - ObjectMeta: api.ObjectMeta{Name: "cluster-s"}, - Spec: federation.ClusterSpec{ - ServerAddressByClientCIDRs: []unversioned.ServerAddressByClientCIDR{ - { - ClientCIDR: "0.0.0.0/0", - ServerAddress: "localhost:8888", - }, - }, - }, - Status: federation.ClusterStatus{ - Phase: federation.ClusterOffline, - }, - }, - update: federation.Cluster{ - ObjectMeta: api.ObjectMeta{Name: "cluster-newname"}, - Spec: federation.ClusterSpec{ - ServerAddressByClientCIDRs: []unversioned.ServerAddressByClientCIDR{ - { - ClientCIDR: "0.0.0.0/0", - ServerAddress: "localhost:8888", - }, - }, - }, - Status: federation.ClusterStatus{ - Phase: federation.ClusterPending, - }, - }, - }, - } + errorCases := map[string]clusterUpdateTest{} for testName, errorCase := range errorCases { errs := ValidateClusterStatusUpdate(&errorCase.update, &errorCase.old) if len(errs) == 0 { diff --git a/federation/registry/cluster/etcd/etcd_test.go b/federation/registry/cluster/etcd/etcd_test.go index cb4d3278767..41496db3646 100644 --- a/federation/registry/cluster/etcd/etcd_test.go +++ b/federation/registry/cluster/etcd/etcd_test.go @@ -57,7 +57,9 @@ func validNewCluster() *federation.Cluster { }, }, Status: federation.ClusterStatus{ - Phase: federation.ClusterPending, + Conditions: []federation.ClusterCondition{ + {Type: federation.ClusterReady, Status: api.ConditionFalse}, + }, }, } } diff --git a/federation/registry/cluster/strategy.go b/federation/registry/cluster/strategy.go index 1130a5e9653..8557a66f7dd 100644 --- a/federation/registry/cluster/strategy.go +++ b/federation/registry/cluster/strategy.go @@ -41,11 +41,7 @@ func (clusterStrategy) NamespaceScoped() bool { } func ClusterToSelectableFields(cluster *federation.Cluster) fields.Set { - objectMetaFieldsSet := generic.ObjectMetaFieldsSet(cluster.ObjectMeta, false) - specificFieldsSet := fields.Set{ - "status.phase": string(cluster.Status.Phase), - } - return generic.MergeFieldsSets(objectMetaFieldsSet, specificFieldsSet) + return generic.ObjectMetaFieldsSet(cluster.ObjectMeta, false) } func MatchCluster(label labels.Selector, field fields.Selector) generic.Matcher { diff --git a/federation/registry/cluster/strategy_test.go b/federation/registry/cluster/strategy_test.go index ccf9a94252d..77721ffb93b 100644 --- a/federation/registry/cluster/strategy_test.go +++ b/federation/registry/cluster/strategy_test.go @@ -47,7 +47,9 @@ func validNewCluster() *federation.Cluster { }, }, Status: federation.ClusterStatus{ - Phase: federation.ClusterTerminated, + Conditions: []federation.ClusterCondition{ + {Type: federation.ClusterReady, Status: api.ConditionTrue}, + }, }, } } @@ -62,7 +64,9 @@ func invalidNewCluster() *federation.Cluster { Credential: "bar", }, Status: federation.ClusterStatus{ - Phase: federation.ClusterPending, + Conditions: []federation.ClusterCondition{ + {Type: federation.ClusterReady, Status: api.ConditionFalse}, + }, }, } } @@ -78,8 +82,8 @@ func TestClusterStrategy(t *testing.T) { cluster := validNewCluster() Strategy.PrepareForCreate(cluster) - if len(cluster.Status.Phase) != 0 { - t.Errorf("Cluster should not allow setting phase on create") + if len(cluster.Status.Conditions) != 0 { + t.Errorf("Cluster should not allow setting conditions on create") } errs := Strategy.Validate(ctx, cluster) if len(errs) != 0 { @@ -115,6 +119,10 @@ func TestClusterStatusStrategy(t *testing.T) { StatusStrategy.PrepareForUpdate(cluster, invalidCluster) if !reflect.DeepEqual(invalidCluster.Spec, cluster.Spec) || reflect.DeepEqual(invalidCluster.Status, cluster.Status) { + t.Logf("== cluster.Spec: %v\n", cluster.Spec) + t.Logf("== cluster.Status: %v\n", cluster.Status) + t.Logf("== invalidCluster.Spec: %v\n", cluster.Spec) + t.Logf("== invalidCluster.Spec: %v\n", cluster.Status) t.Error("Only spec is expected being changed") } errs := Strategy.ValidateUpdate(ctx, invalidCluster, cluster)