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

test(lint): refactor logs and add linting rules #2045

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

laurentiuNiculae
Copy link
Contributor

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@laurentiuNiculae laurentiuNiculae changed the title Ram log refactor Log refactor Nov 15, 2023
@laurentiuNiculae laurentiuNiculae force-pushed the ram-log-refactor branch 2 times, most recently from 38de96b to d9e774a Compare November 15, 2023 16:51
@rchincha
Copy link
Contributor

Think about this pattern ...

pkg/log/constants.go

const RepoNotFoundMsg = "repo not found"

log.Info().Msg(RepoNotFoundMsg)

@rchincha
Copy link
Contributor

rchincha commented Nov 15, 2023

Error msgs ... to be standardized.

"Failed to ..."
"Error happened ..."
"Unable to ..."

"Failed to <verb>"
(or)
"<verb> failed"

All strings in msgs should be lowercase and not LOWERCASE

Str("component", component).Msg("...")
(instead of)
Msg("component: ....")

@rchincha
Copy link
Contributor

Add a log linter if possible.

@laurentiuNiculae laurentiuNiculae force-pushed the ram-log-refactor branch 3 times, most recently from eab9675 to 7612d2e Compare November 16, 2023 12:58
Copy link

codecov bot commented Nov 16, 2023

Codecov Report

Attention: 104 lines in your changes are missing coverage. Please review.

Comparison is base (37988f1) 92.06% compared to head (363fe94) 92.00%.

Files Patch % Lines
pkg/storage/imagestore/imagestore.go 70.32% 27 Missing ⚠️
pkg/storage/cache/boltdb.go 56.52% 10 Missing ⚠️
pkg/exporter/cli/cli.go 0.00% 8 Missing ⚠️
pkg/cli/server/root.go 86.00% 7 Missing ⚠️
pkg/test/oci-utils/oci_layout.go 68.42% 6 Missing ⚠️
pkg/storage/common/common.go 79.16% 5 Missing ⚠️
pkg/meta/boltdb/boltdb.go 73.33% 4 Missing ⚠️
pkg/api/ldap.go 70.00% 3 Missing ⚠️
pkg/api/routes.go 89.65% 3 Missing ⚠️
pkg/storage/cache/dynamodb.go 70.00% 3 Missing ⚠️
... and 20 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2045      +/-   ##
==========================================
- Coverage   92.06%   92.00%   -0.06%     
==========================================
  Files         165      165              
  Lines       28623    28687      +64     
==========================================
+ Hits        26352    26394      +42     
- Misses       1678     1697      +19     
- Partials      593      596       +3     

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

LINT.sh Outdated Show resolved Hide resolved
@laurentiuNiculae laurentiuNiculae force-pushed the ram-log-refactor branch 5 times, most recently from 8c707a9 to ecf44e1 Compare November 22, 2023 13:27
@andaaron andaaron added this to the v2.0.0 milestone Nov 22, 2023
@laurentiuNiculae laurentiuNiculae force-pushed the ram-log-refactor branch 3 times, most recently from c134a4a to 9df9fc5 Compare November 27, 2023 14:01
@laurentiuNiculae
Copy link
Contributor Author

I have added 2 linting rules for now:

  • log messages must not start with capital letter
  • log messages must not start with the component (as in "metadb: error", "storage: error")

errors/errors.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
pkg/meta/boltdb/boltdb.go Show resolved Hide resolved
pkg/meta/dynamodb/dynamodb.go Show resolved Hide resolved
pkg/meta/hooks.go Outdated Show resolved Hide resolved
pkg/meta/parse.go Outdated Show resolved Hide resolved
pkg/meta/parse.go Outdated Show resolved Hide resolved
pkg/meta/parse.go Outdated Show resolved Hide resolved
pkg/scheduler/scheduler.go Outdated Show resolved Hide resolved
pkg/storage/common/common.go Outdated Show resolved Hide resolved
scripts/check_logs.sh Outdated Show resolved Hide resolved
@laurentiuNiculae laurentiuNiculae force-pushed the ram-log-refactor branch 4 times, most recently from 457c132 to 57aef9f Compare November 28, 2023 13:57
pkg/cli/server/root.go Outdated Show resolved Hide resolved
pkg/meta/boltdb/boltdb.go Outdated Show resolved Hide resolved
pkg/meta/boltdb/boltdb.go Outdated Show resolved Hide resolved
pkg/meta/boltdb/boltdb.go Outdated Show resolved Hide resolved
pkg/meta/dynamodb/dynamodb.go Show resolved Hide resolved
pkg/meta/dynamodb/dynamodb.go Show resolved Hide resolved
pkg/meta/hooks.go Outdated Show resolved Hide resolved
pkg/storage/common/common.go Outdated Show resolved Hide resolved
pkg/storage/gc/gc.go Outdated Show resolved Hide resolved
pkg/storage/gc/gc.go Outdated Show resolved Hide resolved
errors/errors.go Outdated Show resolved Hide resolved
@laurentiuNiculae laurentiuNiculae force-pushed the ram-log-refactor branch 5 times, most recently from 5768ee6 to c5adc1f Compare November 29, 2023 15:49
Copy link
Contributor

@andaaron andaaron left a comment

Choose a reason for hiding this comment

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

Otherwise looks ok

pkg/meta/boltdb/boltdb.go Outdated Show resolved Hide resolved
@andaaron andaaron force-pushed the ram-log-refactor branch 4 times, most recently from 3b8dfc4 to 85914c9 Compare December 7, 2023 13:48
Signed-off-by: Ramkumar Chinchani <[email protected]>
Signed-off-by: Laurentiu Niculae <[email protected]>
Signed-off-by: Andrei Aaron <[email protected]>
Copy link
Contributor

@rchincha rchincha left a comment

Choose a reason for hiding this comment

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

lgtm

@andaaron andaaron merged commit 79e1402 into project-zot:main Dec 8, 2023
31 of 33 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.

4 participants