Skip to content

Commit

Permalink
Merge pull request #206 from blackpiglet/CSISnapshotTimeout_v0.6
Browse files Browse the repository at this point in the history
[cherry-pick][release-0.6]Use backup.Spec.CSISnapshotTimeout for DataDownload OperationTimeout.
  • Loading branch information
sseago authored Sep 28, 2023
2 parents 66706a1 + 623096a commit 6caf55b
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 @@ -181,7 +181,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,
dataDownload, err := restoreFromDataUploadResult(context.Background(), input.Restore, backup, &pvc,
operationID, pvcFromBackup.Namespace, p.Client, p.VeleroClient)
if err != nil {
logger.Errorf("Fail to restore from DataUploadResult: %s", err.Error())
Expand Down Expand Up @@ -373,7 +373,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, operationID string) *velerov2alpha1.DataDownload {
dataDownload := &velerov2alpha1.DataDownload{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -407,7 +407,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 @@ -441,7 +441,7 @@ func restoreFromVolumeSnapshot(pvc *corev1api.PersistentVolumeClaim, snapClient
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,
operationID string, sourceNamespace string, kubeClient kubernetes.Interface, veleroClient veleroClientSet.Interface) (*velerov2alpha1.DataDownload, error) {
dataUploadResult, err := getDataUploadResult(ctx, restore, pvc, sourceNamespace, kubeClient)
if err != nil {
Expand All @@ -456,7 +456,7 @@ func restoreFromDataUploadResult(ctx context.Context, restore *velerov1api.Resto
}
pvc.Spec.Selector.MatchLabels[util.DynamicPVRestoreLabel] = label.GetValidName(fmt.Sprintf("%s.%s.%s", pvc.Namespace, pvc.Name, utilrand.String(GenerateNameRandomLength)))

dataDownload := newDataDownload(restore, dataUploadResult, pvc, operationID)
dataDownload := newDataDownload(restore, backup, dataUploadResult, pvc, 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 6caf55b

Please sign in to comment.