image import copy-image API should reflect proper authorization
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance |
Fix Released
|
High
|
Unassigned | ||
Ussuri |
Fix Committed
|
High
|
Unassigned | ||
Victoria |
Fix Released
|
High
|
Unassigned |
Bug Description
In testing the image import copy-to-store mechanism from Nova, I hit an issue that seems clearly to be a bug. Scenario:
A user boots an instance from an image they have permission to see. Nova uses their credentials to start an image import copy-to-store operation, which succeeds:
"POST /v2/images/
Task [888e97e5-
Note the 202 return code. My code polls for a $timeout period, waiting for the image to either arrive at the new store, or be marked as error, which never happens ($timeout=600s). The glance log shows (trace truncated):
glance-api[14039]: File "/opt/stack/
glance-api[14039]: stores if
glance-api[14039]: File "/opt/stack/
glance-api[14039]: raise exception.
glance-api[14039]: glance.
So apparently Nova is unable to use the user's credentials to initiate a copy-to-store operation. That surprises me and I think it likely isn't the access control we should be enforcing. However, if we're going to reject the operation, we should reject it at the time the HTTP response is sent, not later async, since we can check authorization right then and there.
The problem in this case is that from the outside, I have no way of knowing that the task fails subsequently. I receive a 202, which means I should start polling for completion. The task fails to load/run and thus can't update any status on the image, and I'm left to wait for 600s before I give up.
So, at the very least, we're not checking the same set of permissions during the HTTP POST call, and we should be. I also would tend to argue that the user should be allowed to copy the image and not require an admin to do it, perhaps with some additional policy element to control that. However, I have to be able to determine when and when not to wait for 600s.
summary: |
- image import copy-to-store API should reflect proper authorization + image import copy-image API should reflect proper authorization |
Related fix proposed to branch: master /review. opendev. org/737382
Review: https:/