Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix attempt output persistence for schedulerv2 #9764

Merged
merged 4 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ private void reportSuccess(final ConnectionUpdaterInput connectionUpdaterInput)
private void reportFailure(final ConnectionUpdaterInput connectionUpdaterInput) {
jobCreationAndStatusUpdateActivity.attemptFailure(new AttemptFailureInput(
connectionUpdaterInput.getJobId(),
connectionUpdaterInput.getAttemptId()));
connectionUpdaterInput.getAttemptId(),
standardSyncOutput.orElse(null)));

final int maxAttempt = configFetchActivity.getMaxAttempt().getMaxAttempt();
final int attemptNumber = connectionUpdaterInput.getAttemptNumber();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class AttemptFailureInput {

private long jobId;
private int attemptId;
private StandardSyncOutput standardSyncOutput;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ public void jobFailure(final JobFailureInput input) {
public void attemptFailure(final AttemptFailureInput input) {
try {
jobPersistence.failAttempt(input.getJobId(), input.getAttemptId());
final Job job = jobPersistence.getJob(input.getJobId());

if (input.getStandardSyncOutput() != null) {
final JobOutput jobOutput = new JobOutput().withSync(input.getStandardSyncOutput());
jobPersistence.writeOutput(input.getJobId(), input.getAttemptId(), jobOutput);
} else {
log.warn("The job {} doesn't have an input for the attempt {}", input.getJobId(), input.getAttemptId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be "doesn't have any output" instead of "doesn't have an input"

}
} catch (final IOException e) {
throw new RetryableException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void setJobFailureWrapException() throws IOException {

@Test
public void setAttemptFailure() throws IOException {
jobCreationAndStatusUpdateActivity.attemptFailure(new AttemptFailureInput(JOB_ID, ATTEMPT_ID));
jobCreationAndStatusUpdateActivity.attemptFailure(new AttemptFailureInput(JOB_ID, ATTEMPT_ID, null));

Mockito.verify(mJobPersistence).failAttempt(JOB_ID, ATTEMPT_ID);
}
Expand All @@ -195,7 +195,7 @@ public void setAttemptFailureWrapException() throws IOException {
Mockito.doThrow(new IOException())
.when(mJobPersistence).failAttempt(JOB_ID, ATTEMPT_ID);

Assertions.assertThatThrownBy(() -> jobCreationAndStatusUpdateActivity.attemptFailure(new AttemptFailureInput(JOB_ID, ATTEMPT_ID)))
Assertions.assertThatThrownBy(() -> jobCreationAndStatusUpdateActivity.attemptFailure(new AttemptFailureInput(JOB_ID, ATTEMPT_ID, null)))
.isInstanceOf(RetryableException.class)
.hasCauseInstanceOf(IOException.class);
}
Expand Down