Skip to content

Commit f6c9939

Browse files
committed
Add reproducer for bug #2099702: flavor unset --project fails for deleted projects
When a project has been deleted from Keystone, `openstack flavor unset --project <deleted-project-id>` fails because find_project_id_sdk() validates the project against Keystone with validate_actor_existence=True (the default) and raises CommandError when the project is not found. This means Nova's removeTenantAccess API is never called, effectively bypassing the server-side fix for bug #1980845 which already handles deleted projects gracefully. The fix should pass validate_actor_existence=False when calling find_project_id_sdk() for the removeTenantAccess case, similar to how RemoveRole handles this in identity/v3/role.py. Related-Bug: #2099702 Assisted-By: Claude-Code opus 4.6 Change-Id: I438244dd226173b61e5f7c3105fe3006829a0e65 Signed-off-by: René Ribaud <rene.ribaud@gmail.com>
1 parent caec5c3 commit f6c9939

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,37 @@ def test_flavor_unset_with_unexist_flavor(self):
12221222
exceptions.CommandError, self.cmd.take_action, parsed_args
12231223
)
12241224

1225+
def test_flavor_unset_project_deleted_project(self):
1226+
# Simulate a project that has been deleted from Keystone
1227+
self.identity_sdk_client.find_project.side_effect = [
1228+
sdk_exceptions.ResourceNotFound()
1229+
]
1230+
1231+
deleted_project_id = 'deleted-project-uuid'
1232+
arglist = [
1233+
'--project',
1234+
deleted_project_id,
1235+
self.flavor.id,
1236+
]
1237+
verifylist = [
1238+
('project', deleted_project_id),
1239+
('flavor', self.flavor.id),
1240+
]
1241+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1242+
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
1253+
)
1254+
self.compute_client.flavor_remove_tenant_access.assert_not_called()
1255+
12251256
def test_flavor_unset_nothing(self):
12261257
arglist = [
12271258
self.flavor.id,

0 commit comments

Comments
 (0)