Fix: do not install k8s ns ACL rules if cluster IP has invalid value
Change-Id: I18cc9351f953444d1ec48e0042e1556f0115a8dc
diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/Constants.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/Constants.java
index 4a69e10..503ab08 100644
--- a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/Constants.java
+++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/Constants.java
@@ -53,6 +53,9 @@
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";
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNetworkPolicyHandler.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNetworkPolicyHandler.java
index b67858a..7125d06 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNetworkPolicyHandler.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNetworkPolicyHandler.java
@@ -84,6 +84,7 @@
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 @@
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);
}