Skip to content

Commit

Permalink
fix: adding debugging points to check the thread issue in rsync
Browse files Browse the repository at this point in the history
  • Loading branch information
soumyadip007 authored Nov 12, 2024
1 parent 0626afa commit 37f5db6
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/java/io/spaship/sidecar/services/RequestProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,23 @@ private void validatePropertyFields() {
LOG.debug("field validation end");
}

private boolean rsyncInProgress = false;

public Uni<OperationResponse> handleFileUpload(FormData formData) {
if (rsyncInProgress) {
LOG.info("rsync is already in progress for this operation, skipping.");
}

rsyncInProgress = true;

return Uni.createFrom()
.item(() -> processFile(formData))
.runSubscriptionOn(executor);
}

// todo break into smaller methods, get rid of imperative code
private OperationResponse processFile(FormData formData) {
LOG.info("Processing file for formData: {}", formData);

OperationResponse.OperationResponseBuilder opsBuilderCommon = OperationResponse.builder()
.environment(environment)
Expand All @@ -96,11 +105,14 @@ private OperationResponse processFile(FormData formData) {

// Unzip the incoming dist file and return the location of the unzipped file
var zipFilePath = formData.getfilePath().toString();
LOG.info("zipFilePath : {}", zipFilePath);
String unZippedPath = unzipDist(zipFilePath);
LOG.info("unZippedPath : {}", unZippedPath);
if (unZippedPath == null)
return opsBuilderCommon.status(0)
.errorMessage("something went wrong, null pointer exception, check console for stacktrace").build();


//extract context path and spaship meta file
var spashipMeta = extractSpashipMeta(unZippedPath);
if (Objects.isNull(spashipMeta))
Expand Down Expand Up @@ -137,7 +149,7 @@ private OperationResponse handleFileOps(OperationResponse.OperationResponseBuild
var source = sourcePath.toString();
LOG.info("source : {}", source);
var destination = destinationPath.toString();
LOG.info("destination : {}", source);
LOG.info("destination : {}", destinationPath);
source = formatSourceDirName(source);
LOG.info("formatSourceDirName : {}", source);
rsync(source, destination);
Expand Down Expand Up @@ -169,7 +181,12 @@ private OperationResponse handleFileOps(OperationResponse.OperationResponseBuild
private void rsync(String source, String destination) throws IOException, InterruptedException {
// do not use `-a` as it tries to preserve file ownership and permissions leading to permission issues
LOG.info("rsync process started");
ProcessBuilder processBuilder = new ProcessBuilder("rsync", "-rlS", "--delete", source, destination);
ProcessBuilder processBuilder = new ProcessBuilder(
"rsync",
"-rlS",
"--delete",
source,
destination);
LOG.info("ProcessBuilder initialized");
Process process = processBuilder.start();
LOG.info("Process started");
Expand Down

0 comments on commit 37f5db6

Please sign in to comment.