-
Notifications
You must be signed in to change notification settings - Fork 3
Fix/server intent #9
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,9 @@ func (svc *Service) ProcessIntents(ctx context.Context, intents []*domain.Intent | |
| if process.Command == pauseCommand { | ||
| continue | ||
| } | ||
| if !regexp.MustCompile(intent.CommandRegex).MatchString(process.Command) { | ||
| continue | ||
| } | ||
|
Comment on lines
+87
to
+89
|
||
| schedulingIntent := &domain.SchedulingIntents{ | ||
| Priority: intent.Priority > 0, | ||
| ExecutionTime: uint64(intent.ExecutionTime), | ||
|
|
@@ -186,9 +189,10 @@ func (svc *Service) parseCgroupToPodInfo(rootDir string, line string, pid int, p | |
| return nil | ||
| } | ||
|
|
||
| var ( | ||
| podRegex = regexp.MustCompile(`pod([0-9a-fA-F_]+)(?:\.slice)?`) | ||
| ) | ||
| // Support multiple cgroup formats: | ||
| // - systemd: kubelet-kubepods-pod20da609e_6973_4463_a1f9_2db9bcc5becc.slice (underscores) | ||
| // - cgroupfs: /kubepods/burstable/pod31e4e721-a5a0-421a-ae1d-b7971ae30d6e/ (dashes) | ||
| var podRegex = regexp.MustCompile(`pod([0-9a-fA-F]{8}[-_][0-9a-fA-F]{4}[-_][0-9a-fA-F]{4}[-_][0-9a-fA-F]{4}[-_][0-9a-fA-F]{12})`) | ||
|
|
||
| // getPodInfoFromCgroup extracts pod information from cgroup path | ||
| func (svc *Service) getPodInfoFromCgroup(cgroupPath string) (podUID string, containerID string, err error) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex is being compiled on every iteration of the process loop. This is inefficient and can cause performance issues when processing pods with many processes. Consider compiling the regex once outside the loop or caching compiled regex patterns.