Refactor status wait time for Ranger-agent response
Ranger-agent may take a longer time to process IMS resource request from Ranger. This ps allows Ranger to wait for Ranger-agent response an extended period of time compared to other service requests such as FMS or CMS. Change-Id: Ie4ab9944d9636b62b76b87b093a31724177e767e
This commit is contained in:
parent
84c23a4781
commit
b249c3a675
@ -44,9 +44,12 @@ OrmOpts = [
|
|||||||
cfg.StrOpt('ranger_agent_client_cert_path',
|
cfg.StrOpt('ranger_agent_client_cert_path',
|
||||||
default='',
|
default='',
|
||||||
help='Ranger Agent certificate path.'),
|
help='Ranger Agent certificate path.'),
|
||||||
cfg.IntOpt('resource_status_max_interval',
|
cfg.IntOpt('resource_status_wait_time',
|
||||||
default=2,
|
default=120,
|
||||||
help='Interval in seconds.'),
|
help='Time to wait for resource status in seconds.'),
|
||||||
|
cfg.IntOpt('resource_status_extended_wait_time',
|
||||||
|
default=320,
|
||||||
|
help='Extended time to wait for resource status in seconds.'),
|
||||||
cfg.StrOpt('log_location',
|
cfg.StrOpt('log_location',
|
||||||
default='/var/log/ranger',
|
default='/var/log/ranger',
|
||||||
help='Orm log directory.'),
|
help='Orm log directory.'),
|
||||||
|
@ -28,13 +28,18 @@ class ResourceStatusRecord:
|
|||||||
def resource_status(self, resource_status):
|
def resource_status(self, resource_status):
|
||||||
self.__resource_status = resource_status
|
self.__resource_status = resource_status
|
||||||
|
|
||||||
def read_resource_status(self, resource_uuids):
|
def read_resource_status(self, resource_uuids, extended):
|
||||||
records_model = {}
|
records_model = {}
|
||||||
statuses_model = {}
|
statuses_model = {}
|
||||||
|
|
||||||
timestamp = int(time.time()) * 1000
|
timestamp = int(time.time()) * 1000
|
||||||
# assume same time period for all resource types
|
|
||||||
max_interval_in_seconds = cfg.CONF.resource_status_max_interval * 60
|
if extended:
|
||||||
|
max_interval_in_seconds = \
|
||||||
|
cfg.CONF.resource_status_extended_wait_time
|
||||||
|
else:
|
||||||
|
max_interval_in_seconds = cfg.CONF.resource_status_wait_time
|
||||||
|
|
||||||
ref_timestamp = (int(time.time()) - max_interval_in_seconds) * 1000
|
ref_timestamp = (int(time.time()) - max_interval_in_seconds) * 1000
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -246,9 +246,9 @@ def delete_uuid(uuid):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_resource_status_from_db(session, resource_ids):
|
def get_resource_status_from_db(session, resource_ids, extended=False):
|
||||||
resource_status_record = ResourceStatusRecord(session)
|
resource_status_record = ResourceStatusRecord(session)
|
||||||
return resource_status_record.read_resource_status(resource_ids)
|
return resource_status_record.read_resource_status(resource_ids, extended)
|
||||||
|
|
||||||
|
|
||||||
def get_region_end_point_from_db(session, region_id, end_point_type):
|
def get_region_end_point_from_db(session, region_id, end_point_type):
|
||||||
|
@ -151,7 +151,7 @@ def delete_image_by_uuid(image_uuid, transaction_id):
|
|||||||
# Get status from resource status table
|
# Get status from resource status table
|
||||||
uuid = [sql_image.id]
|
uuid = [sql_image.id]
|
||||||
resource_status_dict = utils.get_resource_status_from_db(
|
resource_status_dict = utils.get_resource_status_from_db(
|
||||||
datamanager.get_session(), uuid)
|
datamanager.get_session(), uuid, True)
|
||||||
status_model = resource_status_dict.get(sql_image.id)
|
status_model = resource_status_dict.get(sql_image.id)
|
||||||
|
|
||||||
if status_model:
|
if status_model:
|
||||||
@ -472,7 +472,7 @@ def get_image_by_uuid(image_uuid, query_by_id_or_name=False):
|
|||||||
# Get the status from resource table
|
# Get the status from resource table
|
||||||
uuid = [sql_image.id]
|
uuid = [sql_image.id]
|
||||||
resource_status_dict = utils.get_resource_status_from_db(
|
resource_status_dict = utils.get_resource_status_from_db(
|
||||||
datamanager.get_session(), uuid)
|
datamanager.get_session(), uuid, True)
|
||||||
status_model = resource_status_dict.get(sql_image.id)
|
status_model = resource_status_dict.get(sql_image.id)
|
||||||
|
|
||||||
image_wrapper = set_resource_status(sql_image, status_model)
|
image_wrapper = set_resource_status(sql_image, status_model)
|
||||||
@ -515,7 +515,7 @@ def get_image_list_by_params(visibility, region, Customer):
|
|||||||
if sql_images:
|
if sql_images:
|
||||||
uuids = [sql_image.id for sql_image in sql_images]
|
uuids = [sql_image.id for sql_image in sql_images]
|
||||||
resource_status_dict = utils.get_resource_status_from_db(
|
resource_status_dict = utils.get_resource_status_from_db(
|
||||||
datamanager.get_session(), uuids)
|
datamanager.get_session(), uuids, True)
|
||||||
|
|
||||||
for sql_image in sql_images:
|
for sql_image in sql_images:
|
||||||
status_model = resource_status_dict.get(sql_image.id)
|
status_model = resource_status_dict.get(sql_image.id)
|
||||||
|
Loading…
Reference in New Issue
Block a user