Bug 1881928 - Cannot create a VM from golden image - insufficient permissions in clone source namespace openshift-virtualization-os-images
Summary: Cannot create a VM from golden image - insufficient permissions in clone sou...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: SSP
Version: 2.5.0
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: ---
: 2.5.0
Assignee: Shweta
QA Contact: Israel Pinto
URL:
Whiteboard:
Depends On: 1885196
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-23 12:13 UTC by Ruth Netser
Modified: 2020-11-17 13:24 UTC (History)
11 users (show)

Fixed In Version: kubevirt-ssp-operator-container-v2.5.0-50
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-17 13:24:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github kubevirt kubevirt pull 4269 0 None closed vendor in 1.23.5 CDI 2020-10-30 15:59:43 UTC
Red Hat Product Errata RHEA-2020:5127 0 None None None 2020-11-17 13:24:39 UTC

Description Ruth Netser 2020-09-23 12:13:03 UTC
Description of problem:
From the UI - fail to create a VM from cloned golden image

Version-Release number of selected component (if applicable):
CNV 2.5.0
OCP 4.6

How reproducible:
100%

Steps to Reproduce - from the UI:
1. Create a golden image PVC in openshift-virtualization-os-images ns
2. Create a VM in default ns -> select the OS with the attached golden image 

Actual results:
VM creation fails on:
Error "Authorization failed, message is: User system:serviceaccount:default:default has insufficient permissions in clone source namespace openshift-virtualization-os-images" for field "spec.dataVolumeTemplates[0]".

Expected results:
VM creation should succeed.

Additional info:
$ oc auth can-i create datavolumes/source --as system:serviceaccount:default:default -n openshift-virtualization-os-images
no
$ oc auth can-i get pvc --as system:serviceaccount:default:default -n openshift-virtualization-os-images
yes

Comment 1 Michael Henriksen 2020-09-23 12:19:07 UTC
This is not a storage bug.  SSP operator is responsible for creating the roles/rolebindings to access openshift-virtualization-os-image

Comment 2 Michael Henriksen 2020-09-23 13:20:11 UTC
looks like may have to add:

subjects:
- kind: Group
  name: system:serviceaccounts
  apiGroup: rbac.authorization.k8s.io

to the role SSP creates

https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-binding-examples

Apparently serviceaccounts aren't considered authenticated users?

Comment 3 Michael Henriksen 2020-09-23 13:27:47 UTC
I will confirm...

Comment 4 Michael Henriksen 2020-09-23 13:49:58 UTC
Just tested and there are a couple of issues:

The role created by SSP has to include "system:serviceaccounts" as mentioned above.

ALSO,

kubevirt has to be updated to check group permissions as well as service account permissions

Comment 5 Shweta 2020-09-28 05:05:58 UTC
I tried adding the "system:serviceaccounts" rolebinding, but it didn't help. The auth command still failed while checking create permissions for datavolume/source.

I then tried adding the create permission for the resource datavolumes along with create permissions for the sub-resource datavolumes/source(which was already present) and that worked. So I think, just assigning permissions to sub-resources will not work, the parent resource needs to have the same permission. I am trying to find the documentation on the kubernetes documation page regarding this, will send a link when I find it.

For now I have this WIP patch
https://github.com/kubevirt/kubevirt-ssp-operator/pull/243

Comment 6 Michael Henriksen 2020-09-28 11:46:20 UTC
> I tried adding the "system:serviceaccounts" rolebinding, but it didn't help. The auth command still failed while checking create permissions for datavolume/source.

Yeah as I mention above, kubevirt changes are necessary.  They were just merged:  https://github.com/kubevirt/kubevirt/pull/4269

Comment 7 Shweta 2020-10-01 04:17:24 UTC
Modifications have been made to the kubevirt-ssp-operator as suggested. Here is the PR - https://github.com/kubevirt/kubevirt-ssp-operator/pull/243

@Ruth: The correct auth command used to verify if the serviceaccount has access to the dv/source subresource is 

oc auth can-i create datavolumes --subresource source --as system:serviceaccount:default:default -n kubevirt-os-images

Comment 8 Ruth Netser 2020-10-05 13:35:26 UTC
Blocked by bug 1885196

Comment 9 Ruth Netser 2020-10-12 12:25:41 UTC
Verified with kubevirt-ssp-operator-container-v2.5.0-52
1. Create golden image from UI
2. Create a VM from the UI using the wizard

- VM creation succeeds.
- PVC is cloned
- VM is running


spec:
  dataVolumeTemplates:
    - apiVersion: cdi.kubevirt.io/v1alpha1
      kind: DataVolume
      metadata:
        creationTimestamp: null
        name: fed3-rootdisk-6e2f6
      spec:
        pvc:
          accessModes:
            - ReadWriteOnce
          resources:
            requests:
              storage: 15Gi
          storageClassName: hostpath-provisioner
          volumeMode: Filesystem
        source:
          pvc:
            name: fedora32
            namespace: openshift-virtualization-os-images
  running: true
  template:
    metadata:
      creationTimestamp: null
      labels:
        flavor.template.kubevirt.io/tiny: 'true'
        kubevirt.io/domain: fed3
        kubevirt.io/size: tiny
        os.template.kubevirt.io/fedora32: 'true'
        vm.kubevirt.io/name: fed3
        workload.template.kubevirt.io/desktop: 'true'

Comment 12 errata-xmlrpc 2020-11-17 13:24:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Virtualization 2.5.0 Images), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2020:5127


Note You need to log in before you can comment on or make changes to this bug.