-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-7668] Add GetPipeline method to gRPC JobService #8977
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
Conversation
|
R: @angoenka |
| responseObserver.onCompleted(); | ||
| } catch (Exception e) { | ||
| String errMessage = | ||
| String.format("Encountered Unexpected Exception for Invocation %s", invocationId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| String.format("Encountered Unexpected Exception for Invocation %s", invocationId); | |
| String.format("Encountered unexpected exception for invocation %s", invocationId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this exact phrase (including capitalization) is present in 6 other messages in this file.
| } catch (Exception e) { | ||
| String errMessage = | ||
| String.format("Encountered Unexpected Exception for Invocation %s", invocationId); | ||
| LOG.error(errMessage, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: SLF4J allows you to do
LOG.error(Encountered unexpected exception for invocation {}", invocationId, e);
instead of using String.format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this pattern is repeated in 5 other places in this file. I was just trying to stay consistent.
If you don't like the style used in the file, I would recommend addressing them all at once in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me.
| String invocationId = request.getJobId(); | ||
| try { | ||
| JobInvocation invocation = getInvocation(invocationId); | ||
| RunnerApi.Pipeline pipeline = invocation.getPipeline(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't handling the NOT_FOUND case as described in the API contract in the proto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied the API contract from getState, and handled the error case in exactly the same way, so if it's not correct for getPipeline, that's because it's not correct for getState or the other 4 methods that use this same pattern.
In case of error it's responding with the exception:
catch (Exception e) {
...
responseObserver.onError(Status.INTERNAL.withCause(e).asException());
}I'm new to Java, so I just assumed this was responding with NOT_FOUND in the case that getInvocation(invocationId) failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are handling the exception but are doing it incorrectly since getInvocation() throws a Status.NOT_FOUND exception but since we are catching it and then rethrowing it as an INTERNAL exception we are losing the NOT_FOUND.
The logic needs to be updated to be:
try {
... do stuff ...
} catch (StatusException e) {
responseObserver.onError(e);
} catch (Exception e) {
... original exception handling that converts the status to INTERNAL ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll make a separate issue in Jira for this, since it's technically a breaking change, and I'll follow up with another PR with your suggestion, and the style fixes (if you don't mind me lumping them together).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider it a bugfix since contractually we said we were going to do X and did Y and not a breaking change.
I'm fine with you lumping it in or not.
lukecwik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add tests to InMemoryJobServiceTest using the mocks that exist there or migrate to spinning up a test gRPC service/client using an inprocess servier/client as described in https://stackoverflow.com/questions/37552468/how-to-unit-test-grpc-java-server-implementation-functions
|
Added tests. |
|
I think this PR is ready to go. I'm not sure if the Python PreCommit test failure is real or not. I clicked on details but Jenkins says there are no failures. |
|
Run Python PreCommit |
|
|
||
| def GetPipeline(self, request, context=None): | ||
| return beam_job_api_pb2.GetJobPipelineResponse( | ||
| state=self._jobs[request.job_id]._pipeline_proto) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| state=self._jobs[request.job_id]._pipeline_proto) | |
| pipeline=self._jobs[request.job_id]._pipeline_proto) |
|
I merged this with a fixup addressing my last comment: 05dba6a |
|
thanks! |
|
I created an issue for the proto contract: https://issues.apache.org/jira/browse/BEAM-7720 |
|
Note, I just realized that I did not update the go stubs... Is there a reason that the generated code is committed to the repo for go, but not for python and java? |
|
It may be because of how Go modules have dependencies on other Go modules and since they are statically compiled it may require those Go modules to perform the proto generation on our behalf to perform the compilation but I'm not exactly certain. @lostluck any details you can provide here? |
|
Nit: beam isn't yet using Go Modules. Go calls the unit of dependency packages. Conventionally, the go tooling doesn't do generation at compile time. The main reason is there are ample tools to do that externally to the go tooling (eg. Gradle, bazel, make, etc) that any end user can set that up should they desire it. The impedance mismatch is that beam is a mid-level library. So the proto code needs to be generated with We haven't been rigorous about what version of protoc and the go proto packages to use, hence the piles of differences. As long as the external proto API doesn't change in a backwards incompatible way and the integration tests against flink and spark work, I'm not bothered about what the generated code looks like until we can ensure people can use consistent versions to generate the code, with Go Modules. |
This adds a
GetPipelinemethod to the gRPCJobServiceand implements it forInMemoryJobService. The method is quite similar to the existingGetStatemethod in design/behavior.As described in the Jira issue, I see this feature as a useful first step towards making the Job API capable of serving as a backend to a web app for submitting, viewing, and monitoring Beam jobs. The next step after this PR would be to add a
GetJobsmethod that sends a summary of all of the active jobs and their ids.Remaining issues:
protocI need to use withgo generate: 3.6 and 3.7 produced significant diffs, with a lot of style changes, so I assume it's something older. Any help here would be greatly appreciated.portable_runner_testseem to be largely starting the service and shutting it down in different ways, without actually running any test methods. Basically what I'm saying is I don't see a clear framework for testing RPC methods in any language, but feel free to point me in the right direction.Post-Commit Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.