Skip to content
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

AC-5741 IPs are incorrectly marked as free on IP Pools page #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion kubedock/kapi/ippool.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ def get_network_ips(cls, net):
busy_ips = allocated_ips.keys()
network = ip_network(net)

blocked_blocks = cls.ip_list_by_blocks(sorted(blocked_ips))
blocked_blocks = cls.ip_list_by_blocks(
sorted(blocked_ips - set(busy_ips)))
busy_blocks = cls.ip_list_by_blocks(sorted(busy_ips))
non_free_blocks = sorted(set(blocked_blocks) | set(busy_blocks))
free_blocks = cls.get_missed_intervals(non_free_blocks,
Expand Down
24 changes: 24 additions & 0 deletions kubedock/kapi/tests/test_ippool.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,30 @@ def test_get_network_ips_aws(self, LoadBalanceService):
'network': None, 'node': None}
)

@responses.activate
def test_get_network_ips_with_node_overlapped_blocked(self):
network = u'192.168.2.0/24'
self._create_network(network, autoblock='192.168.2.0-192.168.2.10')

host = 'node1.kuberdock.local'
node = self.fixtures.node(host, u'192.168.2.3')
db.session.add(node)

res = ippool.IpAddrPool().get_network_ips(network)
self.assertEqual(res,
{'node': self.node.hostname,
'free_host_count': 245,
'ipv6': False,
'id': '192.168.2.0/24',
'network': '192.168.2.0/24',
'blocks': [
(3232236032, 3232236034, 'blocked'),
(3232236035, 3232236035, 'cluster member', host),
(3232236036, 3232236042, 'blocked'),
(3232236043, 3232236287, 'free'),
]}
)


if __name__ == '__main__':
unittest.main()