Skip to content

Commit 97153bf

Browse files
authored
Save auto pause option to the DB (#1008)
1 parent 7e88cca commit 97153bf

File tree

27 files changed

+535
-218
lines changed

27 files changed

+535
-218
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414
modules: ${{ steps.set-modules.outputs.modules }}
1515
steps:
1616
- uses: actions/checkout@v4
17-
- uses: actions/setup-go@v5
18-
with:
19-
go-version-file: 'go.work'
2017
- id: set-modules
2118
run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT
2219

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

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

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

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

packages/api/internal/handlers/sandbox_resume.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ func (a *APIStore) PostSandboxesSandboxIDResume(c *gin.Context, sandboxID api.Sa
6666
}
6767
}
6868

69-
autoPause := instance.InstanceAutoPauseDefault
70-
if body.AutoPause != nil {
71-
autoPause = *body.AutoPause
72-
}
73-
7469
sandboxID = utils.ShortID(sandboxID)
7570

7671
// This is also checked during in orchestrator.CreateSandbox, where the sandbox ID is reserved,
@@ -80,7 +75,6 @@ func (a *APIStore) PostSandboxesSandboxIDResume(c *gin.Context, sandboxID api.Sa
8075
zap.L().Debug("Sandbox is already running",
8176
logger.WithSandboxID(sandboxID),
8277
zap.Time("end_time", sbxCache.GetEndTime()),
83-
zap.Bool("auto_pause", sbxCache.AutoPause.Load()),
8478
zap.Time("start_time", sbxCache.StartTime),
8579
zap.String("node_id", sbxCache.Node.NodeID),
8680
)
@@ -102,6 +96,10 @@ func (a *APIStore) PostSandboxesSandboxIDResume(c *gin.Context, sandboxID api.Sa
10296
return
10397
}
10498

99+
autoPause := lastSnapshot.Snapshot.AutoPause
100+
if body.AutoPause != nil {
101+
autoPause = *body.AutoPause
102+
}
105103
snap := lastSnapshot.Snapshot
106104
build := lastSnapshot.EnvBuild
107105

packages/api/internal/orchestrator/create_instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (o *Orchestrator) CreateSandbox(
142142
RamMb: build.RamMb,
143143
Vcpu: build.Vcpu,
144144
Snapshot: isResume,
145-
AutoPause: &autoPause,
145+
AutoPause: autoPause,
146146
AllowInternetAccess: allowInternetAccess,
147147
TotalDiskSizeMb: ut.FromPtr(build.TotalDiskSizeMb),
148148
},

packages/api/internal/orchestrator/list_instances.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ func (o *Orchestrator) getSandboxes(ctx context.Context, node *nNode.NodeInfo) (
5252
return nil, fmt.Errorf("failed to parse build ID '%s' for job: %w", config.BuildId, err)
5353
}
5454

55-
autoPause := instance.InstanceAutoPauseDefault
56-
if config.AutoPause != nil {
57-
autoPause = *config.AutoPause
58-
}
59-
6055
sandboxesInfo = append(
6156
sandboxesInfo,
6257
instance.NewInstanceInfo(
@@ -78,7 +73,7 @@ func (o *Orchestrator) getSandboxes(ctx context.Context, node *nNode.NodeInfo) (
7873
config.FirecrackerVersion,
7974
config.EnvdVersion,
8075
node,
81-
autoPause,
76+
config.AutoPause,
8277
config.EnvdAccessToken,
8378
config.AllowInternetAccess,
8479
config.BaseTemplateId,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- +goose Up
2+
-- +goose StatementBegin
3+
4+
ALTER TABLE snapshots
5+
ADD COLUMN auto_pause boolean NOT NULL default false;
6+
-- +goose StatementEnd
7+
8+
-- +goose Down
9+
-- +goose StatementBegin
10+
ALTER TABLE snapshots
11+
DROP COLUMN IF EXISTS auto_pause;
12+
-- +goose StatementEnd

packages/db/queries/get_last_snapshot.sql.go

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

packages/db/queries/get_snapshots_with_cursor.sql.go

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

packages/db/queries/models.go

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

0 commit comments

Comments
 (0)