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

[CDAP-20683] Propogate logs from System Worker to Pipeline Logs #15284

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

dj-smart
Copy link
Contributor

@dj-smart dj-smart commented Aug 9, 2023

JIRA: CDAP-20683

The StartupTask timeout logs have been propagated to pipeline logs, as can be seen in this image:
image

@dj-smart dj-smart marked this pull request as draft August 9, 2023 11:51
@dj-smart dj-smart self-assigned this Aug 9, 2023
@dj-smart dj-smart requested a review from masoud-io August 9, 2023 11:52
@dj-smart dj-smart changed the title Propogate logs from System Worker to Pipeline Logs [CDAP-20683] Propogate logs from System Worker to Pipeline Logs Aug 11, 2023
@dj-smart dj-smart requested a review from tivv August 11, 2023 13:33
@@ -138,7 +138,7 @@ public final RuntimeInfo run(ProgramDescriptor programDescriptor, ProgramOptions
} catch (Exception e) {
controller.failed(e);
programStateWriter.error(programRunId, e);
LOG.error("Exception while trying to run program run {}", programRunId, e);
LOG.error("Exception while trying to run program with runID {}", programRunId, e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need this change? program run is a proper term

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I misinterpreted term "program run", so I changed it when I came across it. Will revert it back.

@@ -649,6 +653,7 @@ public TwillController create(@Nullable Callable<Void> startupTask, long timeout
}
programStateWriter.error(programRunId, throwable);
}
restoreContext.cancel();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use try..finally to ensure context is always properly cancelled, even if exception is thrown out.

BTW: It's a perfect case for try with resources. We just need to either make Cancellable extend AutoClosable or at least setLoggingContext return an AutoClosable result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored the code to use try-with-resources. PTAL.

* @param loggingContext context to set
* @return Autocloseable that can be used to revert the logging context and MDC Map to its original
*/
public static AutoCloseable restoreLoggingContext(LoggingContext loggingContext) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks strange. Usually try with resource should return a resource. Any cleanup happens on exit of the block. My recommendation: is to create an interface that implements both Cancelable and AutoClosable and make the setLoggingContext return it

Copy link
Contributor Author

@dj-smart dj-smart Apr 23, 2024

Choose a reason for hiding this comment

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

I have made changes based on your suggestion. Let me know if this is in line with the expectation.

@dj-smart dj-smart marked this pull request as ready for review April 23, 2024 15:44
Copy link
Contributor

@tivv tivv left a comment

Choose a reason for hiding this comment

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

LGTM with small comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Triggers github actions build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants