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

Log events only related to a valid CNI configuration file. #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

roman-kiselenko
Copy link
Member

Logs only .conf, .json and .conflist files.

Context #208 (comment)

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Reduce noisy log messages

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Some additional context is here.

Does this PR introduce a user-facing change?

Log events only related to a valid CNI configuration file.

@kwilczynski @saschagrunert PTAL

@openshift-ci openshift-ci bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Nov 9, 2024
Copy link
Contributor

openshift-ci bot commented Nov 9, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: roman-kiselenko
Once this PR has been reviewed and has the lgtm label, please assign saschagrunert for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coveralls
Copy link

coveralls commented Nov 9, 2024

Pull Request Test Coverage Report for Build 11762983317

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 61.68%

Totals Coverage Status
Change from base Build 11626223460: 0.2%
Covered Lines: 536
Relevant Lines: 869

💛 - Coveralls

@roman-kiselenko roman-kiselenko force-pushed the feature/log-only-cni-config-files branch from 910bb50 to 0cfe056 Compare November 9, 2024 13:11
Logs only .conf, .json and .conflist files.

Signed-off-by: roman-kiselenko <[email protected]>
Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

Thank you! I have a suggestion, otherwise LGTM

Comment on lines +158 to +167
exts := map[string]bool{}
for _, ext := range []string{".conf", ".conflist", ".json"} {
exts[ext] = true
}
for {
select {
case event := <-plugin.watcher.Events:
logrus.Infof("CNI monitoring event %v", event)
if exts[filepath.Ext(event.Name)] {
logrus.Infof("CNI monitoring event %v", event)
}
Copy link
Member

Choose a reason for hiding this comment

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

How about avoiding the map:

	exts := []string{".conf", ".conflist", ".json"}
	for {
		select {
		case event := <-plugin.watcher.Events:
			if slices.Contains(exts, filepath.Ext(event.Name)) {
				logrus.Infof("CNI monitoring event %v", event)
			}

Copy link
Member Author

Choose a reason for hiding this comment

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

I like it, I will change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants