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

Virtctl - Force Bind the PVC on WFFC storage #6513

Merged
merged 3 commits into from
Oct 26, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 22 additions & 8 deletions pkg/virtctl/imageupload/imageupload.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const (
// PodReadyAnnotation tells whether the uploadserver pod is ready
PodReadyAnnotation = "cdi.kubevirt.io/storage.pod.ready"

uploadRequestAnnotation = "cdi.kubevirt.io/storage.upload.target"
uploadRequestAnnotation = "cdi.kubevirt.io/storage.upload.target"
forceImmediateBindingAnnotation = "cdi.kubevirt.io/storage.bind.immediate.requested"
brybacki marked this conversation as resolved.
Show resolved Hide resolved

uploadReadyWaitInterval = 2 * time.Second

Expand Down Expand Up @@ -88,6 +89,7 @@ var (
blockVolume bool
noCreate bool
createPVC bool
forceBind bool
)

// HTTPClientCreator is a function that creates http clients
Expand Down Expand Up @@ -139,6 +141,7 @@ func NewImageUploadCommand(clientConfig clientcmd.ClientConfig) *cobra.Command {
cmd.MarkFlagRequired("image-path")
cmd.Flags().BoolVar(&noCreate, "no-create", false, "Don't attempt to create a new DataVolume/PVC.")
cmd.Flags().UintVar(&uploadPodWaitSecs, "wait-secs", 300, "Seconds to wait for upload pod to start.")
cmd.Flags().BoolVar(&forceBind, "force-bind", false, "Force Bind the PVC, ignoring the WaitForFirstConsumer logic")
brybacki marked this conversation as resolved.
Show resolved Hide resolved
cmd.SetUsageTemplate(templates.UsageTemplate())
return cmd
}
Expand Down Expand Up @@ -522,10 +525,16 @@ func createUploadDataVolume(client kubecli.KubevirtClient, namespace, name, size
return nil, err
}

annotations := map[string]string{}
if forceBind {
annotations[forceImmediateBindingAnnotation] = ""
}

dv := &cdiv1.DataVolume{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Name: name,
Namespace: namespace,
Annotations: annotations,
},
Spec: cdiv1.DataVolumeSpec{
Source: &cdiv1.DataVolumeSource{
Expand Down Expand Up @@ -582,13 +591,18 @@ func createUploadPVC(client kubernetes.Interface, namespace, name, size, storage
return nil, err
}

annotations := map[string]string{
uploadRequestAnnotation: "",
}
if forceBind {
annotations[forceImmediateBindingAnnotation] = ""
brybacki marked this conversation as resolved.
Show resolved Hide resolved
}

pvc := &v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Annotations: map[string]string{
uploadRequestAnnotation: "",
},
Name: name,
Namespace: namespace,
Annotations: annotations,
},
Spec: *pvcSpec,
}
Expand Down