Skip to content

Commit 12ba863

Browse files
committed
Allow removing deleted projects from flavor access list
When a project has been deleted from Keystone, `flavor unset --project` fails because find_project_id_sdk() validates the project existence against Keystone before calling Nova's removeTenantAccess API. Pass validate_actor_existence=False so that when the project is not found in Keystone, the raw project ID is passed through to Nova, which already handles deleted projects gracefully since the fix for bug #1980845. Closes-Bug: #2099702 Assisted-By: Claude-Code opus 4.6 Change-Id: Ida1608a0d8753e555206da56312a85536e50ba5b Signed-off-by: René Ribaud <rene.ribaud@gmail.com>
1 parent f6c9939 commit 12ba863

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

openstackclient/compute/v2/flavor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ def take_action(self, parsed_args: argparse.Namespace) -> None:
633633
identity_client,
634634
parsed_args.project,
635635
parsed_args.project_domain,
636+
validate_actor_existence=False,
636637
)
637638
compute_client.flavor_remove_tenant_access(
638639
flavor.id, project_id

openstackclient/tests/unit/compute/v2/test_flavor.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,6 @@ def test_flavor_unset_with_unexist_flavor(self):
12231223
)
12241224

12251225
def test_flavor_unset_project_deleted_project(self):
1226-
# Simulate a project that has been deleted from Keystone
12271226
self.identity_sdk_client.find_project.side_effect = [
12281227
sdk_exceptions.ResourceNotFound()
12291228
]
@@ -1240,18 +1239,13 @@ def test_flavor_unset_project_deleted_project(self):
12401239
]
12411240
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
12421241

1243-
# TODO(bug #2099702): This should succeed. When removing a project
1244-
# from a flavor's access list, the project may no longer exist in
1245-
# Keystone (deleted tenant). The command should pass the raw project
1246-
# ID through to Nova's removeTenantAccess API, which already handles
1247-
# this case since the fix for bug #1980845. Instead, the command
1248-
# fails because find_project_id_sdk() validates the project against
1249-
# Keystone with validate_actor_existence=True (the default) and
1250-
# raises CommandError when it doesn't exist.
1251-
self.assertRaises(
1252-
exceptions.CommandError, self.cmd.take_action, parsed_args
1242+
result = self.cmd.take_action(parsed_args)
1243+
self.assertIsNone(result)
1244+
1245+
self.compute_client.flavor_remove_tenant_access.assert_called_with(
1246+
self.flavor.id,
1247+
deleted_project_id,
12531248
)
1254-
self.compute_client.flavor_remove_tenant_access.assert_not_called()
12551249

12561250
def test_flavor_unset_nothing(self):
12571251
arglist = [

0 commit comments

Comments
 (0)