diff --git a/pom.xml b/pom.xml
index 456efe2..ff319f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,6 +20,7 @@
RESTful API Wrapper for Terraform
21
+ 2.0.5
2.5.0
3.3.1
3.8.0
@@ -105,6 +106,11 @@
org.eclipse.jgit
${jgit.version}
+
+ org.springframework.retry
+ spring-retry
+ ${spring.retry.version}
+
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/TerraformBootApplication.java b/src/main/java/org/eclipse/xpanse/terraform/boot/TerraformBootApplication.java
index efcf35f..65d6349 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/TerraformBootApplication.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/TerraformBootApplication.java
@@ -8,11 +8,13 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
+import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableAsync;
/**
* Main entry class to terraform-boot. This class can be directly executed to start the server.
*/
+@EnableRetry
@EnableAsync
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class TerraformBootApplication {
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromDirectoryApi.java b/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromDirectoryApi.java
index 9fdd166..dad3b6f 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromDirectoryApi.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromDirectoryApi.java
@@ -5,6 +5,8 @@
package org.eclipse.xpanse.terraform.boot.api.controllers;
+import static org.eclipse.xpanse.terraform.boot.logging.CustomRequestIdGenerator.REQUEST_ID;
+
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -70,12 +72,9 @@ public TerraformBootFromDirectoryApi(
public TerraformValidationResult validateFromDirectory(
@Parameter(name = "module_directory",
description = "directory name where the Terraform module files exist.")
- @PathVariable("module_directory") String moduleDirectory,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @PathVariable("module_directory") String moduleDirectory) {
+ UUID uuid = UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
return terraformDirectoryService.tfValidateFromDirectory(moduleDirectory);
}
@@ -93,13 +92,11 @@ public TerraformResult deployFromDirectory(
@Parameter(name = "module_directory",
description = "directory name where the Terraform module files exist.")
@PathVariable("module_directory") String moduleDirectory,
- @Valid @RequestBody
- TerraformDeployFromDirectoryRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformDeployFromDirectoryRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformDirectoryService.deployFromDirectory(request, moduleDirectory);
}
@@ -117,13 +114,11 @@ public TerraformResult modifyFromDirectory(
@Parameter(name = "module_directory",
description = "directory name where the Terraform module files exist.")
@PathVariable("module_directory") String moduleDirectory,
- @Valid @RequestBody
- TerraformModifyFromDirectoryRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformModifyFromDirectoryRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformDirectoryService.modifyFromDirectory(request, moduleDirectory);
}
@@ -142,13 +137,11 @@ public TerraformResult destroyFromDirectory(
@Parameter(name = "module_directory",
description = "directory name where the Terraform module files exist.")
@PathVariable("module_directory") String moduleDirectory,
- @Valid @RequestBody
- TerraformDestroyFromDirectoryRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformDestroyFromDirectoryRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformDirectoryService.destroyFromDirectory(request, moduleDirectory);
}
@@ -169,10 +162,10 @@ public TerraformPlan plan(
@PathVariable("module_directory") String moduleDirectory,
@Valid @RequestBody TerraformPlanFromDirectoryRequest request,
@RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ uuid = Objects.nonNull(request.getRequestId()) ? request.getRequestId()
+ : (Objects.nonNull(uuid) ? uuid : UUID.randomUUID());
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformDirectoryService.getTerraformPlanFromDirectory(request,
moduleDirectory);
}
@@ -190,13 +183,12 @@ public void asyncDeployFromDirectory(
@Parameter(name = "module_directory",
description = "directory name where the Terraform module files exist.")
@PathVariable("module_directory") String moduleDirectory,
- @Valid @RequestBody TerraformAsyncDeployFromDirectoryRequest asyncDeployRequest,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
- terraformDirectoryService.asyncDeployWithScripts(asyncDeployRequest, moduleDirectory);
+ @Valid @RequestBody TerraformAsyncDeployFromDirectoryRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
+ terraformDirectoryService.asyncDeployWithScripts(request, moduleDirectory);
}
/**
@@ -212,13 +204,12 @@ public void asyncModifyFromDirectory(
@Parameter(name = "module_directory",
description = "directory name where the Terraform module files exist.")
@PathVariable("module_directory") String moduleDirectory,
- @Valid @RequestBody TerraformAsyncModifyFromDirectoryRequest asyncModifyRequest,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
- terraformDirectoryService.asyncModifyWithScripts(asyncModifyRequest, moduleDirectory);
+ @Valid @RequestBody TerraformAsyncModifyFromDirectoryRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
+ terraformDirectoryService.asyncModifyWithScripts(request, moduleDirectory);
}
/**
@@ -234,12 +225,11 @@ public void asyncDestroyFromDirectory(
@Parameter(name = "module_directory",
description = "directory name where the Terraform module files exist.")
@PathVariable("module_directory") String moduleDirectory,
- @Valid @RequestBody TerraformAsyncDestroyFromDirectoryRequest asyncDestroyRequest,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
- terraformDirectoryService.asyncDestroyWithScripts(asyncDestroyRequest, moduleDirectory);
+ @Valid @RequestBody TerraformAsyncDestroyFromDirectoryRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
+ terraformDirectoryService.asyncDestroyWithScripts(request, moduleDirectory);
}
}
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromGitRepoApi.java b/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromGitRepoApi.java
index 423be58..0ae463b 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromGitRepoApi.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromGitRepoApi.java
@@ -5,6 +5,8 @@
package org.eclipse.xpanse.terraform.boot.api.controllers;
+import static org.eclipse.xpanse.terraform.boot.logging.CustomRequestIdGenerator.REQUEST_ID;
+
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -29,7 +31,6 @@
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@@ -61,12 +62,11 @@ public TerraformBootFromGitRepoApi(TerraformGitRepoService terraformGitRepoServi
MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformValidationResult validateScriptsFromGitRepo(
- @Valid @RequestBody TerraformDeployFromGitRepoRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformDeployFromGitRepoRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformGitRepoService.validateWithScripts(request);
}
@@ -82,12 +82,11 @@ public TerraformValidationResult validateScriptsFromGitRepo(
@PostMapping(value = "/plan", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformPlan planFromGitRepo(
- @Valid @RequestBody TerraformPlanFromGitRepoRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformPlanFromGitRepoRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformGitRepoService.getTerraformPlanFromGitRepo(request, uuid);
}
@@ -103,12 +102,11 @@ public TerraformPlan planFromGitRepo(
MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformResult deployFromGitRepo(
- @Valid @RequestBody TerraformDeployFromGitRepoRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformDeployFromGitRepoRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformGitRepoService.deployFromGitRepo(request, uuid);
}
@@ -124,12 +122,11 @@ public TerraformResult deployFromGitRepo(
MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformResult modifyFromGitRepo(
- @Valid @RequestBody TerraformModifyFromGitRepoRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformModifyFromGitRepoRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformGitRepoService.modifyFromGitRepo(request, uuid);
}
@@ -145,12 +142,11 @@ public TerraformResult modifyFromGitRepo(
MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformResult destroyFromGitRepo(
- @Valid @RequestBody TerraformDestroyFromGitRepoRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformDestroyFromGitRepoRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformGitRepoService.destroyFromGitRepo(request, uuid);
}
@@ -164,13 +160,12 @@ public TerraformResult destroyFromGitRepo(
MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public void asyncDeployFromGitRepo(
- @Valid @RequestBody TerraformAsyncDeployFromGitRepoRequest asyncDeployRequest,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
- terraformGitRepoService.asyncDeployFromGitRepo(asyncDeployRequest, uuid);
+ @Valid @RequestBody TerraformAsyncDeployFromGitRepoRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
+ terraformGitRepoService.asyncDeployFromGitRepo(request, uuid);
}
/**
@@ -183,13 +178,12 @@ public void asyncDeployFromGitRepo(
MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public void asyncModifyFromGitRepo(
- @Valid @RequestBody TerraformAsyncModifyFromGitRepoRequest asyncModifyRequest,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
- terraformGitRepoService.asyncModifyFromGitRepo(asyncModifyRequest, uuid);
+ @Valid @RequestBody TerraformAsyncModifyFromGitRepoRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
+ terraformGitRepoService.asyncModifyFromGitRepo(request, uuid);
}
/**
@@ -202,12 +196,11 @@ public void asyncModifyFromGitRepo(
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public void asyncDestroyFromGitRepo(
- @Valid @RequestBody TerraformAsyncDestroyFromGitRepoRequest asyncDestroyRequest,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
- terraformGitRepoService.asyncDestroyFromGitRepo(asyncDestroyRequest, uuid);
+ @Valid @RequestBody TerraformAsyncDestroyFromGitRepoRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
+ terraformGitRepoService.asyncDestroyFromGitRepo(request, uuid);
}
}
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromScriptsApi.java b/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromScriptsApi.java
index 99c6917..ac76ec3 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromScriptsApi.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/api/controllers/TerraformBootFromScriptsApi.java
@@ -5,6 +5,8 @@
package org.eclipse.xpanse.terraform.boot.api.controllers;
+import static org.eclipse.xpanse.terraform.boot.logging.CustomRequestIdGenerator.REQUEST_ID;
+
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -29,7 +31,6 @@
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@@ -57,16 +58,14 @@ public TerraformBootFromScriptsApi(TerraformScriptsService terraformScriptsServi
@Tag(name = "TerraformFromScripts", description =
"APIs for running Terraform commands on the scripts sent via request body.")
@Operation(description = "Deploy resources via Terraform")
- @PostMapping(value = "/validate", produces =
- MediaType.APPLICATION_JSON_VALUE)
+ @PostMapping(value = "/validate", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformValidationResult validateWithScripts(
- @Valid @RequestBody TerraformDeployWithScriptsRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformDeployWithScriptsRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformScriptsService.validateWithScripts(request);
}
@@ -78,16 +77,14 @@ public TerraformValidationResult validateWithScripts(
@Tag(name = "TerraformFromScripts", description =
"APIs for running Terraform commands on the scripts sent via request body.")
@Operation(description = "Deploy resources via Terraform")
- @PostMapping(value = "/deploy", produces =
- MediaType.APPLICATION_JSON_VALUE)
+ @PostMapping(value = "/deploy", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformResult deployWithScripts(
- @Valid @RequestBody TerraformDeployWithScriptsRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformDeployWithScriptsRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformScriptsService.deployWithScripts(request, uuid);
}
@@ -99,16 +96,14 @@ public TerraformResult deployWithScripts(
@Tag(name = "TerraformFromScripts", description =
"APIs for running Terraform commands on the scripts sent via request body.")
@Operation(description = "Modify resources via Terraform")
- @PostMapping(value = "/modify", produces =
- MediaType.APPLICATION_JSON_VALUE)
+ @PostMapping(value = "/modify", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformResult modifyWithScripts(
- @Valid @RequestBody TerraformModifyWithScriptsRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformModifyWithScriptsRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformScriptsService.modifyWithScripts(request, uuid);
}
@@ -120,16 +115,14 @@ public TerraformResult modifyWithScripts(
@Tag(name = "TerraformFromScripts", description =
"APIs for running Terraform commands on the scripts sent via request body.")
@Operation(description = "Destroy resources via Terraform")
- @PostMapping(value = "/destroy", produces =
- MediaType.APPLICATION_JSON_VALUE)
+ @PostMapping(value = "/destroy", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformResult destroyWithScripts(
- @Valid @RequestBody TerraformDestroyWithScriptsRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformDestroyWithScriptsRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformScriptsService.destroyWithScripts(request, uuid);
}
@@ -139,17 +132,15 @@ public TerraformResult destroyWithScripts(
@Tag(name = "TerraformFromScripts", description =
"APIs for running Terraform commands on the scripts sent via request body.")
@Operation(description = "async deploy resources via Terraform")
- @PostMapping(value = "/deploy/async", produces =
- MediaType.APPLICATION_JSON_VALUE)
+ @PostMapping(value = "/deploy/async", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public void asyncDeployWithScripts(
- @Valid @RequestBody TerraformAsyncDeployFromScriptsRequest asyncDeployRequest,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
- terraformScriptsService.asyncDeployWithScripts(asyncDeployRequest, uuid);
+ @Valid @RequestBody TerraformAsyncDeployFromScriptsRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
+ terraformScriptsService.asyncDeployWithScripts(request, uuid);
}
/**
@@ -158,17 +149,15 @@ public void asyncDeployWithScripts(
@Tag(name = "TerraformFromScripts", description =
"APIs for running Terraform commands on the scripts sent via request body.")
@Operation(description = "async modify resources via Terraform")
- @PostMapping(value = "/modify/async", produces =
- MediaType.APPLICATION_JSON_VALUE)
+ @PostMapping(value = "/modify/async", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public void asyncModifyWithScripts(
- @Valid @RequestBody TerraformAsyncModifyFromScriptsRequest asyncModifyRequest,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
- terraformScriptsService.asyncModifyWithScripts(asyncModifyRequest, uuid);
+ @Valid @RequestBody TerraformAsyncModifyFromScriptsRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
+ terraformScriptsService.asyncModifyWithScripts(request, uuid);
}
/**
@@ -177,17 +166,15 @@ public void asyncModifyWithScripts(
@Tag(name = "TerraformFromScripts", description =
"APIs for running Terraform commands on the scripts sent via request body.")
@Operation(description = "Async destroy the Terraform modules")
- @DeleteMapping(value = "/destroy/async",
- produces = MediaType.APPLICATION_JSON_VALUE)
+ @DeleteMapping(value = "/destroy/async", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public void asyncDestroyWithScripts(
- @Valid @RequestBody TerraformAsyncDestroyFromScriptsRequest asyncDestroyRequest,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
- terraformScriptsService.asyncDestroyWithScripts(asyncDestroyRequest, uuid);
+ @Valid @RequestBody TerraformAsyncDestroyFromScriptsRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
+ terraformScriptsService.asyncDestroyWithScripts(request, uuid);
}
/**
@@ -202,12 +189,11 @@ public void asyncDestroyWithScripts(
@PostMapping(value = "/plan", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformPlan planWithScripts(
- @Valid @RequestBody TerraformPlanWithScriptsRequest request,
- @RequestHeader(name = "X-Custom-RequestId", required = false) UUID uuid) {
- if (Objects.isNull(uuid)) {
- uuid = UUID.randomUUID();
- }
- MDC.put("TASK_ID", uuid.toString());
+ @Valid @RequestBody TerraformPlanWithScriptsRequest request) {
+ UUID uuid = Objects.nonNull(request.getRequestId())
+ ? request.getRequestId() : UUID.randomUUID();
+ MDC.put(REQUEST_ID, uuid.toString());
+ request.setRequestId(uuid);
return terraformScriptsService.getTerraformPlanFromScripts(request, uuid);
}
}
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/logging/CustomRequestIdGenerator.java b/src/main/java/org/eclipse/xpanse/terraform/boot/logging/CustomRequestIdGenerator.java
index c5e39d3..01e0a6f 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/logging/CustomRequestIdGenerator.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/logging/CustomRequestIdGenerator.java
@@ -16,10 +16,12 @@
*/
public class CustomRequestIdGenerator implements CorrelationId {
+ public static final String REQUEST_ID = "REQUEST_ID";
+
@Override
public String generate(@NonNull HttpRequest request) {
String uuid = UUID.randomUUID().toString();
- MDC.put("TASK_ID", uuid);
+ MDC.put(REQUEST_ID, uuid);
return uuid;
}
}
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/models/plan/TerraformPlanFromDirectoryRequest.java b/src/main/java/org/eclipse/xpanse/terraform/boot/models/plan/TerraformPlanFromDirectoryRequest.java
index c6b1657..ff1a7fc 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/models/plan/TerraformPlanFromDirectoryRequest.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/models/plan/TerraformPlanFromDirectoryRequest.java
@@ -9,6 +9,7 @@
import jakarta.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import lombok.Data;
/**
@@ -17,6 +18,9 @@
@Data
public class TerraformPlanFromDirectoryRequest {
+ @Schema(description = "Id of the request.")
+ UUID requestId;
+
@NotNull
@Schema(description = "Key-value pairs of variables that must be used to execute the "
+ "Terraform request.",
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformDeployFromDirectoryRequest.java b/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformDeployFromDirectoryRequest.java
index 9a4b6a6..99446df 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformDeployFromDirectoryRequest.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformDeployFromDirectoryRequest.java
@@ -9,6 +9,7 @@
import jakarta.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import lombok.Data;
/**
@@ -17,6 +18,9 @@
@Data
public class TerraformDeployFromDirectoryRequest {
+ @Schema(description = "Id of the request")
+ UUID requestId;
+
@NotNull
@Schema(description = "Flag to control if the deployment must only generate the terraform "
+ "or it must also apply the changes.")
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformDestroyFromDirectoryRequest.java b/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformDestroyFromDirectoryRequest.java
index c1207d9..faa6c6e 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformDestroyFromDirectoryRequest.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformDestroyFromDirectoryRequest.java
@@ -11,6 +11,7 @@
import jakarta.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import lombok.Data;
/**
@@ -19,6 +20,9 @@
@Data
public class TerraformDestroyFromDirectoryRequest {
+ @Schema(description = "Id of the request")
+ UUID requestId;
+
@NotNull
@Schema(description = "Key-value pairs of regular variables that must be used to execute the "
+ "Terraform request.", additionalProperties = TRUE)
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformModifyFromDirectoryRequest.java b/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformModifyFromDirectoryRequest.java
index 2c96077..9e5c165 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformModifyFromDirectoryRequest.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/directory/TerraformModifyFromDirectoryRequest.java
@@ -11,6 +11,7 @@
import jakarta.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import lombok.Data;
/**
@@ -18,6 +19,10 @@
*/
@Data
public class TerraformModifyFromDirectoryRequest {
+
+ @Schema(description = "Id of the request")
+ UUID requestId;
+
@NotNull
@Schema(description = "Flag to control if the deployment must only generate the terraform "
+ "or it must also apply the changes.")
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/scripts/TerraformModifyWithScriptsRequest.java b/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/scripts/TerraformModifyWithScriptsRequest.java
index 25a6371..9a0a9b7 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/scripts/TerraformModifyWithScriptsRequest.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/models/request/scripts/TerraformModifyWithScriptsRequest.java
@@ -8,6 +8,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import java.util.List;
+import java.util.UUID;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.eclipse.xpanse.terraform.boot.models.request.directory.TerraformModifyFromDirectoryRequest;
@@ -18,6 +19,10 @@
@EqualsAndHashCode(callSuper = true)
@Data
public class TerraformModifyWithScriptsRequest extends TerraformModifyFromDirectoryRequest {
+
+ @Schema(description = "Id of the request.")
+ UUID taskId;
+
@NotNull
@Schema(description = "List of script files for modify requests deployed via scripts")
private List scripts;
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/models/response/TerraformResult.java b/src/main/java/org/eclipse/xpanse/terraform/boot/models/response/TerraformResult.java
index b934373..b3c4eb3 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/models/response/TerraformResult.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/models/response/TerraformResult.java
@@ -8,6 +8,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import java.util.Map;
+import java.util.UUID;
import lombok.Builder;
import lombok.Data;
@@ -18,8 +19,10 @@
@Builder
public class TerraformResult {
- @Schema(description = "defines if the command was successfully executed")
+ @Schema(description = "Id of the request")
+ UUID requestId;
@NotNull
+ @Schema(description = "defines if the command was successfully executed")
private boolean isCommandSuccessful;
@Schema(description = "stdout of the command returned as string.")
private String commandStdOutput;
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/ScriptsGitRepoManage.java b/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/ScriptsGitRepoManage.java
new file mode 100644
index 0000000..bfb2b7c
--- /dev/null
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/ScriptsGitRepoManage.java
@@ -0,0 +1,76 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * SPDX-FileCopyrightText: Huawei Inc.
+ */
+
+package org.eclipse.xpanse.terraform.boot.terraform.service;
+
+import java.io.File;
+import java.util.Objects;
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.jgit.api.CloneCommand;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.xpanse.terraform.boot.models.exceptions.GitRepoCloneException;
+import org.eclipse.xpanse.terraform.boot.models.request.git.TerraformScriptGitRepoDetails;
+import org.springframework.retry.annotation.Backoff;
+import org.springframework.retry.annotation.Recover;
+import org.springframework.retry.annotation.Retryable;
+import org.springframework.retry.support.RetrySynchronizationManager;
+import org.springframework.stereotype.Component;
+
+/**
+ * Bean to manage GIT clone.
+ */
+@Slf4j
+@Component
+public class ScriptsGitRepoManage {
+
+ /**
+ * Method to check out scripts from a GIT repo.
+ *
+ * @param workspace directory where the GIT clone must be executed.
+ * @param scriptsRepo directory inside the GIT repo where scripts are expected to be present.
+ */
+ @Retryable(retryFor = GitRepoCloneException.class,
+ maxAttemptsExpression = "${spring.retry.max-attempts}",
+ backoff = @Backoff(delayExpression = "${spring.retry.delay-millions}"))
+ public void checkoutScripts(String workspace, TerraformScriptGitRepoDetails scriptsRepo) {
+ log.info("Clone GIT repo to get the deployment scripts. Retry number: "
+ + Objects.requireNonNull(RetrySynchronizationManager.getContext()).getRetryCount());
+ File workspaceDirectory = new File(workspace);
+ FileRepositoryBuilder repositoryBuilder = new FileRepositoryBuilder();
+ repositoryBuilder.findGitDir(workspaceDirectory);
+ if (Objects.isNull(repositoryBuilder.getGitDir())) {
+ CloneCommand cloneCommand = new CloneCommand();
+ cloneCommand.setURI(scriptsRepo.getRepoUrl());
+ cloneCommand.setProgressMonitor(null);
+ cloneCommand.setDirectory(workspaceDirectory);
+ cloneCommand.setBranch(scriptsRepo.getBranch());
+ cloneCommand.setTimeout(20);
+ try (Git git = cloneCommand.call()) {
+ git.checkout();
+ } catch (GitAPIException e) {
+ String errorMsg =
+ String.format("Clone scripts form GIT repo error:%s", e.getMessage());
+ log.error(errorMsg);
+ throw new GitRepoCloneException(errorMsg);
+ }
+ } else {
+ log.info("Scripts repo is already cloned in the workspace.");
+ }
+ }
+
+
+ /**
+ * Recover method for checkoutScripts.
+ *
+ * @param e GitRepoCloneException
+ */
+ @Recover
+ public void recoverCheckoutScripts(GitRepoCloneException e) {
+ log.error("Retry exhausted. Throwing exception: " + e.getMessage());
+ throw e;
+ }
+}
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformDirectoryService.java b/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformDirectoryService.java
index 3dcaf7c..71e86cf 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformDirectoryService.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformDirectoryService.java
@@ -176,6 +176,7 @@ public TerraformResult modifyFromDirectory(TerraformModifyFromDirectoryRequest r
if (cleanWorkspaceAfterDeployment) {
deleteWorkspace(workspace);
}
+ terraformResult.setRequestId(request.getRequestId());
return terraformResult;
}
@@ -197,6 +198,7 @@ public TerraformResult destroyFromDirectory(TerraformDestroyFromDirectoryRequest
String workspace = executor.getModuleFullPath(moduleDirectory);
TerraformResult terraformResult = transSystemCmdResultToTerraformResult(result, workspace);
deleteWorkspace(workspace);
+ terraformResult.setRequestId(request.getRequestId());
return terraformResult;
}
@@ -230,6 +232,7 @@ public void asyncDeployWithScripts(TerraformAsyncDeployFromDirectoryRequest asyn
.importantFileContentMap(new HashMap<>())
.build();
}
+ result.setRequestId(asyncDeployRequest.getRequestId());
String url = asyncDeployRequest.getWebhookConfig().getUrl();
log.info("Deployment service complete, callback POST url:{}, requestBody:{}", url, result);
restTemplate.postForLocation(url, result);
@@ -253,6 +256,7 @@ public void asyncModifyWithScripts(TerraformAsyncModifyFromDirectoryRequest asyn
.importantFileContentMap(new HashMap<>())
.build();
}
+ result.setRequestId(asyncModifyRequest.getRequestId());
String url = asyncModifyRequest.getWebhookConfig().getUrl();
log.info("Deployment service complete, callback POST url:{}, requestBody:{}", url, result);
restTemplate.postForLocation(url, result);
@@ -276,7 +280,7 @@ public void asyncDestroyWithScripts(TerraformAsyncDestroyFromDirectoryRequest re
.importantFileContentMap(new HashMap<>())
.build();
}
-
+ result.setRequestId(request.getRequestId());
String url = request.getWebhookConfig().getUrl();
log.info("Destroy service complete, callback POST url:{}, requestBody:{}", url, result);
restTemplate.postForLocation(url, result);
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformGitRepoService.java b/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformGitRepoService.java
index 2eac012..a10b21d 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformGitRepoService.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformGitRepoService.java
@@ -13,15 +13,10 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
-import java.util.Objects;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.eclipse.jgit.api.CloneCommand;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.xpanse.terraform.boot.async.TaskConfiguration;
-import org.eclipse.xpanse.terraform.boot.models.exceptions.GitRepoCloneException;
import org.eclipse.xpanse.terraform.boot.models.exceptions.TerraformExecutorException;
import org.eclipse.xpanse.terraform.boot.models.plan.TerraformPlan;
import org.eclipse.xpanse.terraform.boot.models.plan.TerraformPlanFromGitRepoRequest;
@@ -50,16 +45,19 @@ public class TerraformGitRepoService extends TerraformDirectoryService {
private final RestTemplate restTemplate;
private final TerraformExecutor executor;
private final TerraformScriptsHelper terraformScriptsHelper;
+ private final ScriptsGitRepoManage scriptsGitRepoManage;
/**
* Constructor for TerraformGitRepoService bean.
*/
public TerraformGitRepoService(TerraformExecutor executor, RestTemplate restTemplate,
- TerraformScriptsHelper terraformScriptsHelper) {
+ TerraformScriptsHelper terraformScriptsHelper,
+ ScriptsGitRepoManage scriptsGitRepoManage) {
super(executor, restTemplate);
this.restTemplate = restTemplate;
this.executor = executor;
this.terraformScriptsHelper = terraformScriptsHelper;
+ this.scriptsGitRepoManage = scriptsGitRepoManage;
}
/**
@@ -133,6 +131,7 @@ public void asyncDeployFromGitRepo(TerraformAsyncDeployFromGitRepoRequest asyncD
.importantFileContentMap(new HashMap<>())
.build();
}
+ result.setRequestId(asyncDeployRequest.getRequestId());
String url = asyncDeployRequest.getWebhookConfig().getUrl();
log.info("Deployment service complete, callback POST url:{}, requestBody:{}", url, result);
restTemplate.postForLocation(url, result);
@@ -156,6 +155,7 @@ public void asyncModifyFromGitRepo(TerraformAsyncModifyFromGitRepoRequest asyncM
.importantFileContentMap(new HashMap<>())
.build();
}
+ result.setRequestId(asyncModifyRequest.getRequestId());
String url = asyncModifyRequest.getWebhookConfig().getUrl();
log.info("Modify service complete, callback POST url:{}, requestBody:{}", url, result);
restTemplate.postForLocation(url, result);
@@ -180,7 +180,7 @@ public void asyncDestroyFromGitRepo(TerraformAsyncDestroyFromGitRepoRequest requ
.importantFileContentMap(new HashMap<>())
.build();
}
-
+ result.setRequestId(request.getRequestId());
String url = request.getWebhookConfig().getUrl();
log.info("Destroy service complete, callback POST url:{}, requestBody:{}", url, result);
restTemplate.postForLocation(url, result);
@@ -190,7 +190,7 @@ private void buildDeployEnv(TerraformScriptGitRepoDetails terraformScriptGitRepo
UUID uuid) {
String workspace = executor.getModuleFullPath(uuid.toString());
buildWorkspace(workspace);
- extractScripts(workspace, terraformScriptGitRepoDetails);
+ scriptsGitRepoManage.checkoutScripts(workspace, terraformScriptGitRepoDetails);
}
private void buildModifyEnv(TerraformScriptGitRepoDetails terraformScriptGitRepoDetails,
@@ -229,37 +229,6 @@ private void buildWorkspace(String workspace) {
log.info("workspace create success, Working directory is " + ws.getAbsolutePath());
}
- private void extractScripts(String workspace, TerraformScriptGitRepoDetails scriptsRepo) {
- log.info("Cloning scripts from GIT repo:{} to workspace:{}", scriptsRepo.getRepoUrl(),
- workspace);
- File workspaceDirectory = new File(workspace);
- FileRepositoryBuilder repositoryBuilder = new FileRepositoryBuilder();
- repositoryBuilder.findGitDir(workspaceDirectory);
- if (Objects.isNull(repositoryBuilder.getGitDir())) {
- CloneCommand cloneCommand = new CloneCommand();
- cloneCommand.setURI(scriptsRepo.getRepoUrl());
- cloneCommand.setProgressMonitor(null);
- cloneCommand.setDirectory(workspaceDirectory);
- cloneCommand.setBranch(scriptsRepo.getBranch());
- boolean cloneSuccess = false;
- int retryCount = 0;
- String errMsg = "";
- while (!cloneSuccess && retryCount < MAX_RETRY_COUNT) {
- try {
- cloneCommand.call();
- cloneSuccess = true;
- } catch (GitAPIException e) {
- retryCount++;
- errMsg =
- String.format("Cloning scripts form GIT repo error:%s", e.getMessage());
- log.error(errMsg);
- }
- }
- if (!cloneSuccess) {
- throw new GitRepoCloneException(errMsg);
- }
- }
- }
private String getScriptsLocationInRepo(
TerraformScriptGitRepoDetails terraformScriptGitRepoDetails, UUID uuid) {
diff --git a/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformScriptsService.java b/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformScriptsService.java
index ada3bc5..7f28b17 100644
--- a/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformScriptsService.java
+++ b/src/main/java/org/eclipse/xpanse/terraform/boot/terraform/service/TerraformScriptsService.java
@@ -118,6 +118,7 @@ public void asyncDeployWithScripts(
.importantFileContentMap(new HashMap<>())
.build();
}
+ result.setRequestId(asyncDeployRequest.getRequestId());
String url = asyncDeployRequest.getWebhookConfig().getUrl();
log.info("Deployment service complete, callback POST url:{}, requestBody:{}", url, result);
restTemplate.postForLocation(url, result);
@@ -141,6 +142,7 @@ public void asyncModifyWithScripts(
.importantFileContentMap(new HashMap<>())
.build();
}
+ result.setRequestId(asyncModifyRequest.getRequestId());
String url = asyncModifyRequest.getWebhookConfig().getUrl();
log.info("Modify service complete, callback POST url:{}, requestBody:{}", url, result);
restTemplate.postForLocation(url, result);
@@ -164,7 +166,7 @@ public void asyncDestroyWithScripts(TerraformAsyncDestroyFromScriptsRequest requ
.importantFileContentMap(new HashMap<>())
.build();
}
-
+ result.setRequestId(request.getRequestId());
String url = request.getWebhookConfig().getUrl();
log.info("Destroy service complete, callback POST url:{}, requestBody:{}", url, result);
restTemplate.postForLocation(url, result);
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index da828fd..f54a89f 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -10,7 +10,7 @@
- %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} [%X{TASK_ID}]- %msg%n
+ %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} [%X{REQUEST_ID}]- %msg%n