Skip to content

Commit

Permalink
Merge pull request #204 from blackpiglet/6819_fix
Browse files Browse the repository at this point in the history
Use backup.Spec.CSISnapshotTimeout for DataDownload OperationTimeout
  • Loading branch information
ywk253100 authored Sep 28, 2023
2 parents bf26f77 + e0825a1 commit c0d55c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,3 @@ jobs:
run: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
./hack/docker-push.sh
# Use the JSON key in secret to login gcr.io
- uses: 'docker/login-action@v2'
with:
registry: 'gcr.io' # or REGION.docker.pkg.dev
username: '_json_key'
password: '${{ secrets.GCR_SA_KEY }}'

# Push image to GCR to facilitate some environments that have rate limitation to docker hub, e.g. vSphere.
- name: Publish container image to GCR
if: github.repository == 'vmware-tanzu/velero-plugin-for-csi'
run: |
sudo swapoff -a
sudo rm -f /mnt/swapfile
docker image prune -a --force
REGISTRY=gcr.io/velero-gcp ./hack/docker-push.sh
10 changes: 5 additions & 5 deletions internal/restore/pvc_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (p *PVCRestoreItemAction) Execute(input *velero.RestoreItemActionExecuteInp
}

operationID = label.GetValidName(string(velerov1api.AsyncOperationIDPrefixDataDownload) + string(input.Restore.UID) + "." + string(pvcFromBackup.UID))
dataDownload, err := restoreFromDataUploadResult(context.Background(), input.Restore, &pvc, newNamespace,
dataDownload, err := restoreFromDataUploadResult(context.Background(), input.Restore, backup, &pvc, newNamespace,
operationID, p.Client, p.VeleroClient)
if err != nil {
logger.Errorf("Fail to restore from DataUploadResult: %s", err.Error())
Expand Down Expand Up @@ -375,7 +375,7 @@ func cancelDataDownload(ctx context.Context, veleroClient veleroClientSet.Interf
return err
}

func newDataDownload(restore *velerov1api.Restore, dataUploadResult *velerov2alpha1.DataUploadResult,
func newDataDownload(restore *velerov1api.Restore, backup *velerov1api.Backup, dataUploadResult *velerov2alpha1.DataUploadResult,
pvc *corev1api.PersistentVolumeClaim, newNamespace, operationID string) *velerov2alpha1.DataDownload {
dataDownload := &velerov2alpha1.DataDownload{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -409,7 +409,7 @@ func newDataDownload(restore *velerov1api.Restore, dataUploadResult *velerov2alp
DataMover: dataUploadResult.DataMover,
SnapshotID: dataUploadResult.SnapshotID,
SourceNamespace: dataUploadResult.SourceNamespace,
OperationTimeout: restore.Spec.ItemOperationTimeout,
OperationTimeout: backup.Spec.CSISnapshotTimeout,
},
}

Expand Down Expand Up @@ -443,7 +443,7 @@ func restoreFromVolumeSnapshot(pvc *corev1api.PersistentVolumeClaim, newNamespac
return nil
}

func restoreFromDataUploadResult(ctx context.Context, restore *velerov1api.Restore, pvc *corev1api.PersistentVolumeClaim,
func restoreFromDataUploadResult(ctx context.Context, restore *velerov1api.Restore, backup *velerov1api.Backup, pvc *corev1api.PersistentVolumeClaim,
newNamespace, operationID string, kubeClient kubernetes.Interface, veleroClient veleroClientSet.Interface) (*velerov2alpha1.DataDownload, error) {
dataUploadResult, err := getDataUploadResult(ctx, restore, pvc, kubeClient)
if err != nil {
Expand All @@ -458,7 +458,7 @@ func restoreFromDataUploadResult(ctx context.Context, restore *velerov1api.Resto
}
pvc.Spec.Selector.MatchLabels[util.DynamicPVRestoreLabel] = label.GetValidName(fmt.Sprintf("%s.%s.%s", newNamespace, pvc.Name, utilrand.String(GenerateNameRandomLength)))

dataDownload := newDataDownload(restore, dataUploadResult, pvc, newNamespace, operationID)
dataDownload := newDataDownload(restore, backup, dataUploadResult, pvc, newNamespace, operationID)
_, err = veleroClient.VeleroV2alpha1().DataDownloads(restore.Namespace).Create(ctx, dataDownload, metav1.CreateOptions{})
if err != nil {
return nil, errors.Wrapf(err, "fail to create DataDownload")
Expand Down

0 comments on commit c0d55c6

Please sign in to comment.