aibrix icon indicating copy to clipboard operation
aibrix copied to clipboard

[Mics]: modify stormservice scaling logic when diff > 0

Open jiangxiaobin96 opened this issue 3 months ago • 2 comments

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.

jiangxiaobin96 avatar Sep 07 '25 14:09 jiangxiaobin96

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 avatar Sep 08 '25 15:09 jiangxiaobin96

@jiangxiaobin96 thanks for the change, I will double check the necessity

Jeffwan avatar Sep 18 '25 17:09 Jeffwan