Fix: double check resource existence at receiving addition event
Change-Id: I80fb2b30201e3e770eb5384ecee2b78b32502936
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sEndpointsWatcher.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sEndpointsWatcher.java
index c3139c1..62c15e6 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sEndpointsWatcher.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sEndpointsWatcher.java
@@ -170,7 +170,10 @@
log.trace("Process endpoints {} creating event from API server.",
endpoints.getMetadata().getName());
- k8sEndpointsAdminService.createEndpoints(endpoints);
+ if (k8sEndpointsAdminService.endpoints(
+ endpoints.getMetadata().getUid()) == null) {
+ k8sEndpointsAdminService.createEndpoints(endpoints);
+ }
}
private void processModification(Endpoints endpoints) {
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sIngressWatcher.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sIngressWatcher.java
index 0b531df..2373713 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sIngressWatcher.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sIngressWatcher.java
@@ -170,7 +170,9 @@
log.trace("Process ingress {} creating event from API server.",
ingress.getMetadata().getName());
- k8sIngressAdminService.createIngress(ingress);
+ if (k8sIngressAdminService.ingress(ingress.getMetadata().getUid()) == null) {
+ k8sIngressAdminService.createIngress(ingress);
+ }
}
private void processModification(Ingress ingress) {
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNamespaceWatcher.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNamespaceWatcher.java
index 090f1ff..1ce7f9f 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNamespaceWatcher.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNamespaceWatcher.java
@@ -171,7 +171,9 @@
log.trace("Process namespace {} creating event from API server.",
namespace.getMetadata().getName());
- k8sNamespaceAdminService.createNamespace(namespace);
+ if (k8sNamespaceAdminService.namespace(namespace.getMetadata().getUid()) == null) {
+ k8sNamespaceAdminService.createNamespace(namespace);
+ }
}
private void processModification(Namespace namespace) {
@@ -182,7 +184,9 @@
log.trace("Process namespace {} updating event from API server.",
namespace.getMetadata().getName());
- k8sNamespaceAdminService.updateNamespace(namespace);
+ if (k8sNamespaceAdminService.namespace(namespace.getMetadata().getUid()) != null) {
+ k8sNamespaceAdminService.updateNamespace(namespace);
+ }
}
private void processDeletion(Namespace namespace) {
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNetworkPolicyWatcher.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNetworkPolicyWatcher.java
index 311ac8a..3ded560 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNetworkPolicyWatcher.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sNetworkPolicyWatcher.java
@@ -172,7 +172,10 @@
log.trace("Process network policy {} creating event from API server.",
networkPolicy.getMetadata().getName());
- k8sNetworkPolicyAdminService.createNetworkPolicy(networkPolicy);
+ if (k8sNetworkPolicyAdminService.networkPolicy(
+ networkPolicy.getMetadata().getUid()) == null) {
+ k8sNetworkPolicyAdminService.createNetworkPolicy(networkPolicy);
+ }
}
private void processModification(NetworkPolicy networkPolicy) {
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sPodWatcher.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sPodWatcher.java
index 978dbbf..1fd1808 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sPodWatcher.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sPodWatcher.java
@@ -168,7 +168,9 @@
log.trace("Process pod {} creating event from API server.",
pod.getMetadata().getName());
- k8sPodAdminService.createPod(pod);
+ if (k8sPodAdminService.pod(pod.getMetadata().getUid()) == null) {
+ k8sPodAdminService.createPod(pod);
+ }
}
private void processModification(Pod pod) {
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sServiceWatcher.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sServiceWatcher.java
index c32efa1..489eee3 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sServiceWatcher.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sServiceWatcher.java
@@ -171,7 +171,10 @@
log.trace("Process service {} creating event from API server.",
service.getMetadata().getName());
- k8sServiceAdminService.createService(service);
+ if (k8sServiceAdminService.service(
+ service.getMetadata().getUid()) == null) {
+ k8sServiceAdminService.createService(service);
+ }
}
private void processModification(Service service) {