diff --git a/api/swagger-spec/apps_v1alpha1.json b/api/swagger-spec/apps_v1alpha1.json index 3d7b59baef..d842bffb11 100644 --- a/api/swagger-spec/apps_v1alpha1.json +++ b/api/swagger-spec/apps_v1alpha1.json @@ -1100,7 +1100,7 @@ "items": { "$ref": "v1.OwnerReference" }, - "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected." + "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller." }, "finalizers": { "type": "array", @@ -1136,6 +1136,10 @@ "uid": { "type": "string", "description": "UID of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids" + }, + "controller": { + "type": "boolean", + "description": "If true, this reference points to the managing controller." } } }, diff --git a/api/swagger-spec/autoscaling_v1.json b/api/swagger-spec/autoscaling_v1.json index ffedf2692f..12d1dbbac0 100644 --- a/api/swagger-spec/autoscaling_v1.json +++ b/api/swagger-spec/autoscaling_v1.json @@ -1103,7 +1103,7 @@ "items": { "$ref": "v1.OwnerReference" }, - "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected." + "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller." }, "finalizers": { "type": "array", @@ -1139,6 +1139,10 @@ "uid": { "type": "string", "description": "UID of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids" + }, + "controller": { + "type": "boolean", + "description": "If true, this reference points to the managing controller." } } }, diff --git a/api/swagger-spec/batch_v1.json b/api/swagger-spec/batch_v1.json index 87e3c426f6..a8824a1a22 100644 --- a/api/swagger-spec/batch_v1.json +++ b/api/swagger-spec/batch_v1.json @@ -1103,7 +1103,7 @@ "items": { "$ref": "v1.OwnerReference" }, - "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected." + "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller." }, "finalizers": { "type": "array", @@ -1139,6 +1139,10 @@ "uid": { "type": "string", "description": "UID of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids" + }, + "controller": { + "type": "boolean", + "description": "If true, this reference points to the managing controller." } } }, diff --git a/api/swagger-spec/extensions_v1beta1.json b/api/swagger-spec/extensions_v1beta1.json index db44f2d56f..623a1a8ca5 100644 --- a/api/swagger-spec/extensions_v1beta1.json +++ b/api/swagger-spec/extensions_v1beta1.json @@ -6949,7 +6949,7 @@ "items": { "$ref": "v1.OwnerReference" }, - "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected." + "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller." }, "finalizers": { "type": "array", @@ -6985,6 +6985,10 @@ "uid": { "type": "string", "description": "UID of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids" + }, + "controller": { + "type": "boolean", + "description": "If true, this reference points to the managing controller." } } }, diff --git a/api/swagger-spec/policy_v1alpha1.json b/api/swagger-spec/policy_v1alpha1.json index bdb64e0ac0..3d10d7dc9c 100644 --- a/api/swagger-spec/policy_v1alpha1.json +++ b/api/swagger-spec/policy_v1alpha1.json @@ -1100,7 +1100,7 @@ "items": { "$ref": "v1.OwnerReference" }, - "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected." + "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller." }, "finalizers": { "type": "array", @@ -1136,6 +1136,10 @@ "uid": { "type": "string", "description": "UID of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids" + }, + "controller": { + "type": "boolean", + "description": "If true, this reference points to the managing controller." } } }, diff --git a/api/swagger-spec/v1.json b/api/swagger-spec/v1.json index 711b5ae7c1..52f755ec4c 100644 --- a/api/swagger-spec/v1.json +++ b/api/swagger-spec/v1.json @@ -15884,7 +15884,7 @@ "items": { "$ref": "v1.OwnerReference" }, - "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected." + "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller." }, "finalizers": { "type": "array", @@ -15920,6 +15920,10 @@ "uid": { "type": "string", "description": "UID of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids" + }, + "controller": { + "type": "boolean", + "description": "If true, this reference points to the managing controller." } } }, diff --git a/docs/api-reference/autoscaling/v1/definitions.html b/docs/api-reference/autoscaling/v1/definitions.html index 68336b212b..a916e3749a 100755 --- a/docs/api-reference/autoscaling/v1/definitions.html +++ b/docs/api-reference/autoscaling/v1/definitions.html @@ -1182,7 +1182,7 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

ownerReferences

-

List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected.

+

List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.

false

v1.OwnerReference array

