summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-05-18 04:31:08 +0000
committerGerrit Code Review <review@openstack.org>2022-05-18 04:31:08 +0000
commitb12afbf4e92c1a801c032570ba4e9b4ebd0cb911 (patch)
treea270170e9d5161e87f75cc6623ed1065d7260192
parent08d56f871311464c7d8f3c1f0c56b2a7f9cd36e1 (diff)
parent6072ef37eed5d3ff5ad8d329ba6bf343a2716ae3 (diff)
downloaddesignate-b12afbf4e92c1a801c032570ba4e9b4ebd0cb911.tar.gz
Merge "Fix set-quotas for non-project scoped tokens" into stable/xena
-rw-r--r--designate/api/v2/controllers/quotas.py10
-rw-r--r--releasenotes/notes/Require-all-projects-for-set-quotas-with-non-project-scoped-tokens-ffe3082db3dbb55b.yaml6
2 files changed, 16 insertions, 0 deletions
diff --git a/designate/api/v2/controllers/quotas.py b/designate/api/v2/controllers/quotas.py
index c4a766f4..801a2d8a 100644
--- a/designate/api/v2/controllers/quotas.py
+++ b/designate/api/v2/controllers/quotas.py
@@ -19,6 +19,7 @@ from oslo_log import log as logging
from designate.api.v2.controllers import rest
from designate.common import keystone
+from designate import exceptions
from designate.objects.adapters import DesignateAdapter
from designate.objects import QuotaList
@@ -63,6 +64,15 @@ class QuotasController(rest.RestController):
quotas = DesignateAdapter.parse('API_v2', body, QuotaList())
+ # The get_quotas lookup will always return the default quotas
+ # if the context does not have a project_id (system scoped token) and
+ # the all_tenants boolean is false. Let's require all_tenants for
+ # contexts with no project ID.
+ if context.project_id is None and not context.all_tenants:
+ raise exceptions.MissingProjectID(
+ "The all-projects flag must be used when using non-project "
+ "scoped tokens.")
+
for quota in quotas:
self.central_api.set_quota(context, tenant_id, quota.resource,
quota.hard_limit)
diff --git a/releasenotes/notes/Require-all-projects-for-set-quotas-with-non-project-scoped-tokens-ffe3082db3dbb55b.yaml b/releasenotes/notes/Require-all-projects-for-set-quotas-with-non-project-scoped-tokens-ffe3082db3dbb55b.yaml
new file mode 100644
index 00000000..eaf17979
--- /dev/null
+++ b/releasenotes/notes/Require-all-projects-for-set-quotas-with-non-project-scoped-tokens-ffe3082db3dbb55b.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ Fixed an issue where set-quotas will always return the default quotas if
+ it was called with a non-project scoped token and the all-projects flag
+ was not set.