Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ws-daemon] Remove old sandboxing behaviour #4994

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions components/ws-daemon/pkg/content/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/gitpod-io/gitpod/ws-daemon/pkg/container"
"github.com/gitpod-io/gitpod/ws-daemon/pkg/internal/session"
"github.com/gitpod-io/gitpod/ws-daemon/pkg/iws"
"github.com/gitpod-io/gitpod/ws-daemon/pkg/quota"
)

// WorkspaceService implements the InitService and WorkspaceService
Expand All @@ -45,7 +44,6 @@ type WorkspaceService struct {
store *session.Store
ctx context.Context
stopService context.CancelFunc
sandboxes quota.SandboxProvider
runtime container.Runtime

api.UnimplementedInWorkspaceServiceServer
Expand Down Expand Up @@ -242,11 +240,6 @@ func (s *WorkspaceService) InitWorkspace(ctx context.Context, req *api.InitWorks

func (s *WorkspaceService) creator(req *api.InitWorkspaceRequest) session.WorkspaceFactory {
return func(ctx context.Context, location string) (res *session.Workspace, err error) {
err = s.createSandbox(ctx, req, location)
if err != nil {
return nil, err
}

return &session.Workspace{
Location: location,
CheckoutLocation: getCheckoutLocation(req),
Expand All @@ -264,49 +257,6 @@ func (s *WorkspaceService) creator(req *api.InitWorkspaceRequest) session.Worksp
}
}

func (s *WorkspaceService) createSandbox(ctx context.Context, req *api.InitWorkspaceRequest, location string) (err error) {
if s.config.WorkspaceSizeLimit == 0 {
return
}

//nolint:ineffassign
span, ctx := opentracing.StartSpanFromContext(ctx, "createSandbox")
defer tracing.FinishSpan(span, &err)

owi := log.OWI(req.Metadata.Owner, req.Metadata.MetaId, req.Id)
if req.FullWorkspaceBackup {
msg := "cannot create sandboxes for workspaces with full workspace backup - skipping sandbox"
span.LogKV("warning", msg)
log.WithFields(owi).Warn(msg)
return
}

// Create and mount sandbox
mode := os.FileMode(0755)
sandbox := filepath.Join(s.store.Location, req.Id+".sandbox")
err = s.sandboxes.Create(ctx, sandbox, s.config.WorkspaceSizeLimit)
if err != nil {
log.WithFields(owi).WithField("sandbox", sandbox).WithField("location", location).WithError(err).Error("cannot create sandbox")
return status.Error(codes.Internal, "cannot create sandbox")
}
if _, err := os.Stat(location); os.IsNotExist(err) {
// in the very unlikely event that the workspace Pod did not mount (and thus create) the workspace directory, create it
err = os.Mkdir(location, mode)
if os.IsExist(err) {
log.WithError(err).WithField("location", location).Debug("ran into non-atomic workspce location existence check")
} else if err != nil {
log.WithFields(owi).WithError(err).Error("cannot create workspace mount point")
return status.Error(codes.Internal, "cannot create workspace")
}
}
err = s.sandboxes.Mount(ctx, sandbox, location)
if err != nil {
log.WithFields(owi).WithField("sandbox", sandbox).WithField("location", location).WithError(err).Error("cannot mount sandbox")
return status.Error(codes.Internal, "cannot mount sandbox")
}
return nil
}

// getCheckoutLocation returns the first checkout location found of any Git initializer configured by this request
func getCheckoutLocation(req *api.InitWorkspaceRequest) string {
spec := req.Initializer.Spec
Expand Down Expand Up @@ -399,17 +349,6 @@ func (s *WorkspaceService) DisposeWorkspace(ctx context.Context, req *api.Dispos
resp.GitStatus = repo
}

if s.config.WorkspaceSizeLimit > 0 && !sess.FullWorkspaceBackup {
// We can delete the sandbox here (rather than in the store) because WaitOrMarkForDisposal
// ensures we're doing this exclusively for this workspace.
err = s.sandboxes.Dispose(ctx, sess.Location)
if err != nil {
log.WithError(err).WithField("workspaceId", req.Id).Error("cannot dispose sandbox")
span.LogKV("error", err.Error())
return nil, status.Error(codes.Internal, "cannot dispose sandbox")
}
}

err = s.store.Delete(ctx, req.Id)
if err != nil {
log.WithError(err).WithField("workspaceId", req.Id).Error("cannot delete workspace from store")
Expand Down
96 changes: 0 additions & 96 deletions components/ws-daemon/pkg/quota/mounts.go

This file was deleted.

75 changes: 0 additions & 75 deletions components/ws-daemon/pkg/quota/mounts_test.go

This file was deleted.

Loading