Skip to content

Commit

Permalink
review comment fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sushanthakumar committed Mar 21, 2021
1 parent 8b1a46f commit 88f0818
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 22 deletions.
3 changes: 1 addition & 2 deletions delfin/api/v1/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
CONF = cfg.CONF

telemetry_opts = [
cfg.IntOpt('performance_collection_interval', default=300,
cfg.IntOpt('performance_collection_interval', default=900,
help='default interval (in sec) for performance collection'),
]

Expand Down Expand Up @@ -127,7 +127,6 @@ def create(self, req, body):
msg = _('Failed to trigger performance monitoring for storage: '
'%(storage)s. Error: %(err)s') % {'storage': storage['id'],
'err': six.text_type(e)}

LOG.error(msg)
return storage_view.build_storage(storage)

Expand Down
2 changes: 1 addition & 1 deletion delfin/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ class SecurityLevel(object):
"writeRequests"
]


BLOCK_SIZE = 4096


Expand All @@ -307,3 +306,4 @@ class TelemetryCollection(object):
PERFORMANCE_TASK_METHOD = "delfin.task_manager.scheduler.schedulers." \
"telemetry.performance_collection_handler." \
"PerformanceCollectionHandler"
PERIODIC_JOB_INTERVAL = 300
13 changes: 3 additions & 10 deletions delfin/task_manager/scheduler/schedule_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,20 @@
from oslo_utils import uuidutils

from delfin import context
from delfin.common import constants
from delfin.task_manager.scheduler import scheduler
from delfin.task_manager.scheduler.schedulers.telemetry import telemetry_job

LOG = log.getLogger(__name__)
CONF = cfg.CONF

telemetry_opts = [
cfg.IntOpt('periodic_task_schedule_interval', default=180,
help='default interval (in sec) for the periodic scan for '
'failed task scheduling'),
]
CONF.register_opts(telemetry_opts, "TELEMETRY")
telemetry = CONF.TELEMETRY


class SchedulerManager(object):
def __init__(self):
self.schedule_instance = scheduler.Scheduler.get_instance()

def start(self):
""" Initialise the schedulers for collection and failed tasks
""" Initialise the schedulers for periodic job creation
"""
ctxt = context.get_admin_context()
try:
Expand All @@ -49,7 +42,7 @@ def start(self):
periodic_scheduler_job_id = uuidutils.generate_uuid()
self.schedule_instance.add_job(
telemetry_job.TelemetryJob(ctxt), 'interval', args=[ctxt],
seconds=telemetry.periodic_task_schedule_interval,
seconds=constants.TelemetryCollection.PERIODIC_JOB_INTERVAL,
next_run_time=datetime.now(),
id=periodic_scheduler_job_id)
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ def __init__(self):
def __call__(self, ctx, task_id):
# Handles performance collection from driver and dispatch
try:

task = db.task_get(ctx, task_id)
LOG.debug('Collecting performance metrics for task id: %s'
% task['id'])
current_time = int(datetime.utcnow().timestamp())
db.task_update(ctx, task_id, {'last_run_time': current_time})

# Times (starttime and endtime) are epoch time in miliseconds
start_time = current_time * 1000
end_time = start_time + task['interval'] * 10000
# Times are epoch time in miliseconds
end_time = current_time * 1000
start_time = end_time - (task['interval'] * 1000)
self.task_rpcapi.collect_telemetry(ctx, task['storage_id'],
telemetry.TelemetryTask.
__module__ + '.' +
Expand All @@ -51,8 +50,7 @@ def __call__(self, ctx, task_id):
LOG.error("Failed to collect performance metrics for "
"task id :{0}, reason:{1}".format(task_id,
six.text_type(e)))

# Add this entry to failed task for the retry process
else:
LOG.debug("Performance collection done for storage id :{0}"
" and task id:{1}".format(task['storage_id'], task_id))
",task id :{1} and interval(in sec):{2}"
.format(task['storage_id'], task_id, task['interval']))
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __call__(self, ctx):

# method indicates the specific collection task to be triggered
collection_class = importutils.import_class(task['method'])
# Create periodic task
# Create periodic job
self.schedule.add_job(
collection_class(), 'interval',
args=[ctx, task_id], seconds=task['interval'],
Expand Down
1 change: 0 additions & 1 deletion etc/delfin/delfin.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ db_backend = sqlalchemy

[TELEMETRY]
performance_collection_interval = 300
periodic_task_schedule_interval = 180

[KAFKA_EXPORTER]
kafka_topic_name = "delfin-kafka"
Expand Down

0 comments on commit 88f0818

Please sign in to comment.