-
Notifications
You must be signed in to change notification settings - Fork 312
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
koordlet:move audit log to resource executor after resource update #1055
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1055 +/- ##
=======================================
Coverage 66.98% 66.98%
=======================================
Files 263 263
Lines 28975 29036 +61
=======================================
+ Hits 19409 19450 +41
- Misses 8206 8226 +20
Partials 1360 1360
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
@@ -227,6 +256,7 @@ type NewResourceUpdaterFunc func(resourceType sysutil.ResourceType, parentDir st | |||
type ResourceUpdaterFactory interface { | |||
Register(g NewResourceUpdaterFunc, resourceTypes ...sysutil.ResourceType) | |||
New(resourceType sysutil.ResourceType, parentDir string, value string) (ResourceUpdater, error) | |||
NewWithAudit(resourceType sysutil.ResourceType, parentDir string, value string, e *audit.EventHelper) (ResourceUpdater, 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 origin New()
can be abandoned and rename NewWithAudit
with New
Is there anyone still using New()?
func CommonCgroupUpdateFunc(resource ResourceUpdater) error { | ||
c := resource.(*CgroupResourceUpdater) | ||
_ = audit.V(5).Reason(ReasonUpdateCgroups).Message("update %v to %v", resource.Path(), resource.Value()).Do() | ||
return sysutil.CgroupFileWriteIfDifferent(c.parentDir, c.file, c.value) | ||
dirty, err := cgroupFileWriteIfDifferent(c.parentDir, c.file, c.value) |
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.
dirty->updated
@@ -227,6 +256,7 @@ type NewResourceUpdaterFunc func(resourceType sysutil.ResourceType, parentDir st | |||
type ResourceUpdaterFactory interface { | |||
Register(g NewResourceUpdaterFunc, resourceTypes ...sysutil.ResourceType) | |||
New(resourceType sysutil.ResourceType, parentDir string, value string) (ResourceUpdater, error) | |||
NewWithAudit(resourceType sysutil.ResourceType, parentDir string, value string, e *audit.EventHelper) (ResourceUpdater, 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.
there is still some V5 logs in other pkg, which need to be modified.
problem about applyCPUSetWithNonePolicy? |
@@ -151,7 +151,7 @@ func UpdateResctrlTasksFunc(resource ResourceUpdater) error { | |||
// 122 | |||
// 123 | |||
// 124 | |||
_ = audit.V(5).Reason(ReasonUpdateResctrl).Message("update %v to %v", resource.Key(), resource.Value()).Do() | |||
_ = audit.V(3).Reason(ReasonUpdateResctrl).Message("update %v to %v", resource.Key(), resource.Value()).Do() |
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.
V5
if err != nil { | ||
klog.Warningf("suppressBECPU failed to apply be cpu suppress policy, err: %s", err) | ||
return | ||
if !compareIntSlice(beCPUSet, oldCPUSet) { |
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.
remove this
02cb0c6
to
8fec93d
Compare
f.lock.RLock() | ||
defer f.lock.RUnlock() | ||
g, ok := f.registry[resourceType] | ||
if !ok { | ||
return nil, fmt.Errorf("resource type %s not registered", resourceType) | ||
} | ||
return g(resourceType, parentDir, value) | ||
u, err := g(resourceType, parentDir, value) |
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.
pass EventHelper to g()
} else if updated { | ||
_ = audit.V(3).Reason(ReasonUpdateCgroups).Message("update %v to %v", resource.Path(), resource.Value()).Do() | ||
} | ||
return nil | ||
} | ||
|
||
func CommonDefaultUpdateFunc(resource ResourceUpdater) 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.
NewCommonDefaultUpdater
@@ -81,7 +81,7 @@ func caculateMemoryConfig(strategy *slov1alpha1.SystemStrategy, nodeMemory int64 | |||
if sysutil.ValidateResourceValue(&minFreeKbytes, "", sysutil.MinFreeKbytes) { | |||
valueStr := strconv.FormatInt(minFreeKbytes, 10) | |||
file := sysutil.MinFreeKbytes.Path("") | |||
resource, err := resourceexecutor.NewCommonDefaultUpdater(file, file, valueStr) | |||
resource, err := resourceexecutor.NewCommonDefaultUpdater(file, file, valueStr, nil) |
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.
should pass eventHelper, not nil
r, err := sysutil.GetCgroupResource(resourceType) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if e == nil { |
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.
why need this
func NewCommonDefaultUpdaterWithUpdateFunc(key string, file string, value string, updateFunc UpdateFunc) (ResourceUpdater, error) { | ||
func NewCommonDefaultUpdaterWithUpdateFunc(key string, file string, value string, updateFunc UpdateFunc, e *audit.EventHelper) (ResourceUpdater, error) { | ||
if e == nil { | ||
e = &audit.EventHelper{} |
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.
rm this
if err != nil { | ||
return err | ||
} | ||
if updated && c.eventHelper.Event.Reason != "" { |
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.
check nil
2734589
to
663cf6d
Compare
check the final result |
Signed-off-by: Re-Grh <1271013391@qq.com>
Signed-off-by: Re-Grh <1271013391@qq.com>
Signed-off-by: Re-Grh <1271013391@qq.com>
/approve |
/assign @FillZpp |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hormes, zwzhang0107 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Ⅰ. Describe what this PR does
to solve the problem of duplicate audit logs by moving it to the executor module after resource update
Ⅱ. Does this pull request fix one issue?
fixes #1018
The audit log redundancy issue has been addressed by leveraging the executor's built-in cache, which has changed the recording frequency from 10 seconds to 60 seconds. Meanwhile, the adjustbecpuset policy execution shows frequent CPU rebinding , both klog and audit log will print.
and klog shows here
and i will start a new issue since it looks like we need to modify the function applyCPUSetWithNonePolicy(beCPUSet, oldCPUSet) to improve the stability of CPUs for the BE Group's calculation policy.
Ⅲ. Describe how to verify it
Ⅳ. Special notes for reviews
V. Checklist
make test