mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Fix: UpdateStrategy.RollingUpdate.Partition is lost when UpdateStrategy.Type is not set
This commit is contained in:
parent
a38096a069
commit
ff69810f1a
@ -99,8 +99,10 @@ func SetDefaults_StatefulSet(obj *appsv1.StatefulSet) {
|
|||||||
if obj.Spec.UpdateStrategy.Type == "" {
|
if obj.Spec.UpdateStrategy.Type == "" {
|
||||||
obj.Spec.UpdateStrategy.Type = appsv1.RollingUpdateStatefulSetStrategyType
|
obj.Spec.UpdateStrategy.Type = appsv1.RollingUpdateStatefulSetStrategyType
|
||||||
|
|
||||||
// UpdateStrategy.RollingUpdate will take default values below.
|
if obj.Spec.UpdateStrategy.RollingUpdate == nil {
|
||||||
obj.Spec.UpdateStrategy.RollingUpdate = &appsv1.RollingUpdateStatefulSetStrategy{}
|
// UpdateStrategy.RollingUpdate will take default values below.
|
||||||
|
obj.Spec.UpdateStrategy.RollingUpdate = &appsv1.RollingUpdateStatefulSetStrategy{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if obj.Spec.UpdateStrategy.Type == appsv1.RollingUpdateStatefulSetStrategyType &&
|
if obj.Spec.UpdateStrategy.Type == appsv1.RollingUpdateStatefulSetStrategyType &&
|
||||||
|
@ -173,6 +173,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
|
|||||||
defaultLabels := map[string]string{"foo": "bar"}
|
defaultLabels := map[string]string{"foo": "bar"}
|
||||||
var defaultPartition int32 = 0
|
var defaultPartition int32 = 0
|
||||||
var defaultReplicas int32 = 1
|
var defaultReplicas int32 = 1
|
||||||
|
var notTheDefaultPartition int32 = 42
|
||||||
|
|
||||||
period := int64(v1.DefaultTerminationGracePeriodSeconds)
|
period := int64(v1.DefaultTerminationGracePeriodSeconds)
|
||||||
defaultTemplate := v1.PodTemplateSpec{
|
defaultTemplate := v1.PodTemplateSpec{
|
||||||
@ -265,6 +266,35 @@ func TestSetDefaultStatefulSet(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{ // UpdateStrategy.RollingUpdate.Partition is not lost when UpdateStrategy.Type is not set
|
||||||
|
original: &appsv1.StatefulSet{
|
||||||
|
Spec: appsv1.StatefulSetSpec{
|
||||||
|
Template: defaultTemplate,
|
||||||
|
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
|
||||||
|
RollingUpdate: &appsv1.RollingUpdateStatefulSetStrategy{
|
||||||
|
Partition: ¬TheDefaultPartition,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: &appsv1.StatefulSet{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Labels: defaultLabels,
|
||||||
|
},
|
||||||
|
Spec: appsv1.StatefulSetSpec{
|
||||||
|
Replicas: &defaultReplicas,
|
||||||
|
Template: defaultTemplate,
|
||||||
|
PodManagementPolicy: appsv1.OrderedReadyPodManagement,
|
||||||
|
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
|
||||||
|
Type: appsv1.RollingUpdateStatefulSetStrategyType,
|
||||||
|
RollingUpdate: &appsv1.RollingUpdateStatefulSetStrategy{
|
||||||
|
Partition: ¬TheDefaultPartition,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user