Commit d72ffcd8 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #49983 from liyinan926/master

Automatic merge from submit-queue Added field CollisionCount to StatefulSetStatus **What this PR does / why we need it**: This PR added a new field `CollisionCount` into `StatefulSetStatus`, similarly in terms of both name and semantics to the existing `CollisionCount` field in `DaemonSetStatus`. The field will be used for collision avoidance when the `StatefulSet` controller creates name for the newest ControllerRevision, which will be done in another PR. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: #49909. **Special notes for your reviewer**: A second PR will include logic that actually uses the field for collision avoidance. **Release note**: ```release-note Added field CollisionCount to StatefulSetStatus in both apps/v1beta1 and apps/v1beta2 ```
parents 87d1de66 7ec391eb
......@@ -53477,6 +53477,11 @@
"replicas"
],
"properties": {
"collisionCount": {
"description": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.",
"type": "integer",
"format": "int64"
},
"currentReplicas": {
"description": "currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.",
"type": "integer",
......@@ -54273,6 +54278,11 @@
"replicas"
],
"properties": {
"collisionCount": {
"description": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.",
"type": "integer",
"format": "int64"
},
"currentReplicas": {
"description": "currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.",
"type": "integer",
......@@ -6279,6 +6279,11 @@
"updateRevision": {
"type": "string",
"description": "updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)"
},
"collisionCount": {
"type": "integer",
"format": "int64",
"description": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision."
}
}
},
......
......@@ -7791,6 +7791,11 @@
"updateRevision": {
"type": "string",
"description": "updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)"
},
"collisionCount": {
"type": "integer",
"format": "int64",
"description": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision."
}
}
},
......
......@@ -5135,6 +5135,13 @@ Examples:<br>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">collisionCount</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int64)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
......
......@@ -1581,6 +1581,13 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">collisionCount</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int64)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
......
......@@ -734,6 +734,9 @@ func appsFuncs(codecs runtimeserializer.CodecFactory) []interface{} {
if s.Status.ObservedGeneration == nil {
s.Status.ObservedGeneration = new(int64)
}
if s.Status.CollisionCount == nil {
s.Status.CollisionCount = new(int64)
}
},
}
}
......
......@@ -187,6 +187,12 @@ type StatefulSetStatus struct {
// updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence
// [replicas-updatedReplicas,replicas)
UpdateRevision string
// collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller
// uses this field as a collision avoidance mechanism when it needs to create the name for the
// newest ControllerRevision.
// +optional
CollisionCount *int64
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
......
......@@ -625,6 +625,7 @@ func autoConvert_v1beta1_StatefulSetStatus_To_apps_StatefulSetStatus(in *v1beta1
out.UpdatedReplicas = in.UpdatedReplicas
out.CurrentRevision = in.CurrentRevision
out.UpdateRevision = in.UpdateRevision
out.CollisionCount = (*int64)(unsafe.Pointer(in.CollisionCount))
return nil
}
......@@ -641,6 +642,7 @@ func autoConvert_apps_StatefulSetStatus_To_v1beta1_StatefulSetStatus(in *apps.St
out.UpdatedReplicas = in.UpdatedReplicas
out.CurrentRevision = in.CurrentRevision
out.UpdateRevision = in.UpdateRevision
out.CollisionCount = (*int64)(unsafe.Pointer(in.CollisionCount))
return nil
}
......
......@@ -237,6 +237,10 @@ func Convert_v1beta2_StatefulSetStatus_To_apps_StatefulSetStatus(in *appsv1beta2
out.UpdatedReplicas = in.UpdatedReplicas
out.CurrentRevision = in.CurrentRevision
out.UpdateRevision = in.UpdateRevision
if in.CollisionCount != nil {
out.CollisionCount = new(int64)
*out.CollisionCount = *in.CollisionCount
}
return nil
}
......@@ -250,6 +254,10 @@ func Convert_apps_StatefulSetStatus_To_v1beta2_StatefulSetStatus(in *apps.Statef
out.UpdatedReplicas = in.UpdatedReplicas
out.CurrentRevision = in.CurrentRevision
out.UpdateRevision = in.UpdateRevision
if in.CollisionCount != nil {
out.CollisionCount = new(int64)
*out.CollisionCount = *in.CollisionCount
}
return nil
}
......
......@@ -862,6 +862,7 @@ func autoConvert_v1beta2_StatefulSetStatus_To_apps_StatefulSetStatus(in *v1beta2
out.UpdatedReplicas = in.UpdatedReplicas
out.CurrentRevision = in.CurrentRevision
out.UpdateRevision = in.UpdateRevision
out.CollisionCount = (*int64)(unsafe.Pointer(in.CollisionCount))
return nil
}
......@@ -873,6 +874,7 @@ func autoConvert_apps_StatefulSetStatus_To_v1beta2_StatefulSetStatus(in *apps.St
out.UpdatedReplicas = in.UpdatedReplicas
out.CurrentRevision = in.CurrentRevision
out.UpdateRevision = in.UpdateRevision
out.CollisionCount = (*int64)(unsafe.Pointer(in.CollisionCount))
return nil
}
......
......@@ -33,6 +33,7 @@ go_test(
"//pkg/apis/apps:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
],
)
......
......@@ -163,9 +163,39 @@ func ValidateStatefulSetUpdate(statefulSet, oldStatefulSet *apps.StatefulSet) fi
return allErrs
}
// ValidateStatefulSetStatus validates a StatefulSetStatus.
func ValidateStatefulSetStatus(status *apps.StatefulSetStatus, fieldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.Replicas), fieldPath.Child("replicas"))...)
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.ReadyReplicas), fieldPath.Child("readyReplicas"))...)
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.CurrentReplicas), fieldPath.Child("currentReplicas"))...)
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.UpdatedReplicas), fieldPath.Child("updatedReplicas"))...)
if status.ObservedGeneration != nil {
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(*status.ObservedGeneration), fieldPath.Child("observedGeneration"))...)
}
if status.CollisionCount != nil {
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(*status.CollisionCount), fieldPath.Child("collisionCount"))...)
}
msg := "cannot be greater than status.replicas"
if status.ReadyReplicas > status.Replicas {
allErrs = append(allErrs, field.Invalid(fieldPath.Child("readyReplicas"), status.ReadyReplicas, msg))
}
if status.CurrentReplicas > status.Replicas {
allErrs = append(allErrs, field.Invalid(fieldPath.Child("currentReplicas"), status.CurrentReplicas, msg))
}
if status.UpdatedReplicas > status.Replicas {
allErrs = append(allErrs, field.Invalid(fieldPath.Child("updatedReplicas"), status.UpdatedReplicas, msg))
}
return allErrs
}
// ValidateStatefulSetStatusUpdate tests if required fields in the StatefulSet are set.
func ValidateStatefulSetStatusUpdate(statefulSet, oldStatefulSet *apps.StatefulSet) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, ValidateStatefulSetStatus(&statefulSet.Status, field.NewPath("status"))...)
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&statefulSet.ObjectMeta, &oldStatefulSet.ObjectMeta, field.NewPath("metadata"))...)
// TODO: Validate status.
return allErrs
......
......@@ -22,6 +22,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/apps"
)
......@@ -300,6 +301,119 @@ func TestValidateStatefulSet(t *testing.T) {
}
}
func TestValidateStatefulSetStatus(t *testing.T) {
minusOne := int64(-1)
tests := []struct {
name string
replicas int32
readyReplicas int32
currentReplicas int32
updatedReplicas int32
observedGeneration *int64
collisionCount *int64
expectedErr bool
}{
{
name: "valid status",
replicas: 3,
readyReplicas: 3,
currentReplicas: 2,
updatedReplicas: 1,
expectedErr: false,
},
{
name: "invalid replicas",
replicas: -1,
readyReplicas: 3,
currentReplicas: 2,
updatedReplicas: 1,
expectedErr: true,
},
{
name: "invalid readyReplicas",
replicas: 3,
readyReplicas: -1,
currentReplicas: 2,
updatedReplicas: 1,
expectedErr: true,
},
{
name: "invalid currentReplicas",
replicas: 3,
readyReplicas: 3,
currentReplicas: -1,
updatedReplicas: 1,
expectedErr: true,
},
{
name: "invalid updatedReplicas",
replicas: 3,
readyReplicas: 3,
currentReplicas: 2,
updatedReplicas: -1,
expectedErr: true,
},
{
name: "invalid observedGeneration",
replicas: 3,
readyReplicas: 3,
currentReplicas: 2,
updatedReplicas: 1,
observedGeneration: &minusOne,
expectedErr: true,
},
{
name: "invalid collisionCount",
replicas: 3,
readyReplicas: 3,
currentReplicas: 2,
updatedReplicas: 1,
collisionCount: &minusOne,
expectedErr: true,
},
{
name: "readyReplicas greater than replicas",
replicas: 3,
readyReplicas: 4,
currentReplicas: 2,
updatedReplicas: 1,
expectedErr: true,
},
{
name: "currentReplicas greater than replicas",
replicas: 3,
readyReplicas: 3,
currentReplicas: 4,
updatedReplicas: 1,
expectedErr: true,
},
{
name: "updatedReplicas greater than replicas",
replicas: 3,
readyReplicas: 3,
currentReplicas: 2,
updatedReplicas: 4,
expectedErr: true,
},
}
for _, test := range tests {
status := apps.StatefulSetStatus{
Replicas: test.replicas,
ReadyReplicas: test.readyReplicas,
CurrentReplicas: test.currentReplicas,
UpdatedReplicas: test.updatedReplicas,
ObservedGeneration: test.observedGeneration,
CollisionCount: test.collisionCount,
}
errs := ValidateStatefulSetStatus(&status, field.NewPath("status"))
if hasErr := len(errs) > 0; hasErr != test.expectedErr {
t.Errorf("%s: expected error: %t, got error: %t\nerrors: %s", test.name, test.expectedErr, hasErr, errs.ToAggregate().Error())
}
}
}
func TestValidateStatefulSetUpdate(t *testing.T) {
validLabels := map[string]string{"a": "b"}
validPodTemplate := api.PodTemplate{
......
......@@ -273,6 +273,15 @@ func (in *StatefulSetStatus) DeepCopyInto(out *StatefulSetStatus) {
**out = **in
}
}
if in.CollisionCount != nil {
in, out := &in.CollisionCount, &out.CollisionCount
if *in == nil {
*out = nil
} else {
*out = new(int64)
**out = **in
}
}
return
}
......
......@@ -429,6 +429,12 @@ message StatefulSetStatus {
// updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence
// [replicas-updatedReplicas,replicas)
optional string updateRevision = 7;
// collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller
// uses this field as a collision avoidance mechanism when it needs to create the name for the
// newest ControllerRevision.
// +optional
optional int64 collisionCount = 9;
}
// StatefulSetUpdateStrategy indicates the strategy that the StatefulSet
......
......@@ -2419,7 +2419,7 @@ func (x *StatefulSetStatus) CodecEncodeSelf(e *codec1978.Encoder) {
} else {
yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [7]bool
var yyq2 [8]bool
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[0] = x.ObservedGeneration != nil
......@@ -2428,9 +2428,10 @@ func (x *StatefulSetStatus) CodecEncodeSelf(e *codec1978.Encoder) {
yyq2[4] = x.UpdatedReplicas != 0
yyq2[5] = x.CurrentRevision != ""
yyq2[6] = x.UpdateRevision != ""
yyq2[7] = x.CollisionCount != nil
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(7)
r.EncodeArrayStart(8)
} else {
yynn2 = 1
for _, b := range yyq2 {
......@@ -2621,6 +2622,41 @@ func (x *StatefulSetStatus) CodecEncodeSelf(e *codec1978.Encoder) {
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[7] {
if x.CollisionCount == nil {
r.EncodeNil()
} else {
yy27 := *x.CollisionCount
yym28 := z.EncBinary()
_ = yym28
if false {
} else {
r.EncodeInt(int64(yy27))
}
}
} else {
r.EncodeNil()
}
} else {
if yyq2[7] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("collisionCount"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.CollisionCount == nil {
r.EncodeNil()
} else {
yy29 := *x.CollisionCount
yym30 := z.EncBinary()
_ = yym30
if false {
} else {
r.EncodeInt(int64(yy29))
}
}
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
} else {
z.EncSendContainerState(codecSelfer_containerMapEnd1234)
......@@ -2769,6 +2805,22 @@ func (x *StatefulSetStatus) codecDecodeSelfFromMap(l int, d *codec1978.Decoder)
*((*string)(yyv16)) = r.DecodeString()
}
}
case "collisionCount":
if r.TryDecodeAsNil() {
if x.CollisionCount != nil {
x.CollisionCount = nil
}
} else {
if x.CollisionCount == nil {
x.CollisionCount = new(int64)
}
yym19 := z.DecBinary()
_ = yym19
if false {
} else {
*((*int64)(x.CollisionCount)) = int64(r.DecodeInt(64))
}
}
default:
z.DecStructFieldNotFound(-1, yys3)
} // end switch yys3
......@@ -2780,16 +2832,16 @@ func (x *StatefulSetStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
var yyj18 int
var yyb18 bool
var yyhl18 bool = l >= 0
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
var yyj20 int
var yyb20 bool
var yyhl20 bool = l >= 0
yyj20++
if yyhl20 {
yyb20 = yyj20 > l
} else {
yyb18 = r.CheckBreak()
yyb20 = r.CheckBreak()
}
if yyb18 {
if yyb20 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
......@@ -2802,20 +2854,20 @@ func (x *StatefulSetStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder
if x.ObservedGeneration == nil {
x.ObservedGeneration = new(int64)
}
yym20 := z.DecBinary()
_ = yym20
yym22 := z.DecBinary()
_ = yym22
if false {
} else {
*((*int64)(x.ObservedGeneration)) = int64(r.DecodeInt(64))
}
}
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
yyj20++
if yyhl20 {
yyb20 = yyj20 > l
} else {
yyb18 = r.CheckBreak()
yyb20 = r.CheckBreak()
}
if yyb18 {
if yyb20 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
......@@ -2823,21 +2875,21 @@ func (x *StatefulSetStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder
if r.TryDecodeAsNil() {
x.Replicas = 0
} else {
yyv21 := &x.Replicas
yym22 := z.DecBinary()
_ = yym22
yyv23 := &x.Replicas
yym24 := z.DecBinary()
_ = yym24
if false {
} else {
*((*int32)(yyv21)) = int32(r.DecodeInt(32))
*((*int32)(yyv23)) = int32(r.DecodeInt(32))
}
}
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
yyj20++
if yyhl20 {
yyb20 = yyj20 > l
} else {
yyb18 = r.CheckBreak()
yyb20 = r.CheckBreak()
}
if yyb18 {
if yyb20 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
......@@ -2845,21 +2897,21 @@ func (x *StatefulSetStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder
if r.TryDecodeAsNil() {
x.ReadyReplicas = 0
} else {
yyv23 := &x.ReadyReplicas
yym24 := z.DecBinary()
_ = yym24
yyv25 := &x.ReadyReplicas
yym26 := z.DecBinary()
_ = yym26
if false {
} else {
*((*int32)(yyv23)) = int32(r.DecodeInt(32))
*((*int32)(yyv25)) = int32(r.DecodeInt(32))
}
}
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
yyj20++
if yyhl20 {
yyb20 = yyj20 > l
} else {
yyb18 = r.CheckBreak()
yyb20 = r.CheckBreak()
}
if yyb18 {
if yyb20 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
......@@ -2867,21 +2919,21 @@ func (x *StatefulSetStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder
if r.TryDecodeAsNil() {
x.CurrentReplicas = 0
} else {
yyv25 := &x.CurrentReplicas
yym26 := z.DecBinary()
_ = yym26
yyv27 := &x.CurrentReplicas
yym28 := z.DecBinary()
_ = yym28
if false {
} else {
*((*int32)(yyv25)) = int32(r.DecodeInt(32))
*((*int32)(yyv27)) = int32(r.DecodeInt(32))
}
}
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
yyj20++
if yyhl20 {
yyb20 = yyj20 > l
} else {
yyb18 = r.CheckBreak()
yyb20 = r.CheckBreak()
}
if yyb18 {
if yyb20 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
......@@ -2889,21 +2941,21 @@ func (x *StatefulSetStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder
if r.TryDecodeAsNil() {
x.UpdatedReplicas = 0
} else {
yyv27 := &x.UpdatedReplicas
yym28 := z.DecBinary()
_ = yym28
yyv29 := &x.UpdatedReplicas
yym30 := z.DecBinary()
_ = yym30
if false {
} else {
*((*int32)(yyv27)) = int32(r.DecodeInt(32))
*((*int32)(yyv29)) = int32(r.DecodeInt(32))
}
}
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
yyj20++
if yyhl20 {
yyb20 = yyj20 > l
} else {
yyb18 = r.CheckBreak()
yyb20 = r.CheckBreak()
}
if yyb18 {
if yyb20 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
......@@ -2911,21 +2963,21 @@ func (x *StatefulSetStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder
if r.TryDecodeAsNil() {
x.CurrentRevision = ""
} else {
yyv29 := &x.CurrentRevision
yym30 := z.DecBinary()
_ = yym30
yyv31 := &x.CurrentRevision
yym32 := z.DecBinary()
_ = yym32
if false {
} else {
*((*string)(yyv29)) = r.DecodeString()
*((*string)(yyv31)) = r.DecodeString()
}
}
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
yyj20++
if yyhl20 {
yyb20 = yyj20 > l
} else {
yyb18 = r.CheckBreak()
yyb20 = r.CheckBreak()
}
if yyb18 {
if yyb20 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
......@@ -2933,26 +2985,52 @@ func (x *StatefulSetStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder
if r.TryDecodeAsNil() {
x.UpdateRevision = ""
} else {
yyv31 := &x.UpdateRevision
yym32 := z.DecBinary()
_ = yym32
yyv33 := &x.UpdateRevision
yym34 := z.DecBinary()
_ = yym34
if false {
} else {
*((*string)(yyv31)) = r.DecodeString()
*((*string)(yyv33)) = r.DecodeString()
}
}
yyj20++
if yyhl20 {
yyb20 = yyj20 > l
} else {
yyb20 = r.CheckBreak()
}
if yyb20 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
if x.CollisionCount != nil {
x.CollisionCount = nil
}
} else {
if x.CollisionCount == nil {
x.CollisionCount = new(int64)
}
yym36 := z.DecBinary()
_ = yym36
if false {
} else {
*((*int64)(x.CollisionCount)) = int64(r.DecodeInt(64))
}
}
for {
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
yyj20++
if yyhl20 {
yyb20 = yyj20 > l
} else {
yyb18 = r.CheckBreak()
yyb20 = r.CheckBreak()
}
if yyb18 {
if yyb20 {
break
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj18-1, "")
z.DecStructFieldNotFound(yyj20-1, "")
}
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
}
......@@ -7976,7 +8054,7 @@ func (x codecSelfer1234) decSliceStatefulSet(v *[]StatefulSet, d *codec1978.Deco
yyrg1 := len(yyv1) > 0
yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1008)
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1016)
if yyrt1 {
if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1]
......
......@@ -239,6 +239,12 @@ type StatefulSetStatus struct {
// updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence
// [replicas-updatedReplicas,replicas)
UpdateRevision string `json:"updateRevision,omitempty" protobuf:"bytes,7,opt,name=updateRevision"`
// collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller
// uses this field as a collision avoidance mechanism when it needs to create the name for the
// newest ControllerRevision.
// +optional
CollisionCount *int64 `json:"collisionCount,omitempty" protobuf:"varint,9,opt,name=collisionCount"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
......
......@@ -239,6 +239,7 @@ var map_StatefulSetStatus = map[string]string{
"updatedReplicas": "updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.",
"currentRevision": "currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).",
"updateRevision": "updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)",
"collisionCount": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.",
}
func (StatefulSetStatus) SwaggerDoc() map[string]string {
......
......@@ -689,6 +689,15 @@ func (in *StatefulSetStatus) DeepCopyInto(out *StatefulSetStatus) {
**out = **in
}
}
if in.CollisionCount != nil {
in, out := &in.CollisionCount, &out.CollisionCount
if *in == nil {
*out = nil
} else {
*out = new(int64)
**out = **in
}
}
return
}
......
......@@ -666,6 +666,12 @@ message StatefulSetStatus {
// updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence
// [replicas-updatedReplicas,replicas)
optional string updateRevision = 7;
// collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller
// uses this field as a collision avoidance mechanism when it needs to create the name for the
// newest ControllerRevision.
// +optional
optional int64 collisionCount = 9;
}
// WIP: This is not ready to be used and we plan to make breaking changes to it.
......
......@@ -252,6 +252,12 @@ type StatefulSetStatus struct {
// updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence
// [replicas-updatedReplicas,replicas)
UpdateRevision string `json:"updateRevision,omitempty" protobuf:"bytes,7,opt,name=updateRevision"`
// collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller
// uses this field as a collision avoidance mechanism when it needs to create the name for the
// newest ControllerRevision.
// +optional
CollisionCount *int64 `json:"collisionCount,omitempty" protobuf:"varint,9,opt,name=collisionCount"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
......
......@@ -328,6 +328,7 @@ var map_StatefulSetStatus = map[string]string{
"updatedReplicas": "updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.",
"currentRevision": "currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).",
"updateRevision": "updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)",
"collisionCount": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.",
}
func (StatefulSetStatus) SwaggerDoc() map[string]string {
......
......@@ -787,7 +787,7 @@ func (in *StatefulSet) DeepCopyInto(out *StatefulSet) {
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
in.Status.DeepCopyInto(&out.Status)
return
}
......@@ -899,6 +899,15 @@ func (in *StatefulSetSpec) DeepCopy() *StatefulSetSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StatefulSetStatus) DeepCopyInto(out *StatefulSetStatus) {
*out = *in
if in.CollisionCount != nil {
in, out := &in.CollisionCount, &out.CollisionCount
if *in == nil {
*out = nil
} else {
*out = new(int64)
**out = **in
}
}
return
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment