From 2098cc26398f2cbd7dce94a4f359c0595894a2db Mon Sep 17 00:00:00 2001 From: Di Xu Date: Wed, 26 Jul 2017 10:53:45 +0800 Subject: [PATCH] change the StatefulSet observedGeneration from a pointer to an int for consistency --- pkg/api/testing/fuzzer.go | 3 +++ pkg/apis/apps/v1beta2/conversion.go | 27 ++++++++++++++++++++ staging/src/k8s.io/api/apps/v1beta2/types.go | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index 305131b3a5..8ec590deb9 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -731,6 +731,9 @@ func appsFuncs(codecs runtimeserializer.CodecFactory) []interface{} { s.Spec.RevisionHistoryLimit = new(int32) *s.Spec.RevisionHistoryLimit = 10 } + if s.Status.ObservedGeneration == nil { + s.Status.ObservedGeneration = new(int64) + } }, } } diff --git a/pkg/apis/apps/v1beta2/conversion.go b/pkg/apis/apps/v1beta2/conversion.go index 44bfc75110..7fc32b3ccb 100644 --- a/pkg/apis/apps/v1beta2/conversion.go +++ b/pkg/apis/apps/v1beta2/conversion.go @@ -43,6 +43,8 @@ func addConversionFuncs(scheme *runtime.Scheme) error { Convert_apps_StatefulSetUpdateStrategy_To_v1beta2_StatefulSetUpdateStrategy, Convert_extensions_RollingUpdateDaemonSet_To_v1beta2_RollingUpdateDaemonSet, Convert_v1beta2_RollingUpdateDaemonSet_To_extensions_RollingUpdateDaemonSet, + Convert_v1beta2_StatefulSetStatus_To_apps_StatefulSetStatus, + Convert_apps_StatefulSetStatus_To_v1beta2_StatefulSetStatus, // extensions // TODO: below conversions should be dropped in favor of auto-generated // ones, see https://github.com/kubernetes/kubernetes/issues/39865 @@ -223,6 +225,31 @@ func Convert_apps_StatefulSetUpdateStrategy_To_v1beta2_StatefulSetUpdateStrategy return nil } +func Convert_v1beta2_StatefulSetStatus_To_apps_StatefulSetStatus(in *appsv1beta2.StatefulSetStatus, out *apps.StatefulSetStatus, s conversion.Scope) error { + out.ObservedGeneration = new(int64) + *out.ObservedGeneration = in.ObservedGeneration + out.Replicas = in.Replicas + out.ReadyReplicas = in.ReadyReplicas + out.CurrentReplicas = in.CurrentReplicas + out.UpdatedReplicas = in.UpdatedReplicas + out.CurrentRevision = in.CurrentRevision + out.UpdateRevision = in.UpdateRevision + return nil +} + +func Convert_apps_StatefulSetStatus_To_v1beta2_StatefulSetStatus(in *apps.StatefulSetStatus, out *appsv1beta2.StatefulSetStatus, s conversion.Scope) error { + if in.ObservedGeneration != nil { + out.ObservedGeneration = *in.ObservedGeneration + } + out.Replicas = in.Replicas + out.ReadyReplicas = in.ReadyReplicas + out.CurrentReplicas = in.CurrentReplicas + out.UpdatedReplicas = in.UpdatedReplicas + out.CurrentRevision = in.CurrentRevision + out.UpdateRevision = in.UpdateRevision + return nil +} + func Convert_extensions_ScaleStatus_To_v1beta2_ScaleStatus(in *extensions.ScaleStatus, out *appsv1beta2.ScaleStatus, s conversion.Scope) error { out.Replicas = int32(in.Replicas) diff --git a/staging/src/k8s.io/api/apps/v1beta2/types.go b/staging/src/k8s.io/api/apps/v1beta2/types.go index 417f996cb6..6bc333f4ef 100644 --- a/staging/src/k8s.io/api/apps/v1beta2/types.go +++ b/staging/src/k8s.io/api/apps/v1beta2/types.go @@ -225,7 +225,7 @@ type StatefulSetStatus struct { // observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the // StatefulSet's generation, which is updated on mutation by the API Server. // +optional - ObservedGeneration *int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` + ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` // replicas is the number of Pods created by the StatefulSet controller. Replicas int32 `json:"replicas" protobuf:"varint,2,opt,name=replicas"`