Bug 1771927 - VM cloning fails on permission when cloned to different namespace than original VM
Summary: VM cloning fails on permission when cloned to different namespace than origin...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: Documentation
Version: 2.2.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: 2.2.0
Assignee: Andrew Burden
QA Contact: Irina Gulina
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-11-13 09:29 UTC by Radim Hrazdil
Modified: 2020-01-30 16:27 UTC (History)
9 users (show)

Fixed In Version: CNV 2.2
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-01-30 16:27:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
screenshot (51.98 KB, image/png)
2019-11-13 09:29 UTC, Radim Hrazdil
no flags Details
examle VM (2.46 KB, text/plain)
2019-11-13 09:30 UTC, Radim Hrazdil
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2020:0307 0 None None None 2020-01-30 16:27:42 UTC

Description Radim Hrazdil 2019-11-13 09:29:15 UTC
Created attachment 1635721 [details]
screenshot

Description of problem:
Consider user creating 2 namespaces and a VM via VM Wizard in one of those namespaces. Then when the VM is cloned to the other namespace, the cloning fails with permission error:
Error "Authorization failed, message is: User system:serviceaccount:rhrazdil-test:default has insufficient permissions in clone source namespace rhrazdil-test-cloneto" for field "spec.dataVolumeTemplates[0]".

It is possible to clone the VM to the same namespace (where the source/original VM is).

Version-Release number of selected component (if applicable):
OCP Cluster 4.3.0-0.nightly-2019-10-29-140935
UI running from master locally, commit 8a44a1fef0ce1ebb932d8561ab8ce0ac8d32aec0 

How reproducible:
100%

Steps to Reproduce:
0. log in as kubeadmin
1. create 2 namespaces
2. Create a VM with VM Wizard in one of created namespaces, see attached yaml for example
3. Clone the VM to the other created namespace

Actual results:
cloning fails with permission error

Expected results:
cloning should pass

Additional info:

Comment 1 Radim Hrazdil 2019-11-13 09:30:56 UTC
Created attachment 1635722 [details]
examle VM

Comment 2 Ido Rosenzwig 2019-11-14 11:40:51 UTC
This is not a bug.
The user kube:admin is missing permissions to clone data volumes from one namespace to another.

For it to work I had to create ClusterRole and Rolebinding in the source namespace (the namespace from which I try to clone the VM)

```
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: datavolume-cloner
rules:
- apiGroups: ["cdi.kubevirt.io"]
  resources: ["datavolumes/source"]
  verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: allow-clone-to-user
  namespace: <Source namespace>
subjects:
- kind: ServiceAccount
  name: default
  namespace: <Destination namespace>
roleRef:
  kind: ClusterRole
  name: datavolume-cloner
  apiGroup: rbac.authorization.k8s.io
```

Comment 3 Ido Rosenzwig 2019-11-14 14:07:54 UTC
Re-open, users should have the option to make operations across namespaces they own
out of the box, without manual rbac configuration.

Moving the bug to Storage.

Comment 4 Adam Litke 2019-11-15 16:43:43 UTC
Due to security considerations when breaching namespace boundaries we are requiring the rbac permissions to be in place.  We expect CNV documentation to provide further information about this.

Comment 5 Andrew Burden 2019-12-13 13:22:49 UTC
New content has been created to cover this, and included as a prerequisite to the cloning user stories.

PR: https://github.com/openshift/openshift-docs/pull/18609

The preview build for the new content can be viewed here:
https://cnv-bz1771927-rbac-clone--ocpdocs.netlify.com/openshift-enterprise/latest/cnv/cnv_users_guide/cnv-enabling-user-permissions-to-clone-datavolumes.html

Comment 6 Irina Gulina 2019-12-13 19:52:20 UTC
DataVolumes spelling is wrong. It should be camel case, see next two chapters. 

Also I'm not sure about its placement. What do you think about making it a part of "Cloning a virtual machine disk into a new DataVolume" and next "Cloning Templates" chapters?  Since 
* current RBAC section mentions DataVolumes, but only next two chapters have a subsection "About DataVolumes" explaining what it is and how it is used. 
* two next sections about cloning have a requirement about RBAC

or another way is to include "About DataVolumes" subsection in RBAC section?

Comment 7 Andrew Burden 2019-12-17 11:57:23 UTC
PR updated: https://github.com/openshift/openshift-docs/pull/18609

* Fixed the case for DataVolumes. 
* Added 'About DataVolumes' module into RBAC section

Although it's not apparent in this PR, the structure of the cnv content will be restructured prior to 2.2 release (WIP PR is here: https://github.com/openshift/openshift-docs/pull/18366/files), which will make this content much easier to navigate and discern at a glance.

Comment 9 Nelly Credi 2019-12-30 07:31:37 UTC
Please add 'fixed in version'

Comment 10 Irina Gulina 2020-01-16 15:05:43 UTC
Looks good, thanks Andrew.

Comment 12 errata-xmlrpc 2020-01-30 16:27:30 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, 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:0307


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