Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
iQQBot committed Feb 7, 2023
1 parent 70871a4 commit c8e599c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions components/ws-manager/pkg/manager/manager_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,28 @@ func (m *Manager) SetTimeout(ctx context.Context, req *api.SetTimeoutRequest) (r
return &api.SetTimeoutResponse{}, nil
}

// SetClosedTimeout changes the default closed timeout for a running workspace
func (m *Manager) SetClosedTimeout(ctx context.Context, req *api.SetClosedTimeoutRequest) (res *api.SetClosedTimeoutResponse, err error) {
//nolint:ineffassign
span, ctx := tracing.FromContext(ctx, "SetClosedTimeout")
tracing.ApplyOWI(span, log.OWI("", "", req.Id))
defer tracing.FinishSpan(span, &err)

if req.Duration != "-1" {
_, err = time.ParseDuration(req.Duration)
if err != nil {
return nil, xerrors.Errorf("invalid duration \"%s\": %w", req.Duration, err)
}
}

err = m.markWorkspace(ctx, req.Id, addMark(customClosedTimeoutAnnotation, req.Duration))
if err != nil {
return nil, xerrors.Errorf("cannot set workspace closed timeout: %w", err)
}

return &api.SetClosedTimeoutResponse{}, nil
}

// BackupWorkspace attempts to create a backup of the workspace, ignoring its perceived current status as much as it can
func (m *Manager) BackupWorkspace(ctx context.Context, req *api.BackupWorkspaceRequest) (res *api.BackupWorkspaceResponse, err error) {
span, ctx := tracing.FromContext(ctx, "BackupWorkspace")
Expand Down
5 changes: 5 additions & 0 deletions components/ws-manager/pkg/manager/manager_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func (m *Manager) SetTimeout(ctx context.Context, req *api.SetTimeoutRequest) (r
return nil, errEnterpriseFeature
}

// SetClosedTimeout changes the default closed timeout for a running workspace
func (m *Manager) SetClosedTimeout(ctx context.Context, req *api.SetClosedTimeoutRequest) (res *api.SetClosedTimeoutResponse, err error) {
return nil, errEnterpriseFeature
}

// BackupWorkspace creates a copy of the workspace content and stores it so that another workspace can be created from it.
func (m *Manager) BackupWorkspace(ctx context.Context, req *api.BackupWorkspaceRequest) (res *api.BackupWorkspaceResponse, err error) {
return nil, errEnterpriseFeature
Expand Down

0 comments on commit c8e599c

Please sign in to comment.