Skip to content

rpc: answer GetWorkload for a missing workload with codes.NotFound - #757

Merged
CMGS merged 1 commit into
masterfrom
fix/getworkload-notfound
Sep 29, 2026
Merged

CMGS merged 1 commit into
masterfrom
fix/getworkload-notfound

Conversation

@CMGS

@CMGS CMGS commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #756. This lets clients recognise a missing workload from the gRPC status instead of from the error text.

GetWorkload returns codes.NotFound

  • When the error chain contains types.ErrWorkloadNotExists, GetWorkload now answers codes.NotFound. Every other failure keeps the per-RPC code GetWorkload (1051).
  • Before this change, agent's WorkloadExists had to string-match bad \Count` valueorworkload not existsin the status message. The companion agent PR switches it tostatus.Code(err) == codes.NotFound`.

The ErrInvaildCount mark from #756 is removed

  • An etcd read that matches zero keys now wraps only ErrKeyNotFound.
  • The store: report a missing etcd key as key not found #756 description said resource-extend's nodestore.CheckAbsent needed the mark. That was wrong. nodestore reads through the raw etcd client and raises its own ErrNodeNotExists on zero matches, so it never sees core's GetOne errors.
  • A search of the projecteru2 org for ErrInvaildCount finds no other consumer of core's not-found error. The companion resource-extend PR also cleans up its side.

Deploy order

  • Roll out core before the new agent.
  • An old agent against a new core keeps working, because the message still contains workload not exists.
  • A new agent against an old core would see the custom code and report the workload as existing.

Tests

  • TestGetWorkloadReportsAMissingWorkloadAsNotFound checks that a missing workload maps to codes.NotFound and that any other error keeps code 1051.
  • The etcd missing-key test now asserts the error is not ErrInvaildCount.

Gates (GOWORK=off)

  • make fmt-check passes.
  • make lint reports 0 issues on linux and darwin.
  • asl is clean on linux and darwin.
  • make test and make build pass.

Clients had to string-match the error text to tell a missing workload from a failure (agent's WorkloadExists). GetWorkload now returns the standard NotFound code when the error chain holds ErrWorkloadNotExists; other failures keep the per-RPC code. The ErrInvaildCount mark on the etcd not-found error added in #756 is dropped: nothing reads it (resource-extend's nodestore uses the raw etcd client and its own ErrNodeNotExists).
@CMGS
CMGS merged commit 6dc46b2 into master Sep 29, 2026
7 checks passed
@CMGS
CMGS deleted the fix/getworkload-notfound branch September 29, 2026 07:39
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.

1 participant