Skip to content

Commit b66403f

Browse files
sjmiller609claude
andcommitted
Add /system/standby API for out-of-band scale-to-zero pin
Adds two new endpoints to the kernel-images server: - POST /system/standby/disable — pins scale-to-zero off until released - POST /system/standby/enable — releases the pin The pin lives alongside the existing request-driven middleware refcount in DebouncedController: scale-to-zero stays disabled while either holders are inflight requests OR the pin is held. Request-driven Enable calls do not release the pin, so a pinned VM survives idle periods. Releasing the pin honors any configured re-enable cooldown. This is the in-VM surface for future control-plane integrations (e.g. a hot-pool controller reserving a VM until it is claimed). Control-plane wiring will follow in metro-api and the API server. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 43ddda6 commit b66403f

6 files changed

Lines changed: 785 additions & 193 deletions

File tree

server/cmd/api/api/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type ApiService struct {
4949

5050
// DevTools upstream manager (Chromium supervisord log tailer)
5151
upstreamMgr *devtoolsproxy.UpstreamManager
52-
stz scaletozero.Controller
52+
stz scaletozero.PinnedController
5353

5454
// inputMu serializes input-related operations (mouse, keyboard, screenshot)
5555
inputMu sync.Mutex
@@ -96,7 +96,7 @@ func New(
9696
recordManager recorder.RecordManager,
9797
factory recorder.FFmpegRecorderFactory,
9898
upstreamMgr *devtoolsproxy.UpstreamManager,
99-
stz scaletozero.Controller,
99+
stz scaletozero.PinnedController,
100100
nekoAuthClient *nekoclient.AuthClient,
101101
captureSession *capturesession.CaptureSession,
102102
eventStream *events.EventStream,

server/cmd/api/api/standby.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package api
2+
3+
import (
4+
"context"
5+
6+
"github.com/kernel/kernel-images/server/lib/logger"
7+
oapi "github.com/kernel/kernel-images/server/lib/oapi"
8+
)
9+
10+
func (s *ApiService) DisableStandby(ctx context.Context, _ oapi.DisableStandbyRequestObject) (oapi.DisableStandbyResponseObject, error) {
11+
if err := s.stz.DisablePin(ctx); err != nil {
12+
logger.FromContext(ctx).Error("failed to pin scale-to-zero disabled", "err", err)
13+
return oapi.DisableStandby500JSONResponse{InternalErrorJSONResponse: oapi.InternalErrorJSONResponse{Message: "failed to disable standby"}}, nil
14+
}
15+
return oapi.DisableStandby204Response{}, nil
16+
}
17+
18+
func (s *ApiService) EnableStandby(ctx context.Context, _ oapi.EnableStandbyRequestObject) (oapi.EnableStandbyResponseObject, error) {
19+
if err := s.stz.EnablePin(ctx); err != nil {
20+
logger.FromContext(ctx).Error("failed to release scale-to-zero pin", "err", err)
21+
return oapi.EnableStandby500JSONResponse{InternalErrorJSONResponse: oapi.InternalErrorJSONResponse{Message: "failed to enable standby"}}, nil
22+
}
23+
return oapi.EnableStandby204Response{}, nil
24+
}

0 commit comments

Comments
 (0)