Conversation
Updated edge-api spec with removed deprecated service discovery endpoint.
PR SummaryMedium Risk Overview Reviewed by Cursor Bugbot for commit d206ad5. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d206ad58ef
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // MemTotal Total memory in bytes | ||
| MemTotal int64 `json:"mem_total"` |
There was a problem hiding this comment.
Keep mem_cache on edge SandboxMetric
Removing mem_cache from edge.SandboxMetric breaks existing callers that still read this field when adapting edge metrics (for example packages/api/internal/clusters/resources_remote.go maps m.MemCache and v.MemCache). After this change, building the API module fails with an undefined-field error, so the edge spec/client update is not compatible with current consumers.
Useful? React with 👍 / 👎.
| @@ -251,9 +248,6 @@ type SandboxMetric struct { | |||
| // DiskUsed Used disk space in bytes | |||
There was a problem hiding this comment.
Compilation break: Removing mem_cache from edgeapi.SandboxMetric will cause a build failure in packages/api/internal/clusters/resources_remote.go, which reads m.MemCache (line 69) and v.MemCache (line 102) off values of type edgeapi.SandboxMetric. The field no longer exists in the generated struct after this PR, so the api package will not compile. The internal spec/openapi.yml and its generated api.gen.go still declare memCache as a required field on SandboxMetric, so the fix needs to either keep mem_cache in the edge spec (with the edge populating it), or remove it from the public spec and update resources_remote.go accordingly.
| // DiskUsed Used disk space in bytes | ||
| DiskUsed int64 `json:"disk_used"` | ||
|
|
||
| // MemCache Cached memory (page cache) in bytes | ||
| MemCache int64 `json:"mem_cache"` | ||
|
|
||
| // MemTotal Total memory in bytes | ||
| MemTotal int64 `json:"mem_total"` | ||
|
|
There was a problem hiding this comment.
🔴 Removing the MemCache field from edge.SandboxMetric (here in generated.go and in spec/openapi-edge.yml) breaks compilation of the api package: packages/api/internal/clusters/resources_remote.go still reads this field at line 69 (MemCache: m.MemCache, where m is an edgeapi.SandboxMetric returned by V1SandboxMetricsWithResponse) and at line 102 (MemCache: v.MemCache, where v is an edgeapi.SandboxMetric from V1SandboxesMetricsWithResponse). go build ./packages/api/internal/clusters/... fails with m.MemCache undefined (type edge.SandboxMetric has no field or method MemCache). Either keep mem_cache in the edge spec, or drop the two MemCache assignments in resources_remote.go (and also drop MemCache from the public api.SandboxMetric schema for consistency).
Extended reasoning...
What the bug is
This PR drops the MemCache field from the edgeapi.SandboxMetric struct (in packages/shared/pkg/http/edge/generated.go lines 248-253) and the corresponding mem_cache property from spec/openapi-edge.yml. However, the API service still reads MemCache from values of that exact type in packages/api/internal/clusters/resources_remote.go, so the api package will no longer compile.
The specific code path
In packages/api/internal/clusters/resources_remote.go:
GetSandboxMetrics(line 69):raw := *res.JSON200whererescomes fromV1SandboxMetricsWithResponse, sorawis[]edgeapi.SandboxMetric. The loopfor i, m := range rawthen constructsapi.SandboxMetric{ ..., MemCache: m.MemCache, ... }.GetSandboxesMetrics(line 102):raw := *res.JSON200fromV1SandboxesMetricsWithResponse, soraw.Sandboxesismap[string]edgeapi.SandboxMetric. The loopfor sbxID, v := range raw.Sandboxesconstructsapi.SandboxMetric{ ..., MemCache: v.MemCache, ... }.
Both reads target the field this PR deletes. The destination api.SandboxMetric.MemCache still exists in packages/api/internal/api/api.gen.go, so the api schema is unchanged — it's only the source field on edgeapi.SandboxMetric that is gone.
Why existing code doesn't prevent it
The cursor[bot] summary said "no in-repo references were found" for the removed surface area, but it missed these two field reads. They live in a sibling Go package (packages/api/internal/clusters) that consumes the edge client; a name-grep for MemCache wouldn't have ruled out a struct-field read on the edge type. The only other place that uses MemCache is resources_local.go, but that one reads from the unrelated clickhouse.Metrics type and still compiles fine.
Impact
Hard build break for the api service. The api package won't compile, blocking the whole binary, which means the api can't be built or shipped while consuming a remote (BYOC) cluster path. This is a merge blocker, not a runtime quirk.
Step-by-step proof
- Apply this PR (
MemCacheremoved fromedge.SandboxMetricin generated.go andmem_cacheremoved from openapi-edge.yml). - Run
go build ./packages/api/internal/clusters/.... - Compiler emits:
(Multiple verifiers reproduced this exact output.)
packages/api/internal/clusters/resources_remote.go:69:21: m.MemCache undefined (type edge.SandboxMetric has no field or method MemCache) packages/api/internal/clusters/resources_remote.go:102:21: v.MemCache undefined (type edge.SandboxMetric has no field or method MemCache)
How to fix
Two clean options:
- Keep
mem_cachein the edge spec — revert theSandboxMetric.mem_cacheremoval inspec/openapi-edge.ymland the corresponding field ingenerated.go, leaving the consumers alone. This is the safest if the field is still expected over the wire. - Drop
MemCacheconsistently — in this same PR, remove the twoMemCache: ...,lines inresources_remote.go(and ideally also dropMemCachefromapi.SandboxMetricinspec/openapi.yml/ regenerateapi.gen.go, plus updateresources_local.goso the publicapitype stops carrying a field that's never populated for remote clusters).
| - healthy | ||
| - draining | ||
| - unhealthy | ||
| - standby |
There was a problem hiding this comment.
@jakubno did some work here and this is not correct change. Let's wait on fixing before this pr is merged.
Updated edge-api spec with removed deprecated service discovery endpoint.