@@ -1249,6 +1249,13 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

string

+ +

controller

+

If true, this reference points to the managing controller.

+

false

+

boolean

+

false

+ @@ -1324,4 +1331,4 @@ Last updated 2016-05-23 07:07:20 UTC - \ No newline at end of file + diff --git a/docs/api-reference/batch/v1/definitions.html b/docs/api-reference/batch/v1/definitions.html index ae27256e33..d3f902cd8f 100755 --- a/docs/api-reference/batch/v1/definitions.html +++ b/docs/api-reference/batch/v1/definitions.html @@ -1737,7 +1737,7 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

ownerReferences

-

List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected.

+

List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.

false

v1.OwnerReference array

@@ -1804,6 +1804,13 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

string

+ +

controller

+

If true, this reference points to the managing controller.

+

false

+

boolean

+

false

+ @@ -4100,4 +4107,4 @@ Last updated 2016-05-24 11:53:33 UTC - \ No newline at end of file + diff --git a/docs/api-reference/extensions/v1beta1/definitions.html b/docs/api-reference/extensions/v1beta1/definitions.html index 28b4cd3e87..3117e055a6 100755 --- a/docs/api-reference/extensions/v1beta1/definitions.html +++ b/docs/api-reference/extensions/v1beta1/definitions.html @@ -1644,7 +1644,7 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

ownerReferences

-

List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected.

+

List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.

false

v1.OwnerReference array

@@ -5010,6 +5010,13 @@ Both these may change in the future. Incoming requests are matched against the h

string

+ +

controller

+

If true, this reference points to the managing controller.

+

false

+

boolean

+

false

+ @@ -6090,4 +6097,4 @@ Last updated 2016-05-24 11:53:27 UTC - \ No newline at end of file + diff --git a/docs/api-reference/v1/definitions.html b/docs/api-reference/v1/definitions.html index 24be949560..bb04e14881 100755 --- a/docs/api-reference/v1/definitions.html +++ b/docs/api-reference/v1/definitions.html @@ -1993,7 +1993,7 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

ownerReferences

-

List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected.

+

List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.

false

v1.OwnerReference array

@@ -6066,6 +6066,13 @@ The resulting set of endpoints can be viewed as:

string

+ +

controller

+

If true, this reference points to the managing controller.

+

false

+

boolean

+

false

