Open thanh-lam opened 3 years ago
@thanh-lam Here is output after the fixes have been implemented. The appropriate results are being returned without the python error.
[root@c650f99p06 python]# /opt/ibm/csm/bigdata/python/findJobTimeRange.py -a 1
# Found 1 matches for specified the job.
allocation-id: 1
job-id: 1 - 0
user-name: root
user-id: 0
begin-time: 2021-02-23.12:04:34:828
end-time: 2021-02-23.12:04:39:513
[root@c650f99p06 python]# ./findJobTimeRange.py -j 1
# Found 15 matches for specified the job.
# This implementation only supports queries where the hit count is equal to 1.
Fixed by #994
Describe the bug A regression test on the CSM bigdata python command
"findJobTimeRange.py"
produced following message even though the allocation ID (1) in question did exist. That meant "total_hits" has the value 1.Adding a debug in the print statement in the script showed that total_hits has "value" as {'value': 1, 'relation': 'eq'} that also showed in message above.
That led to the condition checking:
Diagnosis: "total_hits" has "value" 1 but fell into the code path of
"total_hits != 1"
. So total_hits was not in the format of an integer 1. The output `{'value': 1, 'relation': 'eq'} hinted that it is a "dict" object. Further debugging confirmed that.Python doesn't require data type declaration. Therefore, the change of total_hits from an integer to a "dict" object went without notice. But, the script failed the if condition due to the different format.
To adapt to this change of data type, change
total_hits
tototal_hits['value']
.To Reproduce Steps to reproduce the behavior:
Expected behavior The command should display start and end time of the allocation. For example:
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context This is probably due to the python scripts were written for elastic 6.8.1 that is now upgraded to 7.5.1. It's not clear when the change of "total_hits" format happened.
Issue Source: All bigdata python scripts that do the following might fail "un-knowingly".
Here's a list of those scripts: