Disk space calculations for controller file system are different in Python 2 and Python3
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
StarlingX |
Fix Released
|
Low
|
Jessica Castelino |
Bug Description
Brief Description
-----------------
This bug was uncovered while writing new test cases for sysinv API.
The below two calculations in controller file system return different values when run in Python2 and Python3:
(a) Calculating the space for controller file system (cgtsvg_
(b) Calculating the growth for controller filesystem (cgtsvg_growth_gib)
The division operations return different values.
Eg. 2/3 = 0 (Python 2)
2/3 = 0.66 (Python 3)
In order to replicate the same Python 2 behavior, we can make the following change in Python 3.
2//3 = 0 (Python 3)
Also, as the controller file system source code is undergoing modification, it would be a great idea to improve the logic in the first if-else block in _get_controller
Severity
--------
Minor
Steps to Reproduce
------------------
NA for unit test cases
Expected Behavior
------------------
The controller filesystem growth and space must return the same values in Python 2 and 3.
Actual Behavior
----------------
The division operations done for calculating controller filesystem growth and space yield different results in Python 2 and 3.
Reproducibility
---------------
100% reproducible
System Configuration
-------
One node system
Branch/Pull Time/Commit
-------
2020-02-10_10-52-51
Last Pass
---------
Unknown as this is a new unit test case.
Timestamp/Logs
--------------
NA for unit test cases
Test Activity
-------------
Unit testing
tags: |
added: stx.python3 removed: stx.python2 |
Jessica, if you update the sysinv tox.ini for the py27 section and add:
setenv = {[testenv]setenv}
PYTHON= python2. 7 -3
then when you run "tox -e py27" it will display any other places in the sysinv code that also have potential errors like this, and should display:
DeprecationWarning: classic int division
(however it will display quite a few others as well)
ex: api/middleware/ parsable_ error.py: 71: DeprecationWarning: classic int division 'status_ code'] / 100) not in (2, 3):
sysinv/
if (state[