Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
22fcc1d
Updating hubble to mitigate cve
agrawaliti Oct 28, 2025
ab4ad85
fix(dropreason): Check ftrace_enabled required for fexit programs (#1…
SRodi Nov 5, 2025
29c459f
deps: bump helm/kind-action from 1.12.0 to 1.13.0 (#1925)
dependabot[bot] Nov 5, 2025
7ae5f62
deps: bump golangci/golangci-lint-action from 8 to 9 (#1930)
dependabot[bot] Nov 11, 2025
c8e5728
fix: Clean up before building windows image for git checks (#1950)
carlotaarvela Dec 1, 2025
d92cdf4
deps: bump actions/setup-go from 6.0.0 to 6.1.0 (#1944)
dependabot[bot] Dec 1, 2025
ac053ac
deps: bump actions/checkout from 5.0.0 to 6.0.0 (#1945)
dependabot[bot] Dec 1, 2025
957f02d
fix(conntrack): fix compilation warning + fix subsequent stack size e…
nddq Dec 1, 2025
d5502b9
chore(deps): bump js-yaml from 3.14.1 to 3.14.2 in /site in the npm_a…
dependabot[bot] Dec 1, 2025
d28a8fb
deps: bump github.com/redis/go-redis/v9 from 9.7.1 to 9.7.3 (#1954)
dependabot[bot] Dec 2, 2025
525adfb
chore(deps): bump the npm_and_yarn group across 1 directory with 2 up…
dependabot[bot] Dec 2, 2025
80a1609
fix: add validation of error to k8sWatcherErrorHandler (#1952)
alexcastilio Dec 2, 2025
1c28098
fix: removed unused option PrevTCPSockStats from linux util (#1924)
letv1nnn Dec 2, 2025
8d79f54
chore(deps): bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /site i…
dependabot[bot] Dec 2, 2025
d192fa8
feat: Add download all and all namespaces flags (#1917)
carlotaarvela Dec 2, 2025
b726da4
deps: bump github.com/aws/aws-sdk-go-v2/service/s3 from 1.88.4 to 1.9…
dependabot[bot] Dec 2, 2025
ee25170
Merge branch 'microsoft:main' into main
agrawaliti Dec 3, 2025
d2ef0dc
feat: Implement CheckAndMountFilesystems for required filesystem chec…
Dec 5, 2025
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
67 changes: 67 additions & 0 deletions pkg/plugin/common/filesystem_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//go:build linux
// +build linux

package common

Check failure on line 7 in pkg/plugin/common/filesystem_linux.go

View workflow job for this annotation

GitHub Actions / Lint (linux, arm64)

var-naming: avoid meaningless package names (revive)

Check failure on line 7 in pkg/plugin/common/filesystem_linux.go

View workflow job for this annotation

GitHub Actions / Lint (linux, amd64)

var-naming: avoid meaningless package names (revive)

Check failure on line 7 in pkg/plugin/common/filesystem_linux.go

View workflow job for this annotation

GitHub Actions / Lint (linux, arm64)

var-naming: avoid meaningless package names (revive)

Check failure on line 7 in pkg/plugin/common/filesystem_linux.go

View workflow job for this annotation

GitHub Actions / Lint (linux, amd64)

var-naming: avoid meaningless package names (revive)

import (
"github.com/microsoft/retina/pkg/log"
"go.uber.org/zap"
"golang.org/x/sys/unix"
)

// CheckAndMountFilesystems checks if required filesystems are mounted.
// Returns an error if any required filesystem is not available.
// This helps prevent os.Exit() calls from dependencies that expect these filesystems.
func CheckAndMountFilesystems(l *log.ZapLogger) error {
filesystems := []struct {
name string
paths []string
magic int64
required bool // if true, return error if not available
}{
{
name: "bpf",
paths: []string{"/sys/fs/bpf"},
magic: unix.BPF_FS_MAGIC,
required: false, // bpffs is less critical
},
{
name: "debugfs",
paths: []string{"/sys/kernel/debug"},
magic: unix.DEBUGFS_MAGIC,
required: true,
},
{
name: "tracefs",
paths: []string{"/sys/kernel/tracing", "/sys/kernel/debug/tracing"},
magic: unix.TRACEFS_MAGIC,
required: true,
},
}

var firstError error
filesystemLoop:
for _, fs := range filesystems {
var statfs unix.Statfs_t
for _, path := range fs.paths {
if err := unix.Statfs(path, &statfs); err != nil {
l.Debug("statfs returned error", zap.String("fs", fs.name), zap.String("path", path), zap.Error(err))
continue
}
if statfs.Type == fs.magic {
l.Debug("Filesystem already mounted", zap.String("fs", fs.name), zap.String("path", path))
continue filesystemLoop
}
}

// Filesystem not found or not mounted
l.Error("Filesystem not mounted", zap.String("fs", fs.name), zap.Strings("paths", fs.paths))
if fs.required && firstError == nil {
firstError = unix.ENOENT
}
}
return firstError
}
18 changes: 16 additions & 2 deletions pkg/plugin/dns/dns_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package dns

import (
"context"
"fmt"
"net"
"os"

Expand Down Expand Up @@ -47,8 +48,21 @@ func (d *dns) Compile(ctx context.Context) error {
}

func (d *dns) Init() error {
// Create tracer. In this case no parameters are passed.
err := host.Init(host.Config{})
// Check and mount filesystems before calling host.Init to avoid os.Exit()
if err := common.CheckAndMountFilesystems(d.l); err != nil {
d.l.Error("Required filesystems not available for DNS plugin", zap.Error(err))
// Return error to let retina decide whether to continue without DNS plugin
// or fail the entire agent initialization
return fmt.Errorf("required filesystems not available: %w", err)
}

// Filesystems are available, safe to call host.Init()
if err := host.Init(host.Config{}); err != nil {
d.l.Error("Host initialization failed", zap.Error(err))
return fmt.Errorf("host initialization failed: %w", err)
}

// Create tracer
tracer, err := tracer.NewTracer()
if err != nil {
d.l.Error("Failed to create tracer", zap.Error(err))
Expand Down
9 changes: 9 additions & 0 deletions pkg/plugin/tcpretrans/tcpretrans_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
kcfg "github.com/microsoft/retina/pkg/config"
"github.com/microsoft/retina/pkg/enricher"
"github.com/microsoft/retina/pkg/log"
"github.com/microsoft/retina/pkg/plugin/common"
"github.com/microsoft/retina/pkg/plugin/registry"
"github.com/microsoft/retina/pkg/utils"
"go.uber.org/zap"
Expand Down Expand Up @@ -53,6 +54,14 @@ func (t *tcpretrans) Init() error {
t.l.Warn("tcpretrans will not init because pod level is disabled")
return nil
}

if err := common.CheckAndMountFilesystems(t.l); err != nil {
t.l.Error("Required filesystems not available for tcpretrans plugin", zap.Error(err))
// Return error to let retina decide whether to continue without tcpretrans plugin
// or fail the entire agent initialization
return fmt.Errorf("required filesystems not available: %w", err)
}

// Create tracer. In this case no parameters are passed.
if err := host.Init(host.Config{}); err != nil {
t.l.Error("failed to init host", zap.Error(err))
Expand Down
Loading