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

fix: improve error handling for tracing policies directory access #3289

Merged
merged 1 commit into from
Jan 13, 2025
Merged
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
15 changes: 8 additions & 7 deletions cmd/tetragon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,18 +577,19 @@ func waitCRDs(config *rest.Config) error {
}

func loadTpFromDir(ctx context.Context, dir string) error {
tpMaxDepth := 1
tpFS := os.DirFS(dir)

if dir == defaults.DefaultTpDir {
// If the default directory does not exist then do not fail
// Probably tetragon not fully installed, developers testing, etc
if _, err := os.Stat(dir); os.IsNotExist(err) {
if _, err := os.Stat(dir); err != nil {
// Do not fail if the default directory doesn't exist,
// it might because of developer setup or incomplete installation
if os.IsNotExist(err) && dir == defaults.DefaultTpDir {
log.WithField("tracing-policy-dir", dir).Info("Loading Tracing Policies from directory ignored, directory does not exist")
return nil
}
return fmt.Errorf("Failed to access tracing policies dir %s: %w", dir, err)
}

tpMaxDepth := 1
tpFS := os.DirFS(dir)

err := fs.WalkDir(tpFS, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
Expand Down
Loading