[2.0b5] p.refresh.get_swap_size misconverting units
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MAAS |
Fix Released
|
High
|
Lee Trager |
Bug Description
On my local machine swapon(8) shows 6438252544 bytes of swap:
$ swapon --bytes --show
NAME TYPE SIZE USED PRIO
/dev/dm-1 partition 6438252544 0 -1
whereas get_swap_size() returns 6287356000:
$ bin/py
>>> from provisioningser
>>> get_swap_size()
6287356000
get_swap_size is defined like so:
def get_swap_size():
with open('/
for line in f:
if 'SwapTotal' in line:
return 0
which seems reasonable because /proc/meminfo uses kB as the unit:
$ egrep ^SwapTotal /proc/meminfo
SwapTotal: 6287356 kB
but get_swap_size should be multiplying by 1024, i.e. kiB, to get the
correct byte count. Or, perhaps better, it should sum byte counts as
shown by swapon(8):
$ swapon --noheadings --raw --bytes --show=SIZE
6438252544
Related branches
- Blake Rouse (community): Approve
- Gavin Panella (community): Approve
-
Diff: 232 lines (+28/-46)7 files modifiedsrc/maasserver/models/node.py (+0/-2)
src/maasserver/models/tests/test_node.py (+0/-5)
src/provisioningserver/refresh/__init__.py (+11/-13)
src/provisioningserver/refresh/tests/test_refresh.py (+14/-16)
src/provisioningserver/rpc/cluster.py (+0/-1)
src/provisioningserver/rpc/clusterservice.py (+2/-5)
src/provisioningserver/rpc/tests/test_clusterservice.py (+1/-4)
Changed in maas: | |
status: | Triaged → In Progress |
Changed in maas: | |
status: | In Progress → Fix Committed |
Changed in maas: | |
status: | Fix Committed → Fix Released |
It this is being placed in the "swap_size" field on a Machine this is incorrect. This is basically breaking the information of that machine that MAAS deployed.
This is not an issue on a pure rack controller, but it is a problem on a machine that was converted into a rack controller. It is reseting the value that should be unchanged while a machine is deployed. By allowing this field to be changed when it was a machine is incorrect.
I feel like gather this information on a rack controller is not that important anyway. It is not something we gather from a commissioning machine, because it is something you set when you configure a machine for deployment.