Merge "NP: Don't add pods without IP to affectedPods"

This commit is contained in:
Zuul 2020-08-21 08:46:56 +00:00 committed by Gerrit Code Review
commit c5c1585b82
2 changed files with 3 additions and 1 deletions

View File

@ -69,6 +69,8 @@ class NetworkPolicyDriver(base.NetworkPolicyDriver):
if 'remote_ip_prefixes' in rule:
result['affectedPods'] = []
for ip, namespace in rule['remote_ip_prefixes']:
if not ip:
continue
result['affectedPods'].append({
'podIP': ip,
'podNamespace': namespace,

View File

@ -269,7 +269,7 @@ def create_security_group_rule_body(
security_group_rule_body['namespace'] = namespace
if pods:
security_group_rule_body['affectedPods'] = [
{'podIP': ip, 'podNamespace': ns} for ip, ns in pods.items()]
{'podIP': ip, 'podNamespace': ns} for ip, ns in pods.items() if ip]
LOG.debug("Creating sg rule body %s", security_group_rule_body)
return security_group_rule_body