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

allow porting labels when initiating backup/restore member (#5241) #5247

Merged
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions pkg/fedvolumebackup/backup/backup_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (bm *backupManager) listAllBackupMembers(ctx context.Context, volumeBackup
func (bm *backupManager) initializeVolumeBackup(ctx context.Context, volumeBackup *v1alpha1.VolumeBackup) error {
initializeMember := volumeBackup.Spec.Clusters[0]
kubeClient := bm.deps.FedClientset[initializeMember.K8sClusterName]
backupMember := bm.buildBackupMember(volumeBackup.Name, &initializeMember, &volumeBackup.Spec.Template, volumeBackup.Annotations, true)
backupMember := bm.buildBackupMember(volumeBackup.Name, &initializeMember, &volumeBackup.Spec.Template, volumeBackup.Annotations, volumeBackup.Labels, true)
backupMember, err := kubeClient.PingcapV1alpha1().Backups(backupMember.Namespace).Create(ctx, backupMember, metav1.CreateOptions{})
if err != nil {
return controller.RequeueErrorf("create initialize backup member %s to cluster %s error: %s", backupMember.Name, initializeMember.K8sClusterName, err.Error())
Expand Down Expand Up @@ -266,7 +266,7 @@ func (bm *backupManager) executeVolumeBackup(ctx context.Context, volumeBackup *
}

kubeClient := bm.deps.FedClientset[memberCluster.K8sClusterName]
backupMember := bm.buildBackupMember(volumeBackup.Name, &memberCluster, &volumeBackup.Spec.Template, volumeBackup.Annotations, false)
backupMember := bm.buildBackupMember(volumeBackup.Name, &memberCluster, &volumeBackup.Spec.Template, volumeBackup.Annotations, volumeBackup.Labels, false)
if _, err := kubeClient.PingcapV1alpha1().Backups(memberCluster.TCNamespace).Create(ctx, backupMember, metav1.CreateOptions{}); err != nil {
return false, controller.RequeueErrorf("create backup member %s to cluster %s error: %s", backupMember.Name, memberCluster.K8sClusterName, err.Error())
}
Expand Down Expand Up @@ -394,12 +394,13 @@ func (bm *backupManager) updateVolumeBackupMembersToStatus(volumeBackupStatus *v
}
}

func (bm *backupManager) buildBackupMember(volumeBackupName string, clusterMember *v1alpha1.VolumeBackupMemberCluster, backupTemplate *v1alpha1.VolumeBackupMemberSpec, annotations map[string]string, initialize bool) *pingcapv1alpha1.Backup {
func (bm *backupManager) buildBackupMember(volumeBackupName string, clusterMember *v1alpha1.VolumeBackupMemberCluster, backupTemplate *v1alpha1.VolumeBackupMemberSpec, annotations map[string]string, labels map[string]string, initialize bool) *pingcapv1alpha1.Backup {
backupMember := &pingcapv1alpha1.Backup{
ObjectMeta: metav1.ObjectMeta{
Name: bm.generateBackupMemberName(volumeBackupName, clusterMember.K8sClusterName),
Namespace: clusterMember.TCNamespace,
Annotations: annotations,
Labels: labels,
},
Spec: pingcapv1alpha1.BackupSpec{
Mode: pingcapv1alpha1.BackupModeVolumeSnapshot,
Expand Down
4 changes: 2 additions & 2 deletions pkg/fedvolumebackup/restore/restore_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (rm *restoreManager) executeRestoreVolumePhase(ctx context.Context, volumeR
}

kubeClient := rm.deps.FedClientset[k8sClusterName]
restoreMember := rm.buildRestoreMember(volumeRestore.Name, &memberCluster, &volumeRestore.Spec.Template, volumeRestore.Annotations)
restoreMember := rm.buildRestoreMember(volumeRestore.Name, &memberCluster, &volumeRestore.Spec.Template, volumeRestore.Annotations, volumeRestore.Labels)
if _, err := kubeClient.PingcapV1alpha1().Restores(memberCluster.TCNamespace).Create(ctx, restoreMember, metav1.CreateOptions{}); err != nil {
return false, fmt.Errorf("create restore member %s to cluster %s error: %s", restoreMember.Name, k8sClusterName, err.Error())
}
Expand Down Expand Up @@ -477,7 +477,7 @@ func (rm *restoreManager) skipVolumeRestore(volumeRestore *v1alpha1.VolumeRestor
return v1alpha1.IsVolumeRestoreComplete(volumeRestore) || v1alpha1.IsVolumeRestoreFailed(volumeRestore)
}

func (rm *restoreManager) buildRestoreMember(volumeRestoreName string, memberCluster *v1alpha1.VolumeRestoreMemberCluster, template *v1alpha1.VolumeRestoreMemberSpec, annotations map[string]string) *pingcapv1alpha1.Restore {
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),
Expand Down
Loading