-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EMC vnx block adds collect performance interface #906
EMC vnx block adds collect performance interface #906
Conversation
EMC vnx block adds collect performance interface
Codecov Report
@@ Coverage Diff @@
## master #906 +/- ##
==========================================
- Coverage 71.47% 71.12% -0.35%
==========================================
Files 182 182
Lines 21532 21889 +357
Branches 3291 3346 +55
==========================================
+ Hits 15389 15568 +179
- Misses 5103 5268 +165
- Partials 1040 1053 +13
|
Add collect performance interface
@@ -251,8 +256,10 @@ def list_disks(self, storage_id): | |||
hot_spare = disk.get('hot_spare', '') | |||
if hot_spare and hot_spare != 'N/A': | |||
logical_type = constants.DiskLogicalType.HOTSPARE | |||
disk_name = disk.get('disk_name') | |||
disk_name = disk_name.replace(' Disk', ' Disk') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is recommended to use this way: ' '.join(disk_name.strip().split())
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
metrics = [] | ||
archive_file_list = [] | ||
try: | ||
if (end_time - start_time) < consts.EXEC_TIME_INTERVAL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
statement is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
|
||
def collect_perf_metrics(self, storage_id, resource_metrics, | ||
start_time, end_time): | ||
metrics = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is recommended to add log info when starting this function, and record storage_id, start_time, and end_time in log info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
start_time, end_time): | ||
performance_lines_map = {} | ||
try: | ||
if not resources_map: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already judged outside of this function, so it's redundant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
if not resources_map: | ||
return performance_lines_map | ||
tools = Tools() | ||
for archive_file in (archive_file_list or []): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already judged outside of this function, or []
is redundant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
self.navi_handler.get_local_file_path(), | ||
archive_name_infos[0]) | ||
with open(file_path) as file: | ||
f_csv = csv.reader(StringIO(file.read())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need StringIO
? It's recommended to use simple statement csv.reader(file)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
metric_value_infos = metric_value | ||
if not consts.METRIC_MAP.get(resources_type): | ||
continue | ||
if not consts.METRIC_MAP.get(resources_type).get(metric_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two if
statements can be simplified as if not consts.METRIC_MAP.get(resources_type, {}).get(metric_name): continue
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
collection_timestamp, consts.COLLECTION_TIME_PATTERN) | ||
collection_timestamp = tools.time_str_to_timestamp( | ||
collection_time_str, consts.COLLECTION_TIME_PATTERN) | ||
if "iops" in metric_name.lower(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's recommended to use ==
, not in
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
tools = Tools() | ||
for metric_name in (metric_list or []): | ||
values = {} | ||
obj_labels = copy.deepcopy(labels) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use copy.copy()
, not copy.deepcopy()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
return metrics | ||
metrics = self.create_metrics(storage_id, resource_metrics, | ||
resources_map, resources_type_map, | ||
performance_lines_map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add log info to record storage_id, start_time, end_time, and the length of metrics
when collect successfully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
storage_id) | ||
if num > consts.EXEC_MAX_NUM: | ||
latest_time = file_latest_time | ||
LOG.warn("Storage:{},Exit after {} executions.".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace Chinese symbols with English symbols.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
Emc vnx block 20220529
Emc vnx block 20220529
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does / why we need it:
1 adds collect performance interface
Which issue this PR fixes (optional, in fixes #(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #
Special notes for your reviewer:
Release note: