Skip to content

Commit

Permalink
Remove unnecessary cleanup method; Fix cleanup order
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentaTomas committed Apr 16, 2024
1 parent 633d73e commit 93e6933
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/orchestrator/internal/server/sandboxes.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import (
"github.com/e2b-dev/infra/packages/shared/pkg/telemetry"
)

const fcVersionsDir = "/fc-versions"
const kernelDir = "/fc-kernels"
const kernelMountDir = "/fc-vm"
const kernelName = "vmlinux.bin"
const uffdBinaryName = "uffd"
const fcBinaryName = "firecracker"
const (
fcVersionsDir = "/fc-versions"
kernelDir = "/fc-kernels"
kernelMountDir = "/fc-vm"
kernelName = "vmlinux.bin"
uffdBinaryName = "uffd"
fcBinaryName = "firecracker"
)

func (s *server) SandboxCreate(ctx context.Context, sandboxRequest *orchestrator.SandboxCreateRequest) (*orchestrator.NewSandbox, error) {
childCtx, childSpan := s.tracer.Start(ctx, "sandbox-create")
Expand Down Expand Up @@ -66,8 +68,8 @@ func (s *server) SandboxCreate(ctx context.Context, sandboxRequest *orchestrator

go func() {
tracer := otel.Tracer("close")
defer sbx.CleanupAfterFCStop(context.Background(), tracer, s.consul, s.dns)
defer s.sandboxes.Remove(sandboxRequest.SandboxID)
defer sbx.CleanupAfterFCStop(context.Background(), tracer, s.consul, s.dns)

err := sbx.FC.Wait()
if err != nil {
Expand Down Expand Up @@ -110,7 +112,6 @@ func (s *server) SandboxDelete(ctx context.Context, in *orchestrator.SandboxRequ
}

err := sbx.FC.Stop(ctx, s.tracer)
defer sbx.CleanupAfterFCStop(ctx, s.tracer, s.consul, s.dns)
if err != nil {
errMsg := fmt.Errorf("failed to stop FC: %w", err)

Expand Down

0 comments on commit 93e6933

Please sign in to comment.