Skip to content

fix(pod): css miss due to container cgroup path check errors, and unified resource release#253

Merged
hao022 merged 2 commits into
ccfos:mainfrom
sisttri:fix/css-walkdir-check
Jun 24, 2026
Merged

fix(pod): css miss due to container cgroup path check errors, and unified resource release#253
hao022 merged 2 commits into
ccfos:mainfrom
sisttri:fix/css-walkdir-check

Conversation

@sisttri

@sisttri sisttri commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@huhong-web huhong-web left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review for PR #253: fix(pod): css miss due to container cgroup path check errors, and unified resource release

1. Copyright Check

  • [PASS] All modified files have proper copyright headers

2. Golang Style Check

  • [PASS] Code follows Go style conventions
  • [PASS] Error handling is proper
  • [PASS] Variable naming follows Go conventions

3. Abstract Interface Check

  • [PASS] Uses existing BPF and context interfaces properly

4. Architecture Check

  • [PASS] Follows existing patterns for resource management
  • [PASS] Proper cleanup with cancel functions and reader closing

5. Concurrency Safety Check

  • [PASS] Uses sync.Map for concurrent access (line 76)
  • [PASS] Context cancellation pattern is correct
  • [PASS] Global variables are properly protected

6. Code Quality Issues

Issue 1: Global mutable state pattern

File: internal/pod/container_css_default.go:76-80

var (
    cgroupCssMetaDataMap      sync.Map
    _cgroupCssBpfInternal     *bpf.BPF
    _cgroupCssBpfCancelFunc   context.CancelFunc
    _cgroupCssBpfReader       bpf.PerfEventReader
)

Global mutable state is a common pattern in this codebase, but consider encapsulating these in a struct for better testability and lifecycle management.

Issue 2: Error handling in WalkDir callback

File: internal/pod/container_css_default.go:197-202

if err != nil {
    if path != realRoot {
        return nil // ignore error for container destroy, but not for root path
    }
    return err
}

The error handling is reasonable, but consider adding a comment explaining why container destroy errors should be ignored (e.g., race condition with container deletion).

Issue 3: Regex matching without pre-compilation

File: internal/pod/container_css_default.go:211-214

if !kubeletContainerIDRegexp.MatchString(d.Name()) {
    return nil
}

If kubeletContainerIDRegexp is used frequently in WalkDir callbacks, ensure it's pre-compiled (which it appears to be based on the name). If not, consider using regexp.MustCompile at package level.

7. Resource Management

  • [PASS] Proper cleanup with _cgroupCssBpfCancelFunc
  • [PASS] Reader is properly closed in release function
  • [PASS] BPF resource is properly released

8. Testing Considerations

  • The PR modifies core cgroup handling logic
  • Consider adding unit tests for:
    • cgroupRootNotify with various error conditions
    • kubeletContainerIDRegexp matching patterns
    • cgroupCssRelease cleanup sequence

Summary

This PR fixes a critical issue where container cgroup path checks could cause CSS misses. The implementation is solid with proper resource cleanup and error handling.

Recommendation: Approve with suggestions for documentation and testing improvements.

@hao022 hao022 merged commit fb92c93 into ccfos:main Jun 24, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants