Skip to content

Commit 101e27c

Browse files
committed
Rename API paths to /scaletozero/{disable,enable}
Match user-facing terminology to the action ("disable scale to zero") rather than the internal pin mechanism. Internal PinnedController.Pin/Unpin methods retain pin/unpin naming since they're distinct from the refcounted Controller.Disable/Enable.
1 parent a41fed3 commit 101e27c

4 files changed

Lines changed: 134 additions & 138 deletions

File tree

server/cmd/api/api/scaletozero.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import (
77
oapi "github.com/kernel/kernel-images/server/lib/oapi"
88
)
99

10-
func (s *ApiService) PinScaleToZero(ctx context.Context, _ oapi.PinScaleToZeroRequestObject) (oapi.PinScaleToZeroResponseObject, error) {
10+
func (s *ApiService) DisableScaleToZero(ctx context.Context, _ oapi.DisableScaleToZeroRequestObject) (oapi.DisableScaleToZeroResponseObject, error) {
1111
if err := s.stz.Pin(ctx); err != nil {
12-
logger.FromContext(ctx).Error("failed to pin scale-to-zero", "err", err)
13-
return oapi.PinScaleToZero500JSONResponse{InternalErrorJSONResponse: oapi.InternalErrorJSONResponse{Message: "failed to pin scale-to-zero"}}, nil
12+
logger.FromContext(ctx).Error("failed to disable scale-to-zero", "err", err)
13+
return oapi.DisableScaleToZero500JSONResponse{InternalErrorJSONResponse: oapi.InternalErrorJSONResponse{Message: "failed to disable scale-to-zero"}}, nil
1414
}
15-
return oapi.PinScaleToZero204Response{}, nil
15+
return oapi.DisableScaleToZero204Response{}, nil
1616
}
1717

18-
func (s *ApiService) UnpinScaleToZero(ctx context.Context, _ oapi.UnpinScaleToZeroRequestObject) (oapi.UnpinScaleToZeroResponseObject, error) {
18+
func (s *ApiService) EnableScaleToZero(ctx context.Context, _ oapi.EnableScaleToZeroRequestObject) (oapi.EnableScaleToZeroResponseObject, error) {
1919
if err := s.stz.Unpin(ctx); err != nil {
20-
logger.FromContext(ctx).Error("failed to unpin scale-to-zero", "err", err)
21-
return oapi.UnpinScaleToZero500JSONResponse{InternalErrorJSONResponse: oapi.InternalErrorJSONResponse{Message: "failed to unpin scale-to-zero"}}, nil
20+
logger.FromContext(ctx).Error("failed to enable scale-to-zero", "err", err)
21+
return oapi.EnableScaleToZero500JSONResponse{InternalErrorJSONResponse: oapi.InternalErrorJSONResponse{Message: "failed to enable scale-to-zero"}}, nil
2222
}
23-
return oapi.UnpinScaleToZero204Response{}, nil
23+
return oapi.EnableScaleToZero204Response{}, nil
2424
}

server/e2e/e2e_scaletozero_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
"github.com/stretchr/testify/require"
1111
)
1212

13-
// TestScaleToZeroPinUnpin exercises POST /scaletozero/{pin,unpin} against the
14-
// real built image. The unikraft control file does not exist inside the docker
15-
// test container, so the underlying scale-to-zero write is a no-op — this test
16-
// validates HTTP wiring, idempotency, and that the scale-to-zero middleware
17-
// coexists with the pin handlers.
18-
func TestScaleToZeroPinUnpin(t *testing.T) {
13+
// TestScaleToZeroDisableEnable exercises POST /scaletozero/{disable,enable}
14+
// against the real built image. The unikraft control file does not exist
15+
// inside the docker test container, so the underlying scale-to-zero write is
16+
// a no-op — this test validates HTTP wiring, idempotency, and that the
17+
// scale-to-zero middleware coexists with the disable/enable handlers.
18+
func TestScaleToZeroDisableEnable(t *testing.T) {
1919
t.Parallel()
2020

2121
if _, err := exec.LookPath("docker"); err != nil {
@@ -34,27 +34,27 @@ func TestScaleToZeroPinUnpin(t *testing.T) {
3434
client, err := c.APIClient()
3535
require.NoError(t, err, "failed to create API client")
3636

37-
// Idempotent pin.
38-
r1, err := client.PinScaleToZeroWithResponse(ctx)
39-
require.NoError(t, err, "PinScaleToZero request failed")
37+
// Idempotent disable.
38+
r1, err := client.DisableScaleToZeroWithResponse(ctx)
39+
require.NoError(t, err, "DisableScaleToZero request failed")
4040
require.Equal(t, http.StatusNoContent, r1.StatusCode(), "unexpected status: %s body=%s", r1.Status(), string(r1.Body))
4141

42-
r2, err := client.PinScaleToZeroWithResponse(ctx)
43-
require.NoError(t, err, "second PinScaleToZero request failed")
42+
r2, err := client.DisableScaleToZeroWithResponse(ctx)
43+
require.NoError(t, err, "second DisableScaleToZero request failed")
4444
require.Equal(t, http.StatusNoContent, r2.StatusCode(), "unexpected status: %s body=%s", r2.Status(), string(r2.Body))
4545

46-
// Normal request must still flow while pinned (scaletozero middleware
46+
// Normal request must still flow while disabled (scaletozero middleware
4747
// runs on every request — the pin must not deadlock or break it).
4848
readResp, err := client.ReadClipboardWithResponse(ctx)
49-
require.NoError(t, err, "ReadClipboard request failed while pinned")
50-
require.Equal(t, http.StatusOK, readResp.StatusCode(), "unexpected read status while pinned: %s body=%s", readResp.Status(), string(readResp.Body))
49+
require.NoError(t, err, "ReadClipboard request failed while disabled")
50+
require.Equal(t, http.StatusOK, readResp.StatusCode(), "unexpected read status while disabled: %s body=%s", readResp.Status(), string(readResp.Body))
5151

52-
// Idempotent unpin.
53-
r3, err := client.UnpinScaleToZeroWithResponse(ctx)
54-
require.NoError(t, err, "UnpinScaleToZero request failed")
52+
// Idempotent enable.
53+
r3, err := client.EnableScaleToZeroWithResponse(ctx)
54+
require.NoError(t, err, "EnableScaleToZero request failed")
5555
require.Equal(t, http.StatusNoContent, r3.StatusCode(), "unexpected status: %s body=%s", r3.Status(), string(r3.Body))
5656

57-
r4, err := client.UnpinScaleToZeroWithResponse(ctx)
58-
require.NoError(t, err, "second UnpinScaleToZero request failed")
57+
r4, err := client.EnableScaleToZeroWithResponse(ctx)
58+
require.NoError(t, err, "second EnableScaleToZero request failed")
5959
require.Equal(t, http.StatusNoContent, r4.StatusCode(), "unexpected status: %s body=%s", r4.Status(), string(r4.Body))
6060
}

0 commit comments

Comments
 (0)