Skip to content

Commit

Permalink
when sacle in replace new pod, we should scale in origin pod first
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdsteelRail committed Dec 16, 2024
1 parent 70ed38b commit 2431588
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: kusionstack/kuperator
newName: coldsteelrail/kusion-kuperator
newTag: test
5 changes: 4 additions & 1 deletion pkg/controllers/collaset/synccontrol/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,11 @@ func classifyPodReplacingMapping(podWrappers []*collasetutils.PodWrapper) map[st
if replacePairNewIdStr, exist := podWrapper.Labels[appsv1alpha1.PodReplacePairNewId]; exist {
if pairNewPod, exist := podIdMap[replacePairNewIdStr]; exist {
replacePodMapping[name] = pairNewPod
// if one of pair pods is to Exclude, both pods should not scaleIn
// if one of pair pods is to Exclude, both pods should not scaleIn until
// exclude finished, this is because scale in should be exclusive to ex/include
podWrapper.ToExclude = podWrapper.ToExclude || pairNewPod.ToExclude
// if new pod is selective scaleIn, origin pod should be scaled first and then scaleIn newPod
podWrapper.ToDelete = podWrapper.ToDelete || pairNewPod.ToDelete
continue
}
} else if replaceOriginStr, exist := podWrapper.Labels[appsv1alpha1.PodReplacePairOriginName]; exist {
Expand Down
6 changes: 1 addition & 5 deletions pkg/controllers/collaset/synccontrol/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,12 @@ func getPodsToDelete(filteredPods []*collasetutils.PodWrapper, replaceMapping ma
var needDeletePods []*collasetutils.PodWrapper
// 2. select pods to delete in second round according to replace, delete, exclude
for _, pod := range targetsPods[:diff] {
// don't scaleIn exclude pod and its newPod (if exist)
// scaleIn is exclusive to exclude, just ignore
if pod.ToExclude {
continue
}

if replacePairPod, exist := replaceMapping[pod.Name]; exist && replacePairPod != nil {
// don't selective scaleIn newPod (and its originPod) until replace finished
if replacePairPod.ToDelete {
continue
}
// when scaleIn origin Pod, newPod should be deleted if not service available
if _, serviceAvailable := replacePairPod.Labels[appsv1alpha1.PodServiceAvailableLabel]; !serviceAvailable {
needDeletePods = append(needDeletePods, replacePairPod)
Expand Down

0 comments on commit 2431588

Please sign in to comment.