Skip to content
Closed
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
17 changes: 13 additions & 4 deletions plugins/container/go-worker/pkg/container/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package container

import (
"context"
"strconv"
"strings"
"sync"

"github.com/containerd/containerd/api/events"
containerd "github.com/containerd/containerd/v2/client"
"github.com/containerd/containerd/v2/core/containers"
Expand All @@ -11,9 +15,6 @@ import (
"github.com/falcosecurity/plugins/plugins/container/go-worker/pkg/config"
"github.com/falcosecurity/plugins/plugins/container/go-worker/pkg/event"
"github.com/opencontainers/runtime-spec/specs-go"
"strconv"
"strings"
"sync"
)

func init() {
Expand Down Expand Up @@ -50,6 +51,14 @@ func (c *containerdEngine) ctrToInfo(namespacedContext context.Context, containe
}
}

// Name related
var containerName string
if name, ok := spec.Annotations["io.kubernetes.cri.container-name"]; ok && name != "" {
containerName = name
} else {
containerName = shortContainerID(container.ID())
}

// Cpu related
var (
cpuPeriod uint64 = defaultCpuPeriod
Expand Down Expand Up @@ -207,7 +216,7 @@ func (c *containerdEngine) ctrToInfo(namespacedContext context.Context, containe
Container: event.Container{
Type: typeContainerd.ToCTValue(),
ID: shortContainerID(container.ID()),
Name: shortContainerID(container.ID()),
Name: containerName,
Image: info.Image,
ImageDigest: imageDigest,
ImageRepo: imageRepo,
Expand Down
Loading