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

chore(pkg/gc): don't rely on core.Now var for time #4918

Merged
merged 1 commit into from
Aug 26, 2022

Conversation

lahabana
Copy link
Contributor

  • Always provide ticker as a parameter to both finalizer and gc
  • Use the time of the ticker instead of core.Now()
  • Rewrite tests to create synthetic ticks
  • Improve logging

Motivation:

Signed-off-by: Charly Molter charly.molter@konghq.com

Checklist prior to review

  • Link to docs PR or issue --
  • Link to UI issue or PR --
  • Is the issue worked on linked? --
  • The PR does not hardcode values that might break projects that depend on kuma (e.g. "kumahq" as a image registry) --
  • The PR will work for both Linux and Windows, system specific functions like syscall.Mkfifo have equivalent implementation on the other OS --
  • Unit Tests --
  • E2E Tests --
  • Manual Universal Tests --
  • Manual Kubernetes Tests --
  • Do you need to update UPGRADE.md? --
  • Does it need to be backported according to the backporting policy? --
  • Do you need to explicitly set a > Changelog: entry here?

- Always provide ticker as a parameter to both finalizer and gc
- Use the time of the ticker instead of `core.Now()`
- Rewrite tests to create synthetic ticks

Motivation:

- Tests would have to rely mutexes and some would expose a race because
of the shared global variable
- We can write very precise tests as we trigger the ticks ourselves
- Not relying on global vars is always an improvement

Signed-off-by: Charly Molter <charly.molter@konghq.com>
@lahabana lahabana requested a review from a team as a code owner August 26, 2022 11:47
Copy link
Contributor

@bartsmykla bartsmykla left a comment

Choose a reason for hiding this comment

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

lgtm

@codecov-commenter
Copy link

Codecov Report

Merging #4918 (76a5a49) into master (3f201b1) will decrease coverage by 0.00%.
The diff coverage is 71.42%.

@@            Coverage Diff             @@
##           master    #4918      +/-   ##
==========================================
- Coverage   46.68%   46.68%   -0.01%     
==========================================
  Files         687      687              
  Lines       46656    46655       -1     
==========================================
- Hits        21781    21779       -2     
  Misses      22966    22966              
- Partials     1909     1910       +1     
Impacted Files Coverage Δ
pkg/gc/components.go 0.00% <0.00%> (ø)
pkg/gc/finalizer.go 78.26% <75.00%> (ø)
pkg/gc/collector.go 63.41% <77.77%> (ø)
pkg/plugins/leader/postgres/leader_elector.go 82.97% <0.00%> (-6.39%) ⬇️
pkg/xds/generator/direct_access_proxy_generator.go 90.90% <0.00%> (+1.13%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@lahabana lahabana merged commit ea550b7 into kumahq:master Aug 26, 2022
@lahabana lahabana deleted the fixRaceCollectorTest branch March 29, 2024 12:45
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.

3 participants