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

[Prism] Connect Web UI cancel requests with backend #31028

Merged

Conversation

damondouglas
Copy link
Contributor

@damondouglas damondouglas commented Apr 17, 2024

About

This PR addresses #29669 connecting Web UI cancel requests with the backend Job Management server.

Changes

  • Fixes loading of CANCELED state for previously canceled Jobs
  • Triggers Web request from UI to backend on cancel clicks
  • Adds to /job/cancel http handler more detailed error reporting

Testing

In addition to go test ..., manual testing of this PR was as follows:

  1. Run prism via go run ./go/cmd/prism
  2. Execute example via go run ./go/examples/large_wordcount --output=/tmp/large_wordcount/out --runner=universal --endpoint=localhost:8073 --environment_type=LOOPBACK
  3. Validate job display in web console at http://localhost:8074/job/job-001 with state RUNNING
  4. Click Cancel button
  5. Validate cancel-related log messages populate in console after filtering for debug level logs
  6. Validate Cancel button disabled with Job state change from RUNNING to CANCELLING
  7. On reload of http://localhost:8074/job/job-001, validate state is CANCELED
  8. Navigating to http://localhost:8074 shows job-001 in Jobs list as CANCELED

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@damondouglas damondouglas changed the title Connect Web UI cancel requests with backend [PRISM] Connect Web UI cancel requests with backend Apr 17, 2024
@damondouglas damondouglas marked this pull request as ready for review April 17, 2024 22:55
Copy link
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @jrmccluskey for label go.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@damondouglas damondouglas changed the title [PRISM] Connect Web UI cancel requests with backend [Prism] Connect Web UI cancel requests with backend Apr 18, 2024
Copy link
Contributor

@lostluck lostluck left a comment

Choose a reason for hiding this comment

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

LGTM, though I do have one comment.

@@ -243,8 +243,8 @@ func (s *Server) Run(ctx context.Context, req *jobpb.RunJobRequest) (*jobpb.RunJ
// Otherwise, returns nil if Job does not exist or the Job's existing state as part of the CancelJobResponse.
func (s *Server) Cancel(_ context.Context, req *jobpb.CancelJobRequest) (*jobpb.CancelJobResponse, error) {
s.mu.Lock()
defer s.mu.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

deferring unlock isn't a straightforward universal good.

So this locks the whole server's shared state until the Cancel is complete, while it's doing the per job changes. You would at best want to lock the job's state, not serialize everything the server is handling.

The various job state fields should be locked through a job specific lock, which I suppose might be job.streamCond.L. State in particular is an atomic to avoid needing a full job lock for every read. With cancelling that might need to change however.

The Prepare method definitely has some overzealous locking (it's doing a lot of work, but not a lot of mixing with the server side state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now it makes sense to me that state is an atomic.Value and thus I didn't need to put a lock on the whole service. I only lock/unlock when acquiring the Job just like all the other methods.

@damondouglas damondouglas merged commit ac83276 into apache:master May 2, 2024
7 checks passed
@damondouglas damondouglas deleted the prism-cancel-web-to-backend branch May 2, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants