-
Notifications
You must be signed in to change notification settings - Fork 180
Add peer-to-peer metrics tracker #1333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I'm going to pull a piece out to its own PR, and reopen when that's merged. |
this allows us to put sandbox-specific code here, to execute on insert, on delete, etc
2e39e0f
to
5bababb
Compare
# Conflicts: # packages/orchestrator/internal/server/main.go # packages/orchestrator/internal/server/sandboxes_test.go # packages/orchestrator/internal/service/service_info.go # packages/orchestrator/main.go
# Conflicts: # packages/orchestrator/internal/cfg/model.go
RedisClusterURL string `env:"REDIS_CLUSTER_URL"` | ||
RedisURL string `env:"REDIS_URL"` | ||
Services []string `env:"ORCHESTRATOR_SERVICES" envDefault:"orchestrator"` | ||
MetricsDirectory string `env:"METRICS_DIRECTORY" envDefault:"/orchestrator/metrics"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about calling it /orchestrator/state
so we can put more here in the future?
sandboxVCpuAllocated := uint32(0) | ||
sandboxMemoryAllocated := uint64(0) | ||
sandboxDiskAllocated := uint64(0) | ||
|
||
for _, item := range s.sandboxes.Items() { | ||
sandboxVCpuAllocated += uint32(item.Config.Vcpu) | ||
sandboxMemoryAllocated += uint64(item.Config.RamMB) * 1024 * 1024 | ||
sandboxDiskAllocated += uint64(item.Config.TotalDiskSizeMB) * 1024 * 1024 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is what I misunderstood during our conversation about host shared metrics. I thought we were asking OS to give us allocated memory, CPU, and disk per whole host and sandbox sums are not returned here. Sorry for the miscommunication here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, glad we're on the same page!
This consolidates metrics into a single struct that does a few things:
{pid}.json
It also creates
server.Limiter
for checking starting and running limits.Note
Introduces a shared-state manager that aggregates sandbox allocations across processes via PID JSON files and integrates a limiter to cap starting/running sandboxes, wiring both into server and service info paths.
internal/sharedstate
withManager
that writes self allocations to{pid}.json
, watches directory viafsnotify
, and aggregatesAllocations
across processes.sandboxes
map viaSubscribe
; exposeTotalAllocated()
andTotalRunningCount()
.internal/sharedstate/tracker_test.go
.server.Limiter
to enforce max running (viafeatureflags.MaxSandboxesPerNode
) and max starting per node; replace semaphore logic inserver
withsandboxLimiter
and error handling.internal/service/service_info.go
: switch from iterating localsandboxes
to usingsharedstate.Manager
for CPU/memory/disk and running counts.SHARED_STATE_DIRECTORY
,SHARED_STATE_WRITE_INTERVAL
,MAX_STARTING_INSTANCES
tocfg.Config
.main.go
: instantiate and runsharedstate.Manager
; pass toInfoService
andserver.New
; createserver.NewLimiter
.github.com/fsnotify/fsnotify
togo.mod
/go.sum
.Written by Cursor Bugbot for commit 835ee09. This will update automatically on new commits. Configure here.