Skip to content

Commit

Permalink
bugfix: set pool status based on name rather than index based (#2161)
Browse files Browse the repository at this point in the history
Fixes #2160

Signed-off-by: pjuarezd <pjuarezd@users.noreply.github.com>
  • Loading branch information
pjuarezd authored Jun 12, 2024
1 parent a016247 commit 0c77cc5
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions pkg/controller/main-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,11 +960,17 @@ func (c *Controller) syncHandler(key string) (Result, error) {
// Get the StatefulSet with the name specified in Tenant.status.pools[i].SSName

// if this index is in the status of pools use it, else capture the desired name in the status and store it
var ssName string
if len(tenant.Status.Pools) > i {
ssName = tenant.Status.Pools[i].SSName
} else {
ssName = tenant.PoolStatefulsetName(&pool)
ssName := tenant.PoolStatefulsetName(&pool)

poolInStatus := false
for _, poolStatus := range tenant.Status.Pools {
if poolStatus.SSName == ssName {
poolInStatus = true
break
}
}

if !poolInStatus {
tenant.Status.Pools = append(tenant.Status.Pools, miniov2.PoolStatus{
SSName: ssName,
State: miniov2.PoolNotCreated,
Expand Down Expand Up @@ -1209,10 +1215,17 @@ func (c *Controller) syncHandler(key string) (Result, error) {
for i, pool := range tenant.Spec.Pools {
// Get the StatefulSet with the name specified in Tenant.status.pools[i].SSName
// if this index is in the status of pools use it, else capture the desired name in the status and store it
var ssName string
if len(tenant.Status.Pools) > i {
ssName = tenant.Status.Pools[i].SSName
} else {
ssName := tenant.PoolStatefulsetName(&pool)

poolInStatus := false
for _, poolStatus := range tenant.Status.Pools {
if poolStatus.SSName == ssName {
poolInStatus = true
break
}
}

if !poolInStatus {
ssName = tenant.PoolStatefulsetName(&pool)
tenant.Status.Pools = append(tenant.Status.Pools, miniov2.PoolStatus{
SSName: ssName,
Expand Down

0 comments on commit 0c77cc5

Please sign in to comment.