[Mics]: modify stormservice scaling logic when diff > 0
Pull Request Description
when diff <= len(notReady), we only need to delete the first diff rolesets which are all not ready.
if diff <= len(notReady) {
toDelete = notReady[:diff]
count, err := r.deleteRoleSet(toDelete)
if err != nil {
return false, err
}
klog.Infof("%s/%s successfully delete %d roleSets", stormService.Namespace, stormService.Name, count)
return false, nil
}
And when diff > len(notReady), we already have diff rolesets to delete and only need to delete diff -= len(notReady) rolesets. The original logic directly calculates expected roleset without diff, so I remove by proportion based on diff count.
expectDeleteCurrentReplica, expectDeleteUpdatedReplica := calculateReplicas(int32(diff), int32(len(currentReady)), int32(len(updatedReady)))
toDelete = append(toDelete, currentReady[:expectDeleteCurrentReplica]...)
toDelete = append(toDelete, updatedReady[:expectDeleteUpdatedReplica]...)
Original logic is not bug, just different calculation methods. Please check if it is necessary to refine, thanks.
It is not a bug, just modify logic to use diff value. The result is the same with now. Confirm if it is necessary.
@jiangxiaobin96 thanks for the change, I will double check the necessity