Skip to content

Commit

Permalink
optimize compareImage into one loop (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuker authored May 24, 2022
1 parent db03f01 commit 25a965b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/controller/cluster/main-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,15 +938,17 @@ func (c *Controller) syncHandler(key string) error {
}

// compare all the images across all pools, they should always be the same.
for _, image := range images {
for i := 0; i < len(images); i++ {
if image != images[i] {
if _, err = c.updateTenantStatus(ctx, tenant, StatusInconsistentMinIOVersions, totalReplicas); err != nil {
return err
}
return fmt.Errorf("Pool %d is running incorrect image version, all pools are required to be on the same MinIO version. Attempting update of the inconsistent pool",
i+1)
compareImage := ""
for i, image := range images {
if compareImage == "" {
compareImage = image
}
if compareImage != image {
if _, err = c.updateTenantStatus(ctx, tenant, StatusInconsistentMinIOVersions, totalReplicas); err != nil {
return err
}
return fmt.Errorf("Pool %d is running incorrect image version, all pools are required to be on the same MinIO version. Attempting update of the inconsistent pool",
i+1)
}
}

Expand Down

0 comments on commit 25a965b

Please sign in to comment.