summaryrefslogtreecommitdiffstats
path: root/so-cnf-adapter-application/src/main
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2021-10-22 00:25:47 +0200
committerLukasz Rajewski <lukasz.rajewski@orange.com>2021-10-22 00:25:47 +0200
commit73119cf65b4e3c80c5b67e3f81784c98e0695ce5 (patch)
tree50bc194827a6d9f200aa16d952e425e70b80ad3f /so-cnf-adapter-application/src/main
parent44165469656ceaa53f52ebf4cf88cfeaf65c8f2a (diff)
Prevent failure of unsuccessful AAI delete operation
Issue-ID: SO-3404 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com> Change-Id: I589600b5b9d0d0fcb5cac95b86b3fdf597c22fe5
Diffstat (limited to 'so-cnf-adapter-application/src/main')
-rw-r--r--so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java4
-rw-r--r--so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/util/AaiRepository.java9
2 files changed, 11 insertions, 2 deletions
diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
index 9aaf439..ee8a362 100644
--- a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
+++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
@@ -140,7 +140,7 @@ public class CnfAdapterRest {
try {
aaiService.aaiUpdate(aaiRequest);
callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.COMPLETED);
- } catch (BadResponseException e) {
+ } catch (Exception e) {
logger.warn("Failed to create resource in AAI", e);
callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.FAILED);
callbackResponse.setMessage(e.getMessage());
@@ -165,7 +165,7 @@ public class CnfAdapterRest {
try {
aaiService.aaiDelete(aaiRequest);
callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.COMPLETED);
- } catch (BadResponseException e) {
+ } catch (Exception e) {
logger.warn("Failed to delete resource from AAI", e);
callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.FAILED);
callbackResponse.setMessage(e.getMessage());
diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/util/AaiRepository.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/util/AaiRepository.java
index 0531728..6c03757 100644
--- a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/util/AaiRepository.java
+++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/util/AaiRepository.java
@@ -39,8 +39,10 @@ import org.onap.so.adapters.cnf.service.aai.KubernetesResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.ws.rs.NotFoundException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -165,6 +167,13 @@ public class AaiRepository implements IAaiRepository {
.tenant(aaiRequest.getTenantId())
.k8sResource(r.getId());
return AAIUriFactory.createResourceUri(k8sResource.build(), aaiRequest.getCloudOwner(), aaiRequest.getCloudRegion(), aaiRequest.getTenantId(), r.getId());
+ }).filter(r -> {
+ if (aaiClient.exists(r))
+ return true;
+ else {
+ logger.warn("K8sResource " + r.toString() + "] does not exist in AAI. Skipping delete in AAI");
+ return false;
+ }
}).forEach(uri -> getTransaction().delete(uri));
}
}