From 083eb4bc75eaed1b341c04c3692df2fabd68a0f4 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 8 Apr 2019 17:30:46 -0400 Subject: [PATCH] Delete require_instance_exists_using_uuid This decorator is extremely old, virtual_interface_get_by_instance started using it in 0d9d2487e2ca921ab54b1ecbe359c32ce8fb0c48 (Folsom). virtual_interface_get_by_instance is the only thing still using it and doesn't need to. The only thing which calls that DB API is VirtualInterfaceList.get_by_instance_uuid and everything calling that handles an empty list (and InstanceNotFound is probably unexpected in anything using those anyway, i.e. they'd need to already get the instance to lookup the VIFs). The decorator is also not fast - it calls instance_get_by_uuid which builds up a query on the Instance model and also joins on the metadata and system_metadata tables which is totally unnecessary for an existence type check. Anyway, there seems to be no good reason for having that decorator anymore as nothing else uses it, for example block_device_mapping_get_all_by_instance. Change-Id: I7dcb47f916908319ae58db12e9ab3dd8dad9ff39 Closes-Bug: #1823794 --- nova/db/sqlalchemy/api.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 530d9615957d..ce8298fafe33 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -171,20 +171,6 @@ def require_context(f): return wrapper -def require_instance_exists_using_uuid(f): - """Decorator to require the specified instance to exist. - - Requires the wrapped function to use context and instance_uuid as - their first two arguments. - """ - @functools.wraps(f) - def wrapper(context, instance_uuid, *args, **kwargs): - instance_get_by_uuid(context, instance_uuid) - return f(context, instance_uuid, *args, **kwargs) - - return wrapper - - def select_db_reader_mode(f): """Decorator to select synchronous or asynchronous reader mode. @@ -1596,7 +1582,6 @@ def virtual_interface_get_by_uuid(context, vif_uuid): @require_context -@require_instance_exists_using_uuid @pick_context_manager_reader_allow_async def virtual_interface_get_by_instance(context, instance_uuid): """Gets all virtual interfaces for instance.