kubevirt: virtctl: error DataVolume.storage spec is missing accessMode and volumeMode

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

Found this following error when creating DV:

datavolume-controller  DataVolume.storage spec is missing accessMode and volumeMode

What you expected to happen:

DataVolume cirros created

How to reproduce it (as minimally and precisely as possible):

When I run this following command in virtctl version v0.47.1:

virtctl -n testing image-upload dv cirros --size=300Mi --image-path=./cirros-0.4.0-x86_64-disk.img --uploadproxy-url=https://127.0.0.1:31001 --insecure

The DataVolume fail to create with following error:

kubectl -n testing describe dv cirros

Events:
  Type     Reason            Age                  From                   Message
  ----     ------            ----                 ----                   -------
  Warning  ErrClaimNotValid  24s (x16 over 3m8s)  datavolume-controller  DataVolume.storage spec is missing accessMode and volumeMode, cannot get access mode from StorageProfile longhorn

But everything works fine if I use virtctl version v0.42.1

Anything else we need to know?:

Environment:

  • KubeVirt version (use virtctl version):
virtctl version
Client Version: version.Info{GitVersion:"v0.47.1", GitCommit:"c34de42a48f5564f4fd2c21b6cbda7b96664c65b", GitTreeState:"clean", BuildDate:"2021-11-11T16:01:45Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{GitVersion:"v0.49.0", GitCommit:"f8160a0b5eac2acafab74fd7916bfcaf0c39a6a3", GitTreeState:"clean", BuildDate:"2022-01-11T17:37:26Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
  • Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"clean", BuildDate:"2021-10-27T18:41:28Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"clean", BuildDate:"2021-09-15T21:32:41Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (19 by maintainers)

Most upvoted comments

If the --access-mode flag is not mandatory for image-upload command then IMHO it should work without it.

This seems to summarize the core of the issue pretty nicely. I am not sure if ReadWriteOnce is the best default mode, but setting a default sounds reasonable to me.

More info on StorageProfiles here: https://github.com/kubevirt/containerized-data-importer/blob/main/doc/storageprofile.md

The difference in behavior is described in options available, if one does virtctl image-upload --help for old version says that ReadWriteOnce is default if not provided. New version does not say it.

Flags: --access-mode string The access mode for the PVC.

It is just a change in behavior (a breaking change). We need to decide if it is a bug. If we want to fix it, by hiding new function behind additional option, or maybe provide a legacy flag. Or maybe just point users to new documentation?

@rmohr @vasiliy-ul WDYT?

I had a similar issue. Fixed that using:

kubectl apply -f - <<EOF
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: rancher.io/local-path
volumeBindingMode: WaitForFirstConsumer
EOF

# Patch local storage profile with default accessModes
kubectl patch --type merge -p '{"spec": {"claimPropertySets": [{"accessModes": ["ReadWriteOnce"]}]}}' StorageProfile local

… though it was for local storage class.