diff --git a/manila/api/v1/shares.py b/manila/api/v1/shares.py index fa1fa7856f..396aedc832 100644 --- a/manila/api/v1/shares.py +++ b/manila/api/v1/shares.py @@ -364,7 +364,8 @@ class ShareMixin(object): else: share_type = share_types.get_share_type( context, req_share_type) - except exception.ShareTypeNotFound: + except (exception.ShareTypeNotFound, + exception.ShareTypeNotFoundByName): msg = _("Share type not found.") raise exc.HTTPNotFound(explanation=msg) elif not snapshot: diff --git a/manila/db/sqlalchemy/api.py b/manila/db/sqlalchemy/api.py index b950463d7a..50907e63f8 100644 --- a/manila/db/sqlalchemy/api.py +++ b/manila/db/sqlalchemy/api.py @@ -4233,8 +4233,7 @@ def share_type_get(context, id, inactive=False, expected_fields=None): def _share_type_get_by_name(context, name, session=None): - result = (model_query(context, models.ShareTypes, session=session). - options(joinedload('extra_specs')). + result = (_share_type_get_query(context, session=session). filter_by(name=name). first()) diff --git a/releasenotes/notes/bug-1885956-enforce-policy-check-getting-share-type-by-name-5eca17b02bea5261.yaml b/releasenotes/notes/bug-1885956-enforce-policy-check-getting-share-type-by-name-5eca17b02bea5261.yaml new file mode 100644 index 0000000000..389ec9f268 --- /dev/null +++ b/releasenotes/notes/bug-1885956-enforce-policy-check-getting-share-type-by-name-5eca17b02bea5261.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Fixed `launchpad bug #1885956 `_ + by ensuring that policy checks are enforced when looking up a share-type + by name. This prevents a problem where shares could be stuck in CREATING + status when a user attempts to create a share using the name of a private + share-type to which the user lacks access.