Skip to content

Commit c8e599c

Browse files
committed
1
1 parent 70871a4 commit c8e599c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

components/ws-manager/pkg/manager/manager_ee.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,28 @@ func (m *Manager) SetTimeout(ctx context.Context, req *api.SetTimeoutRequest) (r
142142
return &api.SetTimeoutResponse{}, nil
143143
}
144144

145+
// SetClosedTimeout changes the default closed timeout for a running workspace
146+
func (m *Manager) SetClosedTimeout(ctx context.Context, req *api.SetClosedTimeoutRequest) (res *api.SetClosedTimeoutResponse, err error) {
147+
//nolint:ineffassign
148+
span, ctx := tracing.FromContext(ctx, "SetClosedTimeout")
149+
tracing.ApplyOWI(span, log.OWI("", "", req.Id))
150+
defer tracing.FinishSpan(span, &err)
151+
152+
if req.Duration != "-1" {
153+
_, err = time.ParseDuration(req.Duration)
154+
if err != nil {
155+
return nil, xerrors.Errorf("invalid duration \"%s\": %w", req.Duration, err)
156+
}
157+
}
158+
159+
err = m.markWorkspace(ctx, req.Id, addMark(customClosedTimeoutAnnotation, req.Duration))
160+
if err != nil {
161+
return nil, xerrors.Errorf("cannot set workspace closed timeout: %w", err)
162+
}
163+
164+
return &api.SetClosedTimeoutResponse{}, nil
165+
}
166+
145167
// BackupWorkspace attempts to create a backup of the workspace, ignoring its perceived current status as much as it can
146168
func (m *Manager) BackupWorkspace(ctx context.Context, req *api.BackupWorkspaceRequest) (res *api.BackupWorkspaceResponse, err error) {
147169
span, ctx := tracing.FromContext(ctx, "BackupWorkspace")

components/ws-manager/pkg/manager/manager_oss.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ func (m *Manager) SetTimeout(ctx context.Context, req *api.SetTimeoutRequest) (r
3333
return nil, errEnterpriseFeature
3434
}
3535

36+
// SetClosedTimeout changes the default closed timeout for a running workspace
37+
func (m *Manager) SetClosedTimeout(ctx context.Context, req *api.SetClosedTimeoutRequest) (res *api.SetClosedTimeoutResponse, err error) {
38+
return nil, errEnterpriseFeature
39+
}
40+
3641
// BackupWorkspace creates a copy of the workspace content and stores it so that another workspace can be created from it.
3742
func (m *Manager) BackupWorkspace(ctx context.Context, req *api.BackupWorkspaceRequest) (res *api.BackupWorkspaceResponse, err error) {
3843
return nil, errEnterpriseFeature

0 commit comments

Comments
 (0)