Skip to content

Commit

Permalink
fix data racing
Browse files Browse the repository at this point in the history
Signed-off-by: AiRanthem <[email protected]>
  • Loading branch information
AiRanthem committed Sep 23, 2024
1 parent b6956e1 commit b37c453
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/controller/uniteddeployment/uniteddeployment_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func (r *ReconcileUnitedDeployment) manageSubsets(ud *appsv1alpha1.UnitedDeploym
}
}

var newPodCreated = false
if len(needUpdate) > 0 {
_, updateErr = util.SlowStartBatch(len(needUpdate), slowStartInitialBatchSize, func(index int) error {
cell := needUpdate[index]
Expand All @@ -74,7 +73,6 @@ func (r *ReconcileUnitedDeployment) manageSubsets(ud *appsv1alpha1.UnitedDeploym
if updateSubsetErr != nil {
r.recorder.Event(ud.DeepCopy(), corev1.EventTypeWarning, fmt.Sprintf("Failed%s", eventTypeSubsetsUpdate), fmt.Sprintf("Error updating PodSet (%s) %s when updating: %s", subsetType, subset.Name, updateSubsetErr))
}
newPodCreated = newPodCreated || subset.Spec.Replicas < replicas
return updateSubsetErr
})
}
Expand All @@ -84,6 +82,12 @@ func (r *ReconcileUnitedDeployment) manageSubsets(ud *appsv1alpha1.UnitedDeploym
} else {
// If using an Adaptive scheduling strategy, when the subset is scaled out leading to the creation of new Pods,
// future potential scheduling failures need to be checked for rescheduling.
var newPodCreated = false
for _, cell := range needUpdate {
subset := (*nameToSubset)[cell]
replicas := nextUpdate[cell].Replicas
newPodCreated = newPodCreated || subset.Spec.Replicas < replicas

Check warning on line 89 in pkg/controller/uniteddeployment/uniteddeployment_update.go

View check run for this annotation

Codecov / codecov/patch

pkg/controller/uniteddeployment/uniteddeployment_update.go#L85-L89

Added lines #L85 - L89 were not covered by tests
}
if strategy := ud.Spec.Topology.ScheduleStrategy; strategy.IsAdaptive() && newPodCreated {
durationStore.Push(getUnitedDeploymentKey(ud), strategy.GetRescheduleCriticalDuration())

Check warning on line 92 in pkg/controller/uniteddeployment/uniteddeployment_update.go

View check run for this annotation

Codecov / codecov/patch

pkg/controller/uniteddeployment/uniteddeployment_update.go#L91-L92

Added lines #L91 - L92 were not covered by tests
}
Expand Down

0 comments on commit b37c453

Please sign in to comment.