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: Prevent nil errors in log.Error to ensure proper logging and add sanity check and add custom linter to avoid this scenario in the future #1599

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

camilamacedo86
Copy link
Contributor

@camilamacedo86 camilamacedo86 commented Jan 10, 2025

Description

Solves the following issues and add a custom linter to avoid this scenario in the future:

Furthermore, it solves a similar scenario in the EventHandler code implementation found with the new custom linter check.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@camilamacedo86 camilamacedo86 requested a review from a team as a code owner January 10, 2025 20:45
Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 5a41f9f
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/67a3f0e49e3dc70008317ff0
😎 Deploy Preview https://deploy-preview-1599--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@camilamacedo86 camilamacedo86 changed the title 🐛 Fix error message 🐛 Fix: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check Jan 10, 2025
hack/ci/sanity.sh Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 2.38095% with 41 lines in your changes missing coverage. Please review.

Project coverage is 67.27%. Comparing base (dcf50b8) to head (5a41f9f).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...nal/contentmanager/source/internal/eventhandler.go 3.33% 27 Missing and 2 partials ⚠️
catalogd/cmd/catalogd/main.go 0.00% 6 Missing ⚠️
cmd/operator-controller/main.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1599      +/-   ##
==========================================
- Coverage   67.66%   67.27%   -0.39%     
==========================================
  Files          59       59              
  Lines        4991     5012      +21     
==========================================
- Hits         3377     3372       -5     
- Misses       1367     1392      +25     
- Partials      247      248       +1     
Flag Coverage Δ
e2e 52.98% <2.77%> (-0.40%) ⬇️
unit 55.18% <0.00%> (-0.24%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@camilamacedo86 camilamacedo86 force-pushed the fix-error-message branch 2 times, most recently from 11b2c46 to a66fb03 Compare January 12, 2025 12:09
@camilamacedo86 camilamacedo86 changed the title 🐛 Fix: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check (WIP) 🐛 Fix: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check Jan 12, 2025
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 12, 2025
Makefile Outdated
Comment on lines 101 to 103
.PHONY: lint-custom
lint-custom: custom-linter-build
go vet -vettool=./bin/custom-linter ./...
Copy link
Member

Choose a reason for hiding this comment

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

golangci-lint should already be running go vet (assuming the govet linter is enabled). So I think we get this part automatically if we add the directory where we build the linter binary to the path for the golangci-lint run command.

Copy link
Contributor Author

@camilamacedo86 camilamacedo86 Feb 5, 2025

Choose a reason for hiding this comment

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

See https://golangci-lint.run/contributing/new-linters/
But I could not make it work.
I would need to spend more time on that.

Could we move forward with this one as it is and then track a task for we see if we can integrate it with golangci as a follow up?

At least now we have the logs fixed + the linter

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 25, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 4, 2025
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 5, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 5, 2025
@camilamacedo86 camilamacedo86 force-pushed the fix-error-message branch 4 times, most recently from c4b2d95 to 2ba109f Compare February 5, 2025 13:49
@camilamacedo86 camilamacedo86 changed the title (WIP) 🐛 Fix: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check 🐛 Fix: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check Feb 5, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 5, 2025
@camilamacedo86 camilamacedo86 changed the title 🐛 Fix: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check 🐛 Fix: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check and add custom linter to avoid this scenario in the future Feb 5, 2025
@camilamacedo86 camilamacedo86 changed the title 🐛 Fix: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check and add custom linter to avoid this scenario in the future 🐛 Fix: Prevent nil errors in log.Error to ensure proper logging and add sanity check and add custom linter to avoid this scenario in the future Feb 5, 2025
Copy link
Contributor

@anik120 anik120 left a comment

Choose a reason for hiding this comment

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

Pretty neat. Looks like @joelanford's already helped get this PR to a good state with his initial reviews.

/lgtm

so that Joe can approve :)

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 5, 2025
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

Nice! You found a few other places we needed to fix as well!

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 5, 2025
Copy link

openshift-ci bot commented Feb 5, 2025

New changes are detected. LGTM label has been removed.

.PHONY: custom-linter-build
LINTER_DIR := ./hack/ci/custom-linters/cmd
custom-linter-build: # HELP Build custom linter
cd $(LINTER_DIR) && go build -tags '$(GO_BUILD_TAGS)' -o $(ROOT_DIR)/bin/custom-linter
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joelanford you suggested
go build ./hack/ci/custom-linters/cmd/ -o ./bin/custom-linter
But it does not work.

.PHONY: custom-linter-build
LINTER_DIR := hack/ci/custom-linters
custom-linter-build: # HELP Build custom linter
	go build -tags '$(GO_BUILD_TAGS)' -o $(ROOT_DIR)/bin/custom-linter $(ROOT_DIR)/$(LINTER_DIR)/cmd
make custom-linter-build
go build -tags 'containers_image_openpgp' -o /Users/camilam/go/src/github/operator-framework/operator-controller/bin/custom-linter /Users/camilam/go/src/github/operator-framework/operator-controller/hack/ci/custom-linters/cmd
main module (github.com/operator-framework/operator-controller) does not contain package github.com/operator-framework/operator-controller/hack/ci/custom-linters/cmd
make: *** [custom-linter-build] Error 1

I am missing something silly here.
but anyway that does not seems to be a big deal.

@camilamacedo86
Copy link
Contributor Author

Hi @joelanford

IHMO we can improve more here. However, wdyt is that acceptable to get merged and when we have time, can we work more on this one?

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.

Fix issues with logging flag validations
4 participants