Skip to content

Commit de5d764

Browse files
committed
fix(api): make memCache a required field in SandboxMetric schemas
All other metric fields (memUsed, memTotal, diskUsed, etc.) are required in the OpenAPI specs. Leaving memCache optional caused oapi-codegen to generate it as a pointer (*int64) with omitempty, which is inconsistent with the rest of the struct and would make it the only metric that could be absent from API responses.
1 parent d743ee8 commit de5d764

File tree

5 files changed

+99
-99
lines changed

5 files changed

+99
-99
lines changed

packages/api/internal/api/api.gen.go

Lines changed: 94 additions & 94 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/api/internal/clusters/resources_local.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,14 @@ func (l *LocalClusterResourceProvider) GetSandboxMetrics(ctx context.Context, te
7171

7272
metrics := make([]api.SandboxMetric, len(rawMetrics))
7373
for i, m := range rawMetrics {
74-
memCache := int64(m.MemCache)
7574
metrics[i] = api.SandboxMetric{
7675
Timestamp: m.Timestamp,
7776
TimestampUnix: m.Timestamp.Unix(),
7877
CpuUsedPct: float32(m.CPUUsedPercent),
7978
CpuCount: int32(m.CPUCount),
8079
MemTotal: int64(m.MemTotal),
8180
MemUsed: int64(m.MemUsed),
82-
MemCache: &memCache,
81+
MemCache: int64(m.MemCache),
8382
DiskTotal: int64(m.DiskTotal),
8483
DiskUsed: int64(m.DiskUsed),
8584
}
@@ -100,15 +99,14 @@ func (l *LocalClusterResourceProvider) GetSandboxesMetrics(ctx context.Context,
10099

101100
metrics := make(map[string]api.SandboxMetric)
102101
for _, m := range rawMetrics {
103-
memCache := int64(m.MemCache)
104102
metrics[m.SandboxID] = api.SandboxMetric{
105103
Timestamp: m.Timestamp,
106104
TimestampUnix: m.Timestamp.Unix(),
107105
CpuUsedPct: float32(m.CPUUsedPercent),
108106
CpuCount: int32(m.CPUCount),
109107
MemTotal: int64(m.MemTotal),
110108
MemUsed: int64(m.MemUsed),
111-
MemCache: &memCache,
109+
MemCache: int64(m.MemCache),
112110
DiskTotal: int64(m.DiskTotal),
113111
DiskUsed: int64(m.DiskUsed),
114112
}

packages/shared/pkg/http/edge/generated.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/openapi-edge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ components:
254254
- cpu_count
255255
- mem_total
256256
- mem_used
257+
- mem_cache
257258
- disk_total
258259
- disk_used
259260
properties:

spec/openapi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ components:
388388
- cpuUsedPct
389389
- memUsed
390390
- memTotal
391+
- memCache
391392
- diskUsed
392393
- diskTotal
393394
properties:

0 commit comments

Comments
 (0)