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

Pass group version as an argument while creating PVC from volume snapshot #2295

Merged
merged 7 commits into from
Sep 14, 2023
6 changes: 6 additions & 0 deletions pkg/kube/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"

Expand Down Expand Up @@ -116,6 +117,7 @@ type CreatePVCFromSnapshotArgs struct {
Annotations map[string]string
VolumeMode *v1.PersistentVolumeMode
AccessModes []v1.PersistentVolumeAccessMode
GroupVersion schema.GroupVersion
kale-amruta marked this conversation as resolved.
Show resolved Hide resolved
}

// CreatePVCFromSnapshot will restore a volume and returns the resulting
Expand All @@ -131,6 +133,10 @@ func CreatePVCFromSnapshot(ctx context.Context, args *CreatePVCFromSnapshotArgs)
}
snapshotKind := "VolumeSnapshot"
snapshotAPIGroup := "snapshot.storage.k8s.io"
kale-amruta marked this conversation as resolved.
Show resolved Hide resolved
kale-amruta marked this conversation as resolved.
Show resolved Hide resolved
if !args.GroupVersion.Empty() {
snapshotAPIGroup = args.GroupVersion.String()
}

pvc := &v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Labels: args.Labels,
Expand Down