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 metrics controller races #1379

Merged
merged 1 commit into from
Mar 1, 2022
Merged

Fix metrics controller races #1379

merged 1 commit into from
Mar 1, 2022

Conversation

tzneal
Copy link
Contributor

@tzneal tzneal commented Feb 18, 2022

1. Issue, if available:
N/A

2. Description of changes:
add some race testing and fix two identified issues

3. How was this change tested?
ginkgo -r --race

4. Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: link to issue
  • No

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

@netlify
Copy link

netlify bot commented Feb 18, 2022

✔️ Deploy Preview for karpenter-docs-prod canceled.

🔨 Explore the source changes: fa560ee

🔍 Inspect the deploy log: https://app.netlify.com/sites/karpenter-docs-prod/deploys/621e8fc178b08100081ed257

@tzneal tzneal force-pushed the fix-test-races branch 2 times, most recently from 03733db to 5fcbe73 Compare February 18, 2022 15:09
@tzneal tzneal changed the title Fix test races Fix metrics controller races Feb 18, 2022
@ellistarn
Copy link
Contributor

I'm a bit wary of ExpectRaceFree, though I'll admit it's pretty cool.

  • I'd prefer to catch this sort of thing in e2e tests, where the raceable scope is much larger. I recognize that we won't be using -race in this environment, though
  • I worry that this might give us a false sense of security that our tests won't race
  • In general, testing that something doesn't happen I really hard, since there are an infinite number of things that won't happen. I could see an argument for specific cases like paralleism/racing, but I'd prefer to limit our package testing to behavior checking to catch regressions.
  • I'm a bit wary of the time added to CI tests (how fast is this?)

@tzneal
Copy link
Contributor Author

tzneal commented Feb 20, 2022

I'm a bit wary of ExpectRaceFree, though I'll admit it's pretty cool.

  • I'd prefer to catch this sort of thing in e2e tests, where the raceable scope is much larger. I recognize that we won't be using -race in this environment, though

You can build with -race, though it will run much slower. That's probably the best solution as a -race e2e test should negate the need for this entirely.

  • I worry that this might give us a false sense of security that our tests won't race

  • In general, testing that something doesn't happen I really hard, since there are an infinite number of things that won't happen. I could see an argument for specific cases like paralleism/racing, but I'd prefer to limit our package testing to behavior checking to catch regressions.

On the other hand, the test does expose two bugs :)

  • I'm a bit wary of the time added to CI tests (how fast is this?)

The 50 objects * 5 runs was to hopefully trip an issue like a concurrent map write during normal unit tests. You can just create two objects and run them once to trigger detection with the race detector, so time should be negligible in that case.

Possible solution is to just fix the two bugs and create an issue to ensure that at least some e2e test runs on a -race build?

@ellistarn
Copy link
Contributor

Possible solution is to just fix the two bugs and create an issue to ensure that at least some e2e test runs on a -race build?

Perfect.

@tzneal tzneal force-pushed the fix-test-races branch 2 times, most recently from b09bd3d to 4d291a8 Compare February 22, 2022 00:37
- use a sync.Map
- make some struct members non-public
- add some tests that exercise the maps
@ellistarn ellistarn merged commit 3936cd6 into aws:main Mar 1, 2022
@tzneal tzneal deleted the fix-test-races branch March 3, 2022 02:13
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.

2 participants