Skip to content
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
5 changes: 0 additions & 5 deletions activator/activator.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,6 @@ func (s *Server) Stop(ctx context.Context) {
log.G(ctx).WithError(err).Error("closing bpf maps")
}

log.G(ctx).Debugf("removing %s", PinPath(s.sandboxPid))
if err := cleanPinPath(s.sandboxPid); err != nil {
log.G(ctx).WithError(err).Error("cleaning pin path")
}

s.wg.Wait()
log.G(ctx).Debug("activator stopped")
}
Expand Down
4 changes: 2 additions & 2 deletions activator/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ func (bpf *BPF) Cleanup() error {
}

bpf.log.Info("deleting", "path", PinPath(bpf.pid))
errs = append(errs, cleanPinPath(bpf.pid))
errs = append(errs, CleanPinPath(bpf.pid))
return errors.Join(errs...)
}

func cleanPinPath(pid int) error {
func CleanPinPath(pid int) error {
return errors.Join(
os.RemoveAll(PinPath(pid)),
os.RemoveAll(PinPath(pid)+ManagedByShimSuffix),
Expand Down
30 changes: 30 additions & 0 deletions shim/task/service_zeropod.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/containerd/ttrpc"

"github.com/containerd/typeurl/v2"
"github.com/ctrox/zeropod/activator"
v1 "github.com/ctrox/zeropod/api/shim/v1"
zshim "github.com/ctrox/zeropod/shim"
"google.golang.org/protobuf/types/known/emptypb"
Expand Down Expand Up @@ -296,6 +297,9 @@ func (w *wrapper) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (*taskAP
log.G(ctx).Info("delete called")
zeropodContainer, ok := w.getZeropodContainer(r.ID)
if !ok {
if err := w.cleanSandboxPin(ctx, r); err != nil {
log.G(ctx).WithError(err).Error("cleaning up sandbox pin")
}
return w.service.Delete(ctx, r)
}
log.G(ctx).Infof("delete called in zeropod: %s", zeropodContainer.ID())
Expand Down Expand Up @@ -465,3 +469,29 @@ func (w *wrapper) postRestore(container *runc.Container, handleStarted zshim.Han
handleStarted(container, p)
}
}

// cleanSandboxPin cleanes the eBPF pin path of the sandbox container.
func (w *wrapper) cleanSandboxPin(ctx context.Context, r *taskAPI.DeleteRequest) error {
if r.ExecID != "" {
return nil
}
container, err := w.getContainer(r.ID)
if err != nil {
return err
}
spec, err := zshim.GetSpec(container.Bundle)
if err != nil {
return err
}
cfg, err := v1.NewConfig(ctx, spec)
if err != nil {
return err
}
if cfg.ContainerType != containerTypeSandbox {
return nil
}
if err := activator.CleanPinPath(container.Pid()); err != nil {
return err
}
return nil
}
Loading