Fix: do not install k8s ns ACL rules if cluster IP has invalid value

Change-Id: I18cc9351f953444d1ec48e0042e1556f0115a8dc
This commit is contained in:
Jian Li 2019-12-24 15:02:05 +09:00
parent afe47c2eae
commit c51f1872e3
2 changed files with 10 additions and 0 deletions

View File

@ -53,6 +53,9 @@ public final class Constants {
public static final String A_CLASS = "a";
public static final String B_CLASS = "b";
public static final String DEFAULT_SERVICE_IP_CIDR = "10.96.0.0/12";
public static final String DEFAULT_SERVICE_IP_NONE = "none";
public static final String PORT_NAME_PREFIX_CONTAINER = "veth";
public static final String ANNOTATION_NETWORK_ID = "networkId";

View File

@ -84,6 +84,7 @@ import static org.onosproject.k8snetworking.api.Constants.ACL_TABLE;
import static org.onosproject.k8snetworking.api.Constants.DEFAULT_METADATA_MASK;
import static org.onosproject.k8snetworking.api.Constants.DEFAULT_NAMESPACE_HASH;
import static org.onosproject.k8snetworking.api.Constants.DEFAULT_SEGMENT_ID;
import static org.onosproject.k8snetworking.api.Constants.DEFAULT_SERVICE_IP_NONE;
import static org.onosproject.k8snetworking.api.Constants.GROUPING_TABLE;
import static org.onosproject.k8snetworking.api.Constants.K8S_NETWORKING_APP_ID;
import static org.onosproject.k8snetworking.api.Constants.NAMESPACE_TABLE;
@ -812,6 +813,12 @@ public class K8sNetworkPolicyHandler {
return;
}
// one the creating of new service, the cluster IP will be configured as None
// in this case, we will NOT install any namespace related rules
if (DEFAULT_SERVICE_IP_NONE.equalsIgnoreCase(clusterIp)) {
return;
}
setNamespaceRulesBase(clusterIp, namespaceHashByServiceIp(k8sServiceService,
k8sNamespaceService, clusterIp), install);
}