Skip to content

Commit

Permalink
fix: panic when remove mutli pools (#2215)
Browse files Browse the repository at this point in the history
* fix: panic when remove mutli pools

fix: panic when remove mutli pools

* apply suggestion

apply suggestion

---------

Co-authored-by: jiuker <[email protected]>
  • Loading branch information
jiuker and jiuker authored Jul 16, 2024
1 parent 7f95174 commit ccbdd2c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/controller/decomission.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,25 @@ func (c *Controller) checkForPoolDecommission(ctx context.Context, key string, t
// This means we are attempting to remove a "pool", perhaps after a decommission event.
var poolNamesRemoved []string
var initializedPool miniov2.Pool
for i, pstatus := range tenant.Status.Pools {
var poolStatus []miniov2.PoolStatus
for _, pstatus := range tenant.Status.Pools {
var found bool
for _, pool := range tenant.Spec.Pools {
if pstatus.SSName == tenant.PoolStatefulsetName(&pool) {
found = true
if pstatus.State == miniov2.PoolInitialized {
initializedPool = pool
}
continue
break
}
}
if !found {
poolNamesRemoved = append(poolNamesRemoved, pstatus.SSName)
tenant.Status.Pools = append(tenant.Status.Pools[:i], tenant.Status.Pools[i+1:]...)
} else {
poolStatus = append(poolStatus, *pstatus.DeepCopy())
}
}
tenant.Status.Pools = poolStatus

var restarted bool
// Only restart if there is an initialized pool to fetch the new args.
Expand Down

0 comments on commit ccbdd2c

Please sign in to comment.