Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot[bot] authored Oct 10, 2023
2 parents 5be5dfd + b2cb233 commit 58aa08d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/federation/pingcap/v1alpha1/volume_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func UpdateVolumeRestoreMemberStatus(volumeRestoreStatus *VolumeRestoreStatus, k
}

for i := range volumeRestoreStatus.Restores {
if volumeRestoreStatus.Restores[i].RestoreName == restoreMemberStatus.RestoreName {
if volumeRestoreStatus.Restores[i].RestoreName == restoreMemberStatus.RestoreName && volumeRestoreStatus.Restores[i].K8sClusterName == k8sClusterName {
volumeRestoreStatus.Restores[i] = restoreMemberStatus
return
}
Expand Down
17 changes: 8 additions & 9 deletions pkg/fedvolumebackup/restore/restore_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (rm *restoreManager) listRestoreMembers(ctx context.Context, volumeRestore
if existedRestoreMember, ok := existedMembers[k8sClusterName]; ok {
restoreName = existedRestoreMember.RestoreName
} else {
restoreName = rm.generateRestoreMemberName(volumeRestore.Name, k8sClusterName)
restoreName = rm.generateRestoreMemberName(volumeRestore.Name)
}
restoreMember, err := kubeClient.PingcapV1alpha1().Restores(memberCluster.TCNamespace).Get(ctx, restoreName, metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -205,14 +205,13 @@ func (rm *restoreManager) executeRestoreVolumePhase(ctx context.Context, volumeR
v1alpha1.StartVolumeRestoreStep(&volumeRestore.Status, v1alpha1.VolumeRestoreStepRestoreVolume)
restoreMemberMap := make(map[string]*volumeRestoreMember, len(restoreMembers))
for _, restoreMember := range restoreMembers {
restoreMemberMap[restoreMember.restore.Name] = restoreMember
restoreMemberMap[restoreMember.k8sClusterName] = restoreMember
}

for i := range volumeRestore.Spec.Clusters {
memberCluster := volumeRestore.Spec.Clusters[i]
k8sClusterName := memberCluster.K8sClusterName
restoreName := rm.generateRestoreMemberName(volumeRestore.Name, k8sClusterName)
if _, ok := restoreMemberMap[restoreName]; ok {
if _, ok := restoreMemberMap[k8sClusterName]; ok {
continue
}

Expand All @@ -222,7 +221,7 @@ func (rm *restoreManager) executeRestoreVolumePhase(ctx context.Context, volumeR
return false, fmt.Errorf("create restore member %s to cluster %s error: %s", restoreMember.Name, k8sClusterName, err.Error())
}
memberCreated = true
klog.Infof("VolumeRestore %s/%s create restore member %s successfully", volumeRestore.Namespace, volumeRestore.Name, restoreMember.Name)
klog.Infof("VolumeRestore %s/%s create restore member %s to cluster %s successfully", volumeRestore.Namespace, volumeRestore.Name, restoreMember.Name, k8sClusterName)
v1alpha1.UpdateVolumeRestoreMemberStatus(&volumeRestore.Status, k8sClusterName, restoreMember)
}
return
Expand Down Expand Up @@ -388,7 +387,7 @@ func (rm *restoreManager) executeRestoreFinishPhase(ctx context.Context, volumeR
return false, controller.RequeueErrorf("update FederalVolumeRestorePhase to restore-finish in restore member %s of cluster %s error: %s", restoreMemberName, k8sClusterName, err.Error())
}
memberUpdated = true
klog.Infof("VolumeRestore %s/%s update restore member %s to restore finish", volumeRestore.Namespace, volumeRestore.Name, restoreCR.Name)
klog.Infof("VolumeRestore %s/%s update restore member %s of cluster %s to restore finish", volumeRestore.Namespace, volumeRestore.Name, restoreCR.Name, k8sClusterName)
}
return
}
Expand Down Expand Up @@ -531,7 +530,7 @@ func (rm *restoreManager) skipVolumeRestore(volumeRestore *v1alpha1.VolumeRestor
func (rm *restoreManager) buildRestoreMember(volumeRestoreName string, memberCluster *v1alpha1.VolumeRestoreMemberCluster, template *v1alpha1.VolumeRestoreMemberSpec, annotations map[string]string, labels map[string]string) *pingcapv1alpha1.Restore {
restoreMember := &pingcapv1alpha1.Restore{
ObjectMeta: metav1.ObjectMeta{
Name: rm.generateRestoreMemberName(volumeRestoreName, memberCluster.K8sClusterName),
Name: rm.generateRestoreMemberName(volumeRestoreName),
Namespace: memberCluster.TCNamespace,
Annotations: annotations,
},
Expand All @@ -556,8 +555,8 @@ func (rm *restoreManager) buildRestoreMember(volumeRestoreName string, memberClu
return restoreMember
}

func (rm *restoreManager) generateRestoreMemberName(volumeRestoreName, k8sClusterName string) string {
return fmt.Sprintf("fed-%s-%s", volumeRestoreName, k8sClusterName)
func (rm *restoreManager) generateRestoreMemberName(volumeRestoreName string) string {
return fmt.Sprintf("fed-%s", volumeRestoreName)
}

func isWarmUpSync(volumeRestore *v1alpha1.VolumeRestore) bool {
Expand Down
6 changes: 3 additions & 3 deletions pkg/fedvolumebackup/restore/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func newHelper(t *testing.T, restoreName, restoreNamespace string) *helper {
h.dataPlaneClient2 = h.deps.FedClientset[controller.FakeDataPlaneName2]
h.dataPlaneClient3 = h.deps.FedClientset[controller.FakeDataPlaneName3]

h.restoreMemberName1 = h.rm.generateRestoreMemberName(restoreName, controller.FakeDataPlaneName1)
h.restoreMemberName2 = h.rm.generateRestoreMemberName(restoreName, controller.FakeDataPlaneName2)
h.restoreMemberName3 = h.rm.generateRestoreMemberName(restoreName, controller.FakeDataPlaneName3)
h.restoreMemberName1 = h.rm.generateRestoreMemberName(restoreName)
h.restoreMemberName2 = h.rm.generateRestoreMemberName(restoreName)
h.restoreMemberName3 = h.rm.generateRestoreMemberName(restoreName)
return h
}

Expand Down

0 comments on commit 58aa08d

Please sign in to comment.