Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: schedule policy of restore pod is incorrect #8646

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions pkg/controller/plan/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"github.com/apecloud/kubeblocks/pkg/controller/component"
"github.com/apecloud/kubeblocks/pkg/controller/factory"
"github.com/apecloud/kubeblocks/pkg/controller/instanceset"
"github.com/apecloud/kubeblocks/pkg/controller/scheduling"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
dputils "github.com/apecloud/kubeblocks/pkg/dataprotection/utils"
)
Expand Down Expand Up @@ -197,10 +196,6 @@ func (r *RestoreManager) BuildPrepareDataRestore(comp *component.SynthesizedComp
if len(templates) == 0 {
return nil, nil
}
schedulingSpec, err := r.buildSchedulingSpec(comp)
if err != nil {
return nil, err
}
sourceTargetName := comp.Annotations[constant.BackupSourceTargetAnnotationKey]
sourceTarget := dputils.GetBackupStatusTarget(backupObj, sourceTargetName)
restore := &dpv1alpha1.Restore{
Expand All @@ -216,7 +211,7 @@ func (r *RestoreManager) BuildPrepareDataRestore(comp *component.SynthesizedComp
Parameters: r.parameters,
PrepareDataConfig: &dpv1alpha1.PrepareDataConfig{
RequiredPolicyForAllPodSelection: r.buildRequiredPolicy(sourceTarget),
SchedulingSpec: schedulingSpec,
SchedulingSpec: r.buildSchedulingSpec(comp),
VolumeClaimRestorePolicy: r.volumeRestorePolicy,
RestoreVolumeClaimsTemplate: &dpv1alpha1.RestoreVolumeClaimsTemplate{
Replicas: r.replicas,
Expand Down Expand Up @@ -292,23 +287,15 @@ func (r *RestoreManager) buildRequiredPolicy(sourceTarget *dpv1alpha1.BackupStat
return requiredPolicy
}

func (r *RestoreManager) buildSchedulingSpec(comp *component.SynthesizedComponent) (dpv1alpha1.SchedulingSpec, error) {
shardingName := comp.Labels[constant.KBAppShardingNameLabelKey]
var compSpec *appsv1.ClusterComponentSpec
if shardingName != "" {
compSpec = &r.Cluster.Spec.GetShardingByName(shardingName).Template
} else {
compSpec = r.Cluster.Spec.GetComponentByName(comp.Name)
}
schedulingPolicy, err := scheduling.BuildSchedulingPolicy(r.Cluster, compSpec)
if err != nil || schedulingPolicy == nil {
return dpv1alpha1.SchedulingSpec{}, err
func (r *RestoreManager) buildSchedulingSpec(comp *component.SynthesizedComponent) dpv1alpha1.SchedulingSpec {
if comp.PodSpec == nil {
return dpv1alpha1.SchedulingSpec{}
}
return dpv1alpha1.SchedulingSpec{
Affinity: schedulingPolicy.Affinity,
Tolerations: schedulingPolicy.Tolerations,
TopologySpreadConstraints: schedulingPolicy.TopologySpreadConstraints,
}, nil
Affinity: comp.PodSpec.Affinity,
Tolerations: comp.PodSpec.Tolerations,
TopologySpreadConstraints: comp.PodSpec.TopologySpreadConstraints,
}
}

func (r *RestoreManager) GetRestoreObjectMeta(comp *component.SynthesizedComponent, stage dpv1alpha1.RestoreStage, templateName string) metav1.ObjectMeta {
Expand Down
Loading