@@ -60,25 +60,27 @@ type RollingUpdaterConfig struct {
6060 // CleanupPolicy defines the cleanup action to take after the deployment is
6161 // complete.
6262 CleanupPolicy RollingUpdaterCleanupPolicy
63- // The maximum number of pods that can be unavailable during the update.
64- // Value can be an absolute number (ex: 5) or a percentage of total pods at
65- // the start of update (ex: 10%). Absolute number is calculated from
66- // percentage by rounding up. This can not be 0 if MaxSurge is 0. By
67- // default, a fixed value of 1 is used. Example: when this is set to 30%,
68- // the old RC can be scaled down by 30% immediately when the rolling update
69- // starts. Once new pods are ready, old RC can be scaled down further,
70- // followed by scaling up the new RC, ensuring that at least 70% of original
71- // number of pods are available at all times during the update.
63+ // MaxUnavailable is the maximum number of pods that can be unavailable during the update.
64+ // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
65+ // Absolute number is calculated from percentage by rounding up.
66+ // This can not be 0 if MaxSurge is 0.
67+ // By default, a fixed value of 1 is used.
68+ // Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods
69+ // immediately when the rolling update starts. Once new pods are ready, old RC
70+ // can be scaled down further, followed by scaling up the new RC, ensuring
71+ // that the total number of pods available at all times during the update is at
72+ // least 70% of desired pods.
7273 MaxUnavailable util.IntOrString
73- // The maximum number of pods that can be scheduled above the original
74- // number of pods. Value can be an absolute number (ex: 5) or a percentage of total
75- // pods at the start of the update (ex: 10%). This can not be 0 if
76- // MaxUnavailable is 0. Absolute number is calculated from percentage by
77- // rounding up. By default, a value of 1 is used. Example: when this is set
78- // to 30%, the new RC can be scaled up by 30% immediately when the rolling
79- // update starts. Once old pods have been killed, new RC can be scaled up
74+ // MaxSurge is the maximum number of pods that can be scheduled above the desired number of pods.
75+ // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
76+ // This can not be 0 if MaxUnavailable is 0.
77+ // Absolute number is calculated from percentage by rounding up.
78+ // By default, a value of 1 is used.
79+ // Example: when this is set to 30%, the new RC can be scaled up immediately
80+ // when the rolling update starts, such that the total number of old and new pods do not exceed
81+ // 130% of desired pods. Once old pods have been killed, new RC can be scaled up
8082 // further, ensuring that total number of pods running at any time during
81- // the update is atmost 130% of original pods.
83+ // the update is atmost 130% of desired pods.
8284 MaxSurge util.IntOrString
8385}
8486
@@ -197,12 +199,12 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
197199 oldRc .Name , originalReplicasAnnotation , oldRc .Annotations [originalReplicasAnnotation ])
198200 }
199201 // The maximum pods which can go unavailable during the update.
200- maxUnavailable , err := extractMaxValue (config .MaxUnavailable , "maxUnavailable" , original )
202+ maxUnavailable , err := extractMaxValue (config .MaxUnavailable , "maxUnavailable" , desired )
201203 if err != nil {
202204 return err
203205 }
204206 // The maximum scaling increment.
205- maxSurge , err := extractMaxValue (config .MaxSurge , "maxSurge" , original )
207+ maxSurge , err := extractMaxValue (config .MaxSurge , "maxSurge" , desired )
206208 if err != nil {
207209 return err
208210 }
@@ -480,8 +482,8 @@ func (r *RollingUpdater) cleanupWithClients(oldRc, newRc *api.ReplicationControl
480482}
481483
482484// func extractMaxValue is a helper to extract config max values as either
483- // absolute numbers or based on percentages of the original rc .
484- func extractMaxValue (field util.IntOrString , name string , original int ) (int , error ) {
485+ // absolute numbers or based on percentages of the given value .
486+ func extractMaxValue (field util.IntOrString , name string , value int ) (int , error ) {
485487 switch field .Kind {
486488 case util .IntstrInt :
487489 if field .IntVal < 0 {
@@ -497,7 +499,7 @@ func extractMaxValue(field util.IntOrString, name string, original int) (int, er
497499 if v < 0 {
498500 return 0 , fmt .Errorf ("%s must be >= 0" , name )
499501 }
500- return int (math .Ceil (float64 (original ) * (float64 (v )) / 100 )), nil
502+ return int (math .Ceil (float64 (value ) * (float64 (v )) / 100 )), nil
501503 }
502504 return 0 , fmt .Errorf ("invalid kind %q for %s" , field .Kind , name )
503505}
0 commit comments