+ @@ -7995,4 +8002,4 @@ Last updated 2016-05-26 18:58:49 UTC - \ No newline at end of file + diff --git a/pkg/api/deep_copy_generated.go b/pkg/api/deep_copy_generated.go index ec1cd7ce7d..35ded191b9 100644 --- a/pkg/api/deep_copy_generated.go +++ b/pkg/api/deep_copy_generated.go @@ -1706,6 +1706,13 @@ func DeepCopy_api_OwnerReference(in OwnerReference, out *OwnerReference, c *conv out.Kind = in.Kind out.Name = in.Name out.UID = in.UID + if in.Controller != nil { + in, out := in.Controller, &out.Controller + *out = new(bool) + **out = *in + } else { + out.Controller = nil + } return nil } diff --git a/pkg/api/types.generated.go b/pkg/api/types.generated.go index 37a3bcea03..4d5a34fcf8 100644 --- a/pkg/api/types.generated.go +++ b/pkg/api/types.generated.go @@ -44018,12 +44018,13 @@ func (x *OwnerReference) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [4]bool + var yyq2 [5]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false + yyq2[4] = x.Controller != nil var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(4) + r.EncodeArrayStart(5) } else { yynn2 = 4 for _, b := range yyq2 { @@ -44112,6 +44113,41 @@ func (x *OwnerReference) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeString(codecSelferC_UTF81234, string(x.UID)) } } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[4] { + if x.Controller == nil { + r.EncodeNil() + } else { + yy16 := *x.Controller + yym17 := z.EncBinary() + _ = yym17 + if false { + } else { + r.EncodeBool(bool(yy16)) + } + } + } else { + r.EncodeNil() + } + } else { + if yyq2[4] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("controller")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.Controller == nil { + r.EncodeNil() + } else { + yy18 := *x.Controller + yym19 := z.EncBinary() + _ = yym19 + if false { + } else { + r.EncodeBool(bool(yy18)) + } + } + } + } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) } else { @@ -44197,6 +44233,22 @@ func (x *OwnerReference) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { } else { x.UID = pkg1_types.UID(r.DecodeString()) } + case "controller": + if r.TryDecodeAsNil() { + if x.Controller != nil { + x.Controller = nil + } + } else { + if x.Controller == nil { + x.Controller = new(bool) + } + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*bool)(x.Controller)) = r.DecodeBool() + } + } default: z.DecStructFieldNotFound(-1, yys3) } // end switch yys3 @@ -44208,16 +44260,16 @@ func (x *OwnerReference) 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 yyj10 int + var yyb10 bool + var yyhl10 bool = l >= 0 + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l } else { - yyb8 = r.CheckBreak() + yyb10 = r.CheckBreak() } - if yyb8 { + if yyb10 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -44227,13 +44279,13 @@ func (x *OwnerReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } else { x.APIVersion = string(r.DecodeString()) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l } else { - yyb8 = r.CheckBreak() + yyb10 = r.CheckBreak() } - if yyb8 { + if yyb10 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -44243,13 +44295,13 @@ func (x *OwnerReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } else { x.Kind = string(r.DecodeString()) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l } else { - yyb8 = r.CheckBreak() + yyb10 = r.CheckBreak() } - if yyb8 { + if yyb10 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -44259,13 +44311,13 @@ func (x *OwnerReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } else { x.Name = string(r.DecodeString()) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l } else { - yyb8 = r.CheckBreak() + yyb10 = r.CheckBreak() } - if yyb8 { + if yyb10 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -44275,18 +44327,44 @@ func (x *OwnerReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } else { x.UID = pkg1_types.UID(r.DecodeString()) } - for { - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = r.CheckBreak() + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.Controller != nil { + x.Controller = nil } - if yyb8 { + } else { + if x.Controller == nil { + x.Controller = new(bool) + } + yym16 := z.DecBinary() + _ = yym16 + if false { + } else { + *((*bool)(x.Controller)) = r.DecodeBool() + } + } + for { + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj8-1, "") + z.DecStructFieldNotFound(yyj10-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -52860,7 +52938,7 @@ func (x codecSelfer1234) decSliceOwnerReference(v *[]OwnerReference, d *codec197 yyrg1 := len(yyv1) > 0 yyv21 := yyv1 - yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 64) + yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 72) if yyrt1 { if yyrl1 <= cap(yyv1) { yyv1 = yyv1[:yyrl1] diff --git a/pkg/api/types.go b/pkg/api/types.go index 4847ba434c..ff651936ee 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -140,7 +140,9 @@ type ObjectMeta struct { Annotations map[string]string `json:"annotations,omitempty"` // List of objects depended by this object. If ALL objects in the list have - // been deleted, this object will be garbage collected. + // been deleted, this object will be garbage collected. If this object is managed by a controller, + // then an entry in this list will point to this controller, with the controller field set to true. + // There cannot be more than one managing controller. OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"` // Must be empty before the object is deleted from the registry. Each entry @@ -2328,6 +2330,8 @@ type OwnerReference struct { // UID of the referent. // More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids UID types.UID `json:"uid"` + // If true, this reference points to the managing controller. + Controller *bool `json:"controller,omitempty"` } // ObjectReference contains enough information to let you inspect or modify the referred object. diff --git a/pkg/api/v1/conversion_generated.go b/pkg/api/v1/conversion_generated.go index 3d1ce27a92..6299f97eef 100644 --- a/pkg/api/v1/conversion_generated.go +++ b/pkg/api/v1/conversion_generated.go @@ -3629,6 +3629,13 @@ func autoConvert_v1_OwnerReference_To_api_OwnerReference(in *OwnerReference, out out.Kind = in.Kind out.Name = in.Name out.UID = in.UID + if in.Controller != nil { + in, out := &in.Controller, &out.Controller + *out = new(bool) + **out = **in + } else { + out.Controller = nil + } return nil } @@ -3641,6 +3648,13 @@ func autoConvert_api_OwnerReference_To_v1_OwnerReference(in *api.OwnerReference, out.Kind = in.Kind out.Name = in.Name out.UID = in.UID + if in.Controller != nil { + in, out := &in.Controller, &out.Controller + *out = new(bool) + **out = **in + } else { + out.Controller = nil + } return nil } diff --git a/pkg/api/v1/deep_copy_generated.go b/pkg/api/v1/deep_copy_generated.go index 6f2b1e1533..8e759583d6 100644 --- a/pkg/api/v1/deep_copy_generated.go +++ b/pkg/api/v1/deep_copy_generated.go @@ -1653,6 +1653,13 @@ func DeepCopy_v1_OwnerReference(in OwnerReference, out *OwnerReference, c *conve out.Kind = in.Kind out.Name = in.Name out.UID = in.UID + if in.Controller != nil { + in, out := in.Controller, &out.Controller + *out = new(bool) + **out = *in + } else { + out.Controller = nil + } return nil } diff --git a/pkg/api/v1/generated.pb.go b/pkg/api/v1/generated.pb.go index c78a2c0350..c933e40b56 100644 --- a/pkg/api/v1/generated.pb.go +++ b/pkg/api/v1/generated.pb.go @@ -4452,6 +4452,16 @@ func (m *OwnerReference) MarshalTo(data []byte) (int, error) { i++ i = encodeVarintGenerated(data, i, uint64(len(m.APIVersion))) i += copy(data[i:], m.APIVersion) + if m.Controller != nil { + data[i] = 0x30 + i++ + if *m.Controller { + data[i] = 1 + } else { + data[i] = 0 + } + i++ + } return i, nil } @@ -8972,6 +8982,9 @@ func (m *OwnerReference) Size() (n int) { n += 1 + l + sovGenerated(uint64(l)) l = len(m.APIVersion) n += 1 + l + sovGenerated(uint64(l)) + if m.Controller != nil { + n += 2 + } return n } @@ -23033,6 +23046,27 @@ func (m *OwnerReference) Unmarshal(data []byte) error { } m.APIVersion = string(data[iNdEx:postIndex]) iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + b := bool(v != 0) + m.Controller = &b default: iNdEx = preIndex skippy, err := skipGenerated(data[iNdEx:]) diff --git a/pkg/api/v1/generated.proto b/pkg/api/v1/generated.proto index bd4dbe7ab7..4e22e2fa49 100644 --- a/pkg/api/v1/generated.proto +++ b/pkg/api/v1/generated.proto @@ -1461,7 +1461,9 @@ message ObjectMeta { map annotations = 12; // List of objects depended by this object. If ALL objects in the list have - // been deleted, this object will be garbage collected. + // been deleted, this object will be garbage collected. If this object is managed by a controller, + // then an entry in this list will point to this controller, with the controller field set to true. + // There cannot be more than one managing controller. repeated OwnerReference ownerReferences = 13; // Must be empty before the object is deleted from the registry. Each entry @@ -1525,6 +1527,9 @@ message OwnerReference { // UID of the referent. // More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids optional string uid = 4; + + // If true, this reference points to the managing controller. + optional bool controller = 6; } // PersistentVolume (PV) is a storage resource provisioned by an administrator. diff --git a/pkg/api/v1/types.generated.go b/pkg/api/v1/types.generated.go index 4e66fdb43c..dc0a9b011c 100644 --- a/pkg/api/v1/types.generated.go +++ b/pkg/api/v1/types.generated.go @@ -43760,12 +43760,13 @@ func (x *OwnerReference) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [4]bool + var yyq2 [5]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false + yyq2[4] = x.Controller != nil var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(4) + r.EncodeArrayStart(5) } else { yynn2 = 4 for _, b := range yyq2 { @@ -43854,6 +43855,41 @@ func (x *OwnerReference) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeString(codecSelferC_UTF81234, string(x.UID)) } } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[4] { + if x.Controller == nil { + r.EncodeNil() + } else { + yy16 := *x.Controller + yym17 := z.EncBinary() + _ = yym17 + if false { + } else { + r.EncodeBool(bool(yy16)) + } + } + } else { + r.EncodeNil() + } + } else { + if yyq2[4] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("controller")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.Controller == nil { + r.EncodeNil() + } else { + yy18 := *x.Controller + yym19 := z.EncBinary() + _ = yym19 + if false { + } else { + r.EncodeBool(bool(yy18)) + } + } + } + } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) } else { @@ -43939,6 +43975,22 @@ func (x *OwnerReference) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { } else { x.UID = pkg1_types.UID(r.DecodeString()) } + case "controller": + if r.TryDecodeAsNil() { + if x.Controller != nil { + x.Controller = nil + } + } else { + if x.Controller == nil { + x.Controller = new(bool) + } + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*bool)(x.Controller)) = r.DecodeBool() + } + } default: z.DecStructFieldNotFound(-1, yys3) } // end switch yys3 @@ -43950,16 +44002,16 @@ func (x *OwnerReference) 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 yyj10 int + var yyb10 bool + var yyhl10 bool = l >= 0 + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l } else { - yyb8 = r.CheckBreak() + yyb10 = r.CheckBreak() } - if yyb8 { + if yyb10 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -43969,13 +44021,13 @@ func (x *OwnerReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } else { x.APIVersion = string(r.DecodeString()) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l } else { - yyb8 = r.CheckBreak() + yyb10 = r.CheckBreak() } - if yyb8 { + if yyb10 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -43985,13 +44037,13 @@ func (x *OwnerReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } else { x.Kind = string(r.DecodeString()) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l } else { - yyb8 = r.CheckBreak() + yyb10 = r.CheckBreak() } - if yyb8 { + if yyb10 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -44001,13 +44053,13 @@ func (x *OwnerReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } else { x.Name = string(r.DecodeString()) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l } else { - yyb8 = r.CheckBreak() + yyb10 = r.CheckBreak() } - if yyb8 { + if yyb10 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -44017,18 +44069,44 @@ func (x *OwnerReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } else { x.UID = pkg1_types.UID(r.DecodeString()) } - for { - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = r.CheckBreak() + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.Controller != nil { + x.Controller = nil } - if yyb8 { + } else { + if x.Controller == nil { + x.Controller = new(bool) + } + yym16 := z.DecBinary() + _ = yym16 + if false { + } else { + *((*bool)(x.Controller)) = r.DecodeBool() + } + } + for { + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj8-1, "") + z.DecStructFieldNotFound(yyj10-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -53032,7 +53110,7 @@ func (x codecSelfer1234) decSliceOwnerReference(v *[]OwnerReference, d *codec197 yyrg1 := len(yyv1) > 0 yyv21 := yyv1 - yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 64) + yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 72) if yyrt1 { if yyrl1 <= cap(yyv1) { yyv1 = yyv1[:yyrl1] diff --git a/pkg/api/v1/types.go b/pkg/api/v1/types.go index 382c5513fb..400646c356 100644 --- a/pkg/api/v1/types.go +++ b/pkg/api/v1/types.go @@ -177,7 +177,9 @@ type ObjectMeta struct { Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` // List of objects depended by this object. If ALL objects in the list have - // been deleted, this object will be garbage collected. + // been deleted, this object will be garbage collected. If this object is managed by a controller, + // then an entry in this list will point to this controller, with the controller field set to true. + // There cannot be more than one managing controller. OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" patchStrategy:"merge" patchMergeKey:"uid" protobuf:"bytes,13,rep,name=ownerReferences"` // Must be empty before the object is deleted from the registry. Each entry @@ -2775,6 +2777,8 @@ type OwnerReference struct { // UID of the referent. // More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids UID types.UID `json:"uid" protobuf:"bytes,4,opt,name=uid,casttype=k8s.io/kubernetes/pkg/types.UID"` + // If true, this reference points to the managing controller. + Controller *bool `json:"controller,omitempty" protobuf:"varint,6,opt,name=controller"` } // ObjectReference contains enough information to let you inspect or modify the referred object. diff --git a/pkg/api/v1/types_swagger_doc_generated.go b/pkg/api/v1/types_swagger_doc_generated.go index c18b5e7e4b..93a714586f 100644 --- a/pkg/api/v1/types_swagger_doc_generated.go +++ b/pkg/api/v1/types_swagger_doc_generated.go @@ -928,7 +928,7 @@ var map_ObjectMeta = map[string]string{ "deletionGracePeriodSeconds": "Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.", "labels": "Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md", "annotations": "Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: http://releases.k8s.io/HEAD/docs/user-guide/annotations.md", - "ownerReferences": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected.", + "ownerReferences": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.", "finalizers": "Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed.", } @@ -957,6 +957,7 @@ var map_OwnerReference = map[string]string{ "kind": "Kind of the referent. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds", "name": "Name of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#names", "uid": "UID of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#uids", + "controller": "If true, this reference points to the managing controller.", } func (OwnerReference) SwaggerDoc() map[string]string { diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index 1144cefb24..822a35735c 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -160,8 +160,17 @@ func validateOwnerReference(ownerReference api.OwnerReference, fldPath *field.Pa func ValidateOwnerReferences(ownerReferences []api.OwnerReference, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} + controllerName := "" for _, ref := range ownerReferences { allErrs = append(allErrs, validateOwnerReference(ref, fldPath)...) + if ref.Controller != nil && *ref.Controller { + if controllerName != "" { + allErrs = append(allErrs, field.Invalid(fldPath, ownerReferences, + fmt.Sprintf("Only one reference can have Controller set to true. Found \"true\" in references for %v and %v", controllerName, ref.Name))) + } else { + controllerName = ref.Name + } + } } return allErrs } diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 9e7bbdb23d..4ef74488e7 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -99,12 +99,17 @@ func TestValidateObjectMetaNamespaces(t *testing.T) { } func TestValidateObjectMetaOwnerReferences(t *testing.T) { + trueVar := true + falseVar := false testCases := []struct { - ownerReferences []api.OwnerReference - expectError bool + description string + ownerReferences []api.OwnerReference + expectError bool + expectedErrorMessage string }{ { - []api.OwnerReference{ + description: "simple success - third party extension.", + ownerReferences: []api.OwnerReference{ { APIVersion: "thirdpartyVersion", Kind: "thirdpartyKind", @@ -112,11 +117,12 @@ func TestValidateObjectMetaOwnerReferences(t *testing.T) { UID: "1", }, }, - false, + expectError: false, + expectedErrorMessage: "", }, { - // event shouldn't be set as an owner - []api.OwnerReference{ + description: "simple failures - event shouldn't be set as an owner", + ownerReferences: []api.OwnerReference{ { APIVersion: "v1", Kind: "Event", @@ -124,7 +130,76 @@ func TestValidateObjectMetaOwnerReferences(t *testing.T) { UID: "1", }, }, - true, + expectError: true, + expectedErrorMessage: "is disallowed from being an owner", + }, + { + description: "simple controller ref success - one reference with Controller set", + ownerReferences: []api.OwnerReference{ + { + APIVersion: "thirdpartyVersion", + Kind: "thirdpartyKind", + Name: "name", + UID: "1", + Controller: &falseVar, + }, + { + APIVersion: "thirdpartyVersion", + Kind: "thirdpartyKind", + Name: "name", + UID: "2", + Controller: &trueVar, + }, + { + APIVersion: "thirdpartyVersion", + Kind: "thirdpartyKind", + Name: "name", + UID: "3", + Controller: &falseVar, + }, + { + APIVersion: "thirdpartyVersion", + Kind: "thirdpartyKind", + Name: "name", + UID: "4", + }, + }, + expectError: false, + expectedErrorMessage: "", + }, + { + description: "simple controller ref failure - two references with Controller set", + ownerReferences: []api.OwnerReference{ + { + APIVersion: "thirdpartyVersion", + Kind: "thirdpartyKind", + Name: "name", + UID: "1", + Controller: &falseVar, + }, + { + APIVersion: "thirdpartyVersion", + Kind: "thirdpartyKind", + Name: "name", + UID: "2", + Controller: &trueVar, + }, + { + APIVersion: "thirdpartyVersion", + Kind: "thirdpartyKind", + Name: "name", + UID: "3", + Controller: &trueVar, + }, + { + APIVersion: "thirdpartyVersion", + Kind: "thirdpartyKind", + Name: "name", + UID: "4", + }, + }, + expectError: true, + expectedErrorMessage: "Only one reference can have Controller set to true", }, } @@ -137,13 +212,13 @@ func TestValidateObjectMetaOwnerReferences(t *testing.T) { }, field.NewPath("field")) if len(errs) != 0 && !tc.expectError { - t.Errorf("unexpected error: %v", errs) + t.Errorf("unexpected error: %v in test case %v", errs, tc.description) } if len(errs) == 0 && tc.expectError { - t.Errorf("expect error") + t.Errorf("expect error in test case %v", tc.description) } - if len(errs) != 0 && !strings.Contains(errs[0].Error(), "is disallowed from being an owner") { - t.Errorf("unexpected error message: %v", errs) + if len(errs) != 0 && !strings.Contains(errs[0].Error(), tc.expectedErrorMessage) { + t.Errorf("unexpected error message: %v in test case %v", errs, tc.description) } } }