Bug 1725672 - CDI: getting error with "unknown reason" when trying to create UploadTokenRequest for a none existing pvc
Summary: CDI: getting error with "unknown reason" when trying to create UploadTokenReq...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: Storage
Version: 2.0
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 2.4.0
Assignee: Alexander Wels
QA Contact: Natalie Gavrielov
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-01 08:48 UTC by Natalie Gavrielov
Modified: 2020-07-28 19:09 UTC (History)
7 users (show)

Fixed In Version: hco-bundle-registry-container-v2.3.0-388 virt-cdi-apiserver-container-v2.4.0-24
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-07-28 19:09:38 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github kubevirt containerized-data-importer pull 1233 0 None closed Allow tokens for PVCs that do not exist. 2021-01-05 08:43:25 UTC
Github kubevirt containerized-data-importer pull 1238 0 None closed Allow tokens for PVCs that do not exist. (#1233) 2021-01-05 08:42:47 UTC
Red Hat Product Errata RHSA-2020:3194 0 None None None 2020-07-28 19:09:53 UTC

Description Natalie Gavrielov 2019-07-01 08:48:37 UTC
Description of problem:
When accidentally trying to create an UploadTokenRequest for a pvc that doesn't exist in the specified namespace.

Version-Release number of selected component:
hco v2.0.0-30

How reproducible:
100%

Steps to Reproduce:
Create an upload token for a pvc that doesn't exist in the specified namespace.
Example yaml:
apiVersion: upload.cdi.kubevirt.io/v1alpha1
kind: UploadTokenRequest
metadata:
   name: upload-datavolume-token-2
   namespace: kubevirt-hyperconverged
spec:
   pvcName: upload-datavolume-2

Command: kubectl apply -f t2.yaml -o="jsonpath={.status.token}"

Actual results:
Error from server (BadRequest): error when creating "t2.yaml": the server rejected our request for an unknown reason (post uploadtokenrequests.upload.cdi.kubevirt.io)

Expected results:
Something of that sort:
Error from server ... the specified pvc wasn't found in namespace <current-namespace>

Comment 2 Fred Rolland 2019-09-04 09:11:34 UTC
There is a check if the PVC exists that use the error received from the API:
https://github.com/kubevirt/containerized-data-importer/blob/master/pkg/apiserver/apiserver.go#L343

Note there is a log with the reason that the request was rejected:
klog.Infof("Rejecting request for PVC %s that doesn't exist", pvcName)

I will see if I can create a more detail message that will get back to the user.

I don't think it is a medium severity/priority, should be low.

Comment 3 Natalie Gavrielov 2019-11-13 13:44:47 UTC
Hi Freddy, any updates on this one?

Comment 4 Adam Litke 2020-03-10 20:39:08 UTC
Pushing low severity bugs out to 2.4.

Comment 5 Ying Cui 2020-04-08 12:30:33 UTC
Alexander, could you help to give the update on this bug?

Comment 6 Alexander Wels 2020-04-08 12:34:06 UTC
No updates, its low priority and not an easy fix, other things are taking priority.

Comment 7 Adam Litke 2020-05-14 21:02:38 UTC
Can you elaborate why it's not an easy fix?  If we need to track this as an RFE in order to get it worked on that's fine but I'd like to at least understand how much effort it would take.  We have been carrying this for too many releases.

Comment 8 Alexander Wels 2020-05-18 11:48:20 UTC
Because everything we can do on our end, we already do. We check in the api server if the PVC exists, and if it does not, we return a 400 (BadRequest) with the error [0]. How or why kubectl turns that into "Error from server (BadRequest): error when creating "upload-token.yaml": the server rejected our request for an unknown reason (post uploadtokenrequests.upload.cdi.kubevirt.io)", I don't know. I can understand the BadRequest (thats the 400), but we do pass the error message as well, and that is not displayed.

We might be able to figure out if there is something better we can send to the client so it can display the error message. That would be the part that is not an easy fix.

[0] https://github.com/kubevirt/containerized-data-importer/blob/master/pkg/apiserver/apiserver.go#L312

Comment 9 Adam Litke 2020-06-03 21:01:33 UTC
If I remember correctly, creating a VM with an invalid spec gives us a more informative message.  Can we do something similar in our case?

Comment 10 Adam Litke 2020-06-10 13:32:52 UTC
The difference between this case and a VM is that we don't have a CRD so cannot perform special validation.  We don't have much opportunity to change the error as reported by the kubernetes API server as it currently is implemented.  We could investigate if we can always grant the token and have the upload proxy server report a better error message instead when a valid token refers to a non-existent PVC.  It also might be worth checking if we report a good error message when the PVC exists but is not bound.

Comment 11 Alexander Wels 2020-06-10 19:29:19 UTC
Allowing the token to be created and having the proxy reject the request seems to work well.

Comment 12 Natalie Gavrielov 2020-07-02 11:36:27 UTC
Created the following token:
$ cat token.yaml
apiVersion: upload.cdi.kubevirt.io/v1alpha1
kind: UploadTokenRequest
metadata:
   name: upload-dv
   namespace: recycle-pvs
spec:
   pvcName: upload

Still getting:
kubectl apply -f token.yaml -o="jsonpath={.status.token}"
Error from server (BadRequest): error when creating "token.yaml": the server rejected our request for an unknown reason (post uploadtokenrequests.upload.cdi.kubevirt.io)

Comment 13 Adam Litke 2020-07-07 11:33:24 UTC
I wonder if this could be due to the wrong container image being pulled into the compose.  @awels can you compare the md5sums and see if this is the case.

Comment 14 Alexander Wels 2020-07-07 19:05:28 UTC
@Natalie, can you provide me access to the cluster that has this problem?

Comment 15 Adam Litke 2020-07-09 12:25:50 UTC
@Natalie, perhaps it would be easier if you attempt to verify this again with the latest builds in case something was messed up with the compose.

Comment 16 Alexander Wels 2020-07-09 15:07:11 UTC
If it fails again, can you give me access to the cluster so I can investigate the version of the container?

Comment 17 Natalie Gavrielov 2020-07-15 11:44:10 UTC
In the latest build (CNV 2.4), it works as expected.
A. The token is created successfully.
B. The upload fails with a message saying "rejecting Upload Request for PVC upload that doesn't exist"

Comment 20 errata-xmlrpc 2020-07-28 19:09:38 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/RHSA-2020:3194


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