Skip to content

Commit 3ad1f17

Browse files
committed
Small refactoring
1 parent 9897c15 commit 3ad1f17

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pkg/cluster/majorversionupgrade.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,13 @@ func (c *Cluster) removeFailuresAnnotation() error {
106106
return nil
107107
}
108108

109-
func (c *Cluster) criticalOperationLabel(pods []v1.Pod, active bool) error {
109+
func (c *Cluster) criticalOperationLabel(pods []v1.Pod, value string) error {
110110
var action string
111111
var metadataReq map[string]map[string]map[string]*string
112112

113-
if active {
113+
if value != "" {
114114
action = "assign"
115-
val := "true"
116-
metadataReq = map[string]map[string]map[string]*string{"metadata": {"labels": {"critical-operation": &val}}}
115+
metadataReq = map[string]map[string]map[string]*string{"metadata": {"labels": {"critical-operation": &value}}}
117116
} else {
118117
action = "remove"
119118
metadataReq = map[string]map[string]map[string]*string{"metadata": {"labels": {"critical-operation": nil}}}
@@ -252,12 +251,12 @@ func (c *Cluster) majorVersionUpgrade() error {
252251
c.logger.Infof("healthy cluster ready to upgrade, current: %d desired: %d", c.currentMajorVersion, desiredVersion)
253252
if c.currentMajorVersion < desiredVersion {
254253
defer func() error {
255-
if err = c.criticalOperationLabel(pods, false); err != nil {
254+
if err = c.criticalOperationLabel(pods, ""); err != nil {
256255
return fmt.Errorf("failed to remove critical-operation label: %s", err)
257256
}
258257
return nil
259258
}()
260-
if err = c.criticalOperationLabel(pods, true); err != nil {
259+
if err = c.criticalOperationLabel(pods, "true"); err != nil {
261260
return fmt.Errorf("failed to assign critical-operation label: %s", err)
262261
}
263262

0 commit comments

Comments
 (0)