Skip to content

Implement dynamic worker-type queue routing for heavy targets - #364

Merged
jamespitt merged 4 commits into
please-build:masterfrom
jamespitt:heavymettle
Oct 23, 2026
Merged

jamespitt merged 4 commits into
please-build:masterfrom
jamespitt:heavymettle

Conversation

@jamespitt

Copy link
Copy Markdown
Contributor

This adds support for passing multiple request queues to the Mettle API server, and dynamically routing incoming ExecuteRequests based on the 'worker-type' platform property found in the Action digest. Unrouted or missing properties safely fall back to the standard queue.

Includes full unit test coverage for the new routing logic in api_test.go.

@peterebden peterebden left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice thanks!

Comment thread mettle/api/api.go Outdated
Comment thread mettle/api/api.go Outdated
Comment on lines +400 to +401
log.Warningf("Failed to read action for worker-type routing, falling back to standard: %s", err)
topic = s.requests[defaultRequestQueue]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I expect if we get here the action is doomed, so you could just bail. This is fine too though.

Comment thread mettle/api/api.go Outdated
log.Warningf("Failed to read action for worker-type routing, falling back to standard: %s", err)
topic = s.requests[defaultRequestQueue]
} else if t, ok := s.requests[workerType]; ok {
log.Infof("Routing action %s to worker-type queue: %s", req.ActionDigest.Hash, workerType)

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.

We probably want to make these debug logs, there will be lots of them

Comment thread mettle/api/api.go Outdated
defer cancel()
if err := s.requests.Send(ctx, &pubsub.Message{

workerType, err := s.getWorkerType(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.

We have a validatePlatform() function on line 342. Is it worth combining these to keep them in line. Currently if we have multiple worker queues and don't add the worker-type to allowed platform properties we will fail before we get here

Comment thread ChangeLog
@jamespitt
jamespitt force-pushed the heavymettle branch 3 times, most recently from 9918ef7 to c1881bf Compare October 19, 2026 09:08

@peterebden peterebden left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Also just spotted the branch name 🤘

@jamespitt
jamespitt force-pushed the heavymettle branch 2 times, most recently from 06cda8d to f899069 Compare October 23, 2026 13:34
This adds support for passing multiple request queues to the Mettle API server, and dynamically routing incoming ExecuteRequests based on the 'worker-type' platform property found in the Action digest. Unrouted or missing properties safely fall back to the standard queue.

Includes full unit test coverage for the new routing logic in api_test.go.
Comment thread mettle/api/api.go
@jamespitt jamespitt closed this Oct 23, 2026
@jamespitt jamespitt reopened this Oct 23, 2026
@jamespitt
jamespitt merged commit 6728b6e into please-build:master Oct 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants