Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcapet committed Jan 28, 2025
1 parent 990d65a commit ae6e65e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pkg/cluster/majorversionupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,17 @@ func (c *Cluster) removeFailuresAnnotation() error {
return nil
}

func (c *Cluster) criticalOperationLabel(pods []v1.Pod, remove bool) error {
func (c *Cluster) criticalOperationLabel(pods []v1.Pod, active bool) error {
var action string
var metadataReq map[string]map[string]map[string]*string

if remove {
action = "remove"
metadataReq = map[string]map[string]map[string]*string{"metadata": {"labels": {"critical-operaton": nil}}}

} else {
if active {
action = "assign"
val := "true"
metadataReq = map[string]map[string]map[string]*string{"metadata": {"labels": {"critical-operaton": &val}}}
metadataReq = map[string]map[string]map[string]*string{"metadata": {"labels": {"critical-operation": &val}}}
} else {
action = "remove"
metadataReq = map[string]map[string]map[string]*string{"metadata": {"labels": {"critical-operation": nil}}}
}

patchReq, err := json.Marshal(metadataReq)
Expand Down Expand Up @@ -253,12 +252,12 @@ func (c *Cluster) majorVersionUpgrade() error {
c.logger.Infof("healthy cluster ready to upgrade, current: %d desired: %d", c.currentMajorVersion, desiredVersion)
if c.currentMajorVersion < desiredVersion {
defer func() error {
if err = c.criticalOperationLabel(pods, true); err != nil {
if err = c.criticalOperationLabel(pods, false); err != nil {
return fmt.Errorf("failed to remove critical-operation label: %s", err)
}
return nil
}()
if err = c.criticalOperationLabel(pods, false); err != nil {
if err = c.criticalOperationLabel(pods, true); err != nil {
return fmt.Errorf("failed to assign critical-operation label: %s", err)
}

Expand Down

0 comments on commit ae6e65e

Please sign in to comment.