Skip to content

Commit

Permalink
chore: stability pr for changes (#35911)
Browse files Browse the repository at this point in the history
## Description
- Changes to put blocking calls on the bounded elastic thread.
- This Pr has changes to test.
- commit
- Status
- branch
- delete branch
- List branch 
- checkout
- checkout remote
- merge status
- merge

Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`

## Automation

/ok-to-test tags="@tag.Git"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]  
> If you modify the content in this section, you are likely to disrupt
the CI result for your PR.

<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Improved performance and responsiveness when saving applications to
Git repositories by optimizing the execution flow.
- Enhanced clarity and control in the application push process to Git,
ensuring better maintainability.

- **Bug Fixes**
- Addressed potential threading issues by ensuring operations run on the
appropriate scheduler.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
sondermanish authored Aug 30, 2024
1 parent abce472 commit 4b89c1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,8 @@ public Mono<String> pushApplication(
// open the repo
Path baseRepoPath = createRepoPath(repoSuffix);

return gitConfig
.getIsAtomicPushAllowed()
.flatMap(isAtomicPushAllowed -> {
return Mono.using(
return gitConfig.getIsAtomicPushAllowed().flatMap(isAtomicPushAllowed -> {
return Mono.using(
() -> Git.open(baseRepoPath.toFile()),
git -> Mono.fromCallable(() -> {
log.debug(Thread.currentThread().getName() + ": pushing changes to remote "
Expand Down Expand Up @@ -265,9 +263,12 @@ public Mono<String> pushApplication(
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpan.FS_PUSH)
.tap(Micrometer.observation(observationRegistry)),
Git::close);
})
.subscribeOn(scheduler);
Git::close)
// this subscribeOn on is required because Mono.using
// is not deferring the execution of push and for that reason it runs on the
// lettuce-nioEventLoop thread instead of boundedElastic
.subscribeOn(scheduler);
});
}

/** Clone the repo to the file path : container-volume/orgId/defaultAppId/repo/<Data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.springframework.stereotype.Component;
import reactor.core.Exceptions;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

import java.io.IOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -93,7 +94,9 @@ public Mono<Path> saveArtifactToLocalRepo(

// Save application to git repo
try {
return fileUtils.saveApplicationToGitRepo(baseRepoSuffix, artifactGitReference, branchName);
return fileUtils
.saveApplicationToGitRepo(baseRepoSuffix, artifactGitReference, branchName)
.subscribeOn(Schedulers.boundedElastic());
} catch (IOException | GitAPIException e) {
log.error("Error occurred while saving files to local git repo: ", e);
throw Exceptions.propagate(e);
Expand Down

0 comments on commit 4b89c1c

Please sign in to comment.