Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

executors: multi-queue: enable client to submit heartbeat for multiple queues#52525

Merged
sanderginn merged 41 commits into
sginn/executor-multi-queue-heartbeat-endpointfrom
sginn/executor-multi-queue-heartbeat-client
May 31, 2023
Merged

executors: multi-queue: enable client to submit heartbeat for multiple queues#52525
sanderginn merged 41 commits into
sginn/executor-multi-queue-heartbeat-endpointfrom
sginn/executor-multi-queue-heartbeat-client

Conversation

@sanderginn

@sanderginn sanderginn commented May 26, 2023

Copy link
Copy Markdown
Contributor

Hierarchy:

Test plan

  • Unit tests
  • Demo: all the way in the parent PR

@cla-bot cla-bot Bot added the cla-signed label May 26, 2023
@sourcegraph-buildkite

sourcegraph-buildkite commented May 26, 2023

Copy link
Copy Markdown
Collaborator

Bundle size report 📦

Initial size Total size Async size Modules
0.00% (0.00 kb) 0.00% (+0.38 kb) 0.00% (+0.38 kb) 0.00% (0)

Look at the Statoscope report for a full comparison between the commits 41275d7 and 42be886 or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

@sanderginn sanderginn requested a review from a team May 26, 2023 19:43
@sanderginn sanderginn marked this pull request as ready for review May 30, 2023 14:15
@sourcegraph-bot

sourcegraph-bot commented May 30, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 80efc59...c36c55e.

Notify File(s)
@BolajiOlajide client/web/src/enterprise/batches/batch-spec/batch-spec.mock.ts
client/web/src/enterprise/batches/batch-spec/execute/backend.ts
@courier-new client/web/src/enterprise/batches/batch-spec/batch-spec.mock.ts
client/web/src/enterprise/batches/batch-spec/execute/backend.ts
@efritz enterprise/cmd/executor/internal/apiclient/queue/client.go
enterprise/cmd/executor/internal/apiclient/queue/client_test.go
enterprise/cmd/frontend/internal/executorqueue/handler/BUILD.bazel
enterprise/cmd/frontend/internal/executorqueue/handler/multihandler.go
enterprise/cmd/frontend/internal/executorqueue/handler/multihandler_test.go
enterprise/internal/executor/types/http.go
enterprise/internal/executor/types/http_test.go
@eseliger client/web/src/enterprise/batches/batch-spec/batch-spec.mock.ts
client/web/src/enterprise/batches/batch-spec/execute/backend.ts
enterprise/cmd/frontend/internal/executorqueue/handler/BUILD.bazel
enterprise/cmd/frontend/internal/executorqueue/handler/multihandler.go
enterprise/cmd/frontend/internal/executorqueue/handler/multihandler_test.go

@sourcegraph-bot

sourcegraph-bot commented May 30, 2023

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

@Piszmog Piszmog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, just a couple items

Comment thread enterprise/internal/executor/types/http.go
Comment thread enterprise/cmd/executor/internal/apiclient/queue/client.go
Comment thread enterprise/cmd/executor/internal/apiclient/queue/client.go Outdated
_, body, err := c.client.Do(ctx, req)
if err != nil {
return nil, nil, err
_, body, doErr := c.client.Do(ctx, req)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the reason for having all the errors be uniquely named?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I noticed the observability routine using the named return variable pointer, so it seems to me that reusing that variable would make the observation kind of pointless?

Of course that would only ask for one other error. Should the observation receive its own error?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yea, the named returns and observability are weird.. I had to play around with an example to understand better. Take the below example

func Foo(x, y bool) (s string, err error) {
	defer func() {
		fmt.Println(s, err)
	}()
	if x {
		err = fmt.Errorf("failed")
		return "", err
	}
	if y {
		return "foo", nil
	}
	return "bar", nil
}

When the defer function runs, the s and err will be set to the values in the return statement. So even though I set err to a value (overriding the named err), the return statement still sets err to the same thing.

If I update the code to,

	if x {
		err = fmt.Errorf("failed")
		return "", fmt.Errorf("failed again")
	}

err in the defer will be "failed again" even though I am setting it explicitly.

So by naming it something else and returning the new named error, will still set the observability error to it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for that explanation, makes it more clear 👍

I'll change back to a single err in the parent PR then

Comment thread enterprise/internal/executor/types/http.go
@sanderginn sanderginn merged commit 51a606c into sginn/executor-multi-queue-heartbeat-endpoint May 31, 2023
@sanderginn sanderginn deleted the sginn/executor-multi-queue-heartbeat-client branch May 31, 2023 17:21
sanderginn referenced this pull request Jun 4, 2023
…2016)

- Closes https://github.com/sourcegraph/sourcegraph/issues/50614

Depends on the following issues:
- https://github.com/sourcegraph/sourcegraph/issues/50616
  - Merged in https://github.com/sourcegraph/sourcegraph/pull/52020
- https://github.com/sourcegraph/sourcegraph/issues/51656
  - Merged in https://github.com/sourcegraph/sourcegraph/pull/52381
- https://github.com/sourcegraph/sourcegraph/issues/51658
  - Merged in  https://github.com/sourcegraph/sourcegraph/pull/52525

Due to the dependency on the work listed above, all PRs were ultimately
merged into this branch, so the client side implementation got a little
bit messy to review, for which I apologize. The initial intent of this
PR, closing #50614, was reviewed before the merges occurred.

## Demos

### Scenario 1: old Sourcegraph version, new executor version
#### batches, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/6d325326-d4f5-4e6f-a5e0-0918dbde07bf

#### codeintel, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/ff3a87db-ef07-4221-a159-73b93a6ae55b

### Scenario 2: new Sourcegraph version, old executor version
#### batches, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/c66a9b9f-b745-4abc-bf87-9077dd5f2959

#### codeintel, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/785d7f34-630f-4c2a-abb6-82ca3b896813

### Scenario 3: new Sourcegraph version, new executor version
#### batches, single queue 

https://github.com/sourcegraph/sourcegraph/assets/2979513/69c5c06b-ea1c-47f7-9196-e3f108794493

#### codeintel, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/4e791d98-06cd-4fa7-93dd-81be0a73c744

#### batches + codeintel in parallel, multi queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/004608dd-f98c-4305-aeb3-a01444c12224





## Initial PR description (enable client to dequeue from multiple
queues)
This PR updates the client's `Dequeue` method to dequeue from multiple
queues. It's backwards compatible with single-queue configurations. The
field `Job.Queue` is only set when dequeuing from the general `/dequeue`
endpoint, so the job `MarkXxx` methods default to single-queue behaviour
if the job does not specify a queue name.

Unrelated to the linked issue, the multi-handler will log and return no
content early in the event of an empty queue list in a dequeue request
(although this should never occur).

## Test plan
- [x] Unit tests
- [x] Local testing
- [x] Dogfood testing
- [x] Demo

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
ErikaRS referenced this pull request Jun 22, 2023
…2016)

- Closes https://github.com/sourcegraph/sourcegraph/issues/50614

Depends on the following issues:
- https://github.com/sourcegraph/sourcegraph/issues/50616
  - Merged in https://github.com/sourcegraph/sourcegraph/pull/52020
- https://github.com/sourcegraph/sourcegraph/issues/51656
  - Merged in https://github.com/sourcegraph/sourcegraph/pull/52381
- https://github.com/sourcegraph/sourcegraph/issues/51658
  - Merged in  https://github.com/sourcegraph/sourcegraph/pull/52525

Due to the dependency on the work listed above, all PRs were ultimately
merged into this branch, so the client side implementation got a little
bit messy to review, for which I apologize. The initial intent of this
PR, closing #50614, was reviewed before the merges occurred.

## Demos

### Scenario 1: old Sourcegraph version, new executor version
#### batches, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/6d325326-d4f5-4e6f-a5e0-0918dbde07bf

#### codeintel, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/ff3a87db-ef07-4221-a159-73b93a6ae55b

### Scenario 2: new Sourcegraph version, old executor version
#### batches, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/c66a9b9f-b745-4abc-bf87-9077dd5f2959

#### codeintel, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/785d7f34-630f-4c2a-abb6-82ca3b896813

### Scenario 3: new Sourcegraph version, new executor version
#### batches, single queue 

https://github.com/sourcegraph/sourcegraph/assets/2979513/69c5c06b-ea1c-47f7-9196-e3f108794493

#### codeintel, single queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/4e791d98-06cd-4fa7-93dd-81be0a73c744

#### batches + codeintel in parallel, multi queue

https://github.com/sourcegraph/sourcegraph/assets/2979513/004608dd-f98c-4305-aeb3-a01444c12224





## Initial PR description (enable client to dequeue from multiple
queues)
This PR updates the client's `Dequeue` method to dequeue from multiple
queues. It's backwards compatible with single-queue configurations. The
field `Job.Queue` is only set when dequeuing from the general `/dequeue`
endpoint, so the job `MarkXxx` methods default to single-queue behaviour
if the job does not specify a queue name.

Unrelated to the linked issue, the multi-handler will log and return no
content early in the event of an empty queue list in a dequeue request
(although this should never occur).

## Test plan
- [x] Unit tests
- [x] Local testing
- [x] Dogfood testing
- [x] Demo

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants