Skip to content

Commit 70ccca4

Browse files
authored
Fix clients and buckets creation when deployment fails on a provider (#28)
* Fix IAM clients and S3 buckets creation when deployment fails in a provider * Move at the beginning the log message when find an IAM and S3 bucket node --------- Co-authored-by: Luca Giommi <[email protected]>
1 parent df1766b commit 70ccca4

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,17 @@ public boolean doDeploy(DeploymentMessage deploymentMessage) {
293293
if (resource.getToscaNodeType().equals(IAM_TOSCA_NODE_TYPE)) {
294294
String nodeName = resource.getToscaNodeName();
295295
LOG.info("Found node of type: {}. Node name: {}", IAM_TOSCA_NODE_TYPE, nodeName);
296+
297+
// If resource metadata is not empty means that the IAM client is already created.
298+
// If it is, fill iamTemplateOutput with resource metadata info, then continue to next
299+
// resource
300+
if (resource.getMetadata() != null) {
301+
LOG.info("Found an IAM client already created for the {} tosca node. Loading it.",
302+
nodeName);
303+
iamTemplateOutput.put(nodeName, resource.getMetadata());
304+
continue;
305+
}
306+
296307
String scopes;
297308
String issuerNode;
298309
String tokenCredentials = null;
@@ -418,14 +429,25 @@ public boolean doDeploy(DeploymentMessage deploymentMessage) {
418429
// Manage creation of an S3 bucket
419430
if (resource.getToscaNodeType().equals(toscaService.getS3ToscaNodeType())) {
420431
String nodeName = resource.getToscaNodeName();
432+
LOG.info("Found node of type: {}. Node name: {}", toscaService.getS3ToscaNodeType(),
433+
nodeName);
434+
435+
// If resource metadata is not empty means that the S3 bucket is already created.
436+
// If it is, fill s3TemplateOutput with resource metadata info, then continue to next
437+
// resource
438+
if (resource.getMetadata() != null) {
439+
LOG.info("Found an S3 bucket already created for the {} tosca node. Loading it.",
440+
nodeName);
441+
s3TemplateOutput.put(nodeName, resource.getMetadata());
442+
continue;
443+
}
444+
421445
String userGroup = deployment.getUserGroup();
422446
Map<String, Object> s3Result = null;
423447
String bucketName = null;
424448
String s3Url = null;
425449
String enableVersioning = null;
426450
Map<String, String> resourceMetadata = new HashMap<>();
427-
LOG.info("Found node of type: {}. Node name: {}", toscaService.getS3ToscaNodeType(),
428-
nodeName);
429451

430452
if (s3TemplateInput == null) {
431453
s3TemplateInput = toscaService.getS3Properties(ar);

0 commit comments

Comments
 (0)