Skip to content

Commit

Permalink
Merge pull request #1070 from skalenetwork/add-swap-info-to-schain-info
Browse files Browse the repository at this point in the history
Add cpu, memory and swap to container info
  • Loading branch information
DmytroNazarenko authored May 16, 2024
2 parents bb8d657 + 0d76749 commit 11048bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions tests/routes/health_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def test_containers(skale_bp, dutils):
)
}
assert data == expected
for container_info in data['payload']:
field_map = {'cpu_shares': 0, 'mem_limit': 0, 'swap_limit': 0, 'swappiness': None}
for field, value in field_map.items():
assert container_info[field] == value


def test_containers_all(skale_bp, dutils, schain_db, cleanup_schain_containers):
Expand All @@ -85,6 +89,10 @@ def test_containers_all(skale_bp, dutils, schain_db, cleanup_schain_containers):
)
}
assert data == expected
for container_info in data['payload']:
field_map = {'cpu_shares': 0, 'mem_limit': 0, 'swap_limit': 0, 'swappiness': None}
for field, value in field_map.items():
assert container_info[field] == value


def test_schains_checks(skale_bp, skale, schain_on_contracts, schain_db, dutils):
Expand Down
6 changes: 5 additions & 1 deletion tools/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def inner(*args, **kwargs) -> list:
res.append({
'image': container.attrs['Config']['Image'],
'name': re.sub('/', '', container.attrs['Name']),
'state': container.attrs['State']
'state': container.attrs['State'],
'cpu_shares': container.attrs['HostConfig']['CpuShares'],
'mem_limit': container.attrs['HostConfig']['Memory'],
'swap_limit': container.attrs['HostConfig']['MemorySwap'],
'swappiness': container.attrs['HostConfig']['MemorySwappiness']
})
return res

Expand Down

0 comments on commit 11048bb

Please sign in to comment.