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

streaming: fix not being able to enable streaming #10514

Merged
merged 4 commits into from
Jun 28, 2021

Conversation

dnephin
Copy link
Contributor

@dnephin dnephin commented Jun 28, 2021

This PR adds a new X-Consul-Query-Backend response header to make it easier to determine when streaming was used for a query. Adds a check for this header to a few tests that are meant to check that streaming is being used.

And finally fix the bug that was preventing streaming from being enabled on the client.

One commit is cherry-picked from #10396. It removes a test that is both very racy and also no longer valid because the requests are made via streaming, not the cache. Since the cache rate limit functionality is already tested in the appropriate package (agent/cache) it seems like we can remove this failing/flaky test.

So that it is easier to detect and test when streaming is being used.
@dnephin dnephin added type/bug Feature does not function as expected theme/streaming Related to Streaming connections between server and client backport/1.10 labels Jun 28, 2021
@dnephin dnephin requested a review from a team June 28, 2021 20:50
@github-actions github-actions bot added theme/health-checks Health Check functionality type/docs Documentation needs to be created/updated/clarified labels Jun 28, 2021
@hashicorp-ci
Copy link
Contributor

🤔 This PR has changes in the website/ directory but does not have a type/docs-cherrypick label. If the changes are for the next version, this can be ignored. If they are updates to current docs, attach the label to auto cherrypick to the stable-website branch after merging.

@dnephin dnephin force-pushed the dnephin/actually-enable-streaming branch from c8f6ecd to 3356dd1 Compare June 28, 2021 20:55
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 28, 2021 20:55 Inactive
@vercel vercel bot temporarily deployed to Preview – consul June 28, 2021 20:55 Inactive
Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks Daniel!

@dnephin dnephin force-pushed the dnephin/actually-enable-streaming branch from 3356dd1 to 5de306d Compare June 28, 2021 20:57
@vercel vercel bot temporarily deployed to Preview – consul June 28, 2021 20:57 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 28, 2021 20:57 Inactive
dnephin added 3 commits June 28, 2021 17:23
This test is super racy (it's not just a single line).

This test also starts failing once streaming is enabled, because the
cache rate limit no longer applies to the requests in the test. The
queries use streaming instead of the cache.

This test is no longer valid, and the functionality is already well
tested by TestCacheThrottle.  Instead of spending time rewriting this
test, let's remove it.

```
WARNING: DATA RACE
Read at 0x00c01de410fc by goroutine 735:
  github.com/hashicorp/consul/agent.TestCacheRateLimit.func1()
      /home/daniel/pers/code/consul/agent/agent_test.go:1024 +0x9af
  github.com/hashicorp/consul/testrpc.WaitForTestAgent()
      /home/daniel/pers/code/consul/testrpc/wait.go:99 +0x209
  github.com/hashicorp/consul/agent.TestCacheRateLimit.func1()
      /home/daniel/pers/code/consul/agent/agent_test.go:966 +0x1ad
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1193 +0x202

Previous write at 0x00c01de410fc by goroutine 605:
  github.com/hashicorp/consul/agent.TestCacheRateLimit.func1.2()
      /home/daniel/pers/code/consul/agent/agent_test.go:998 +0xe9

Goroutine 735 (running) created at:
  testing.(*T).Run()
      /usr/lib/go/src/testing/testing.go:1238 +0x5d7
  github.com/hashicorp/consul/agent.TestCacheRateLimit()
      /home/daniel/pers/code/consul/agent/agent_test.go:961 +0x375
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1193 +0x202

Goroutine 605 (finished) created at:
  github.com/hashicorp/consul/agent.TestCacheRateLimit.func1()
      /home/daniel/pers/code/consul/agent/agent_test.go:1022 +0x91e
  github.com/hashicorp/consul/testrpc.WaitForTestAgent()
      /home/daniel/pers/code/consul/testrpc/wait.go:99 +0x209
  github.com/hashicorp/consul/agent.TestCacheRateLimit.func1()
      /home/daniel/pers/code/consul/agent/agent_test.go:966 +0x1ad
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1193 +0x202
```
And add checks to all the tests that explicitly use streaming.
If a value was already available in the local view the request is considered a cache hit.
If the materialized had to wait for a value, it is considered a cache miss.
@dnephin dnephin force-pushed the dnephin/actually-enable-streaming branch from 5de306d to bc4d349 Compare June 28, 2021 21:29
@vercel vercel bot temporarily deployed to Preview – consul June 28, 2021 21:29 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 28, 2021 21:29 Inactive
@dnephin dnephin requested review from banks and a team June 28, 2021 21:29
Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

I see, this test is no longer valid now that streaming is actually default and so cache is not being used.

@dnephin dnephin merged commit 1041ba7 into master Jun 28, 2021
@dnephin dnephin deleted the dnephin/actually-enable-streaming branch June 28, 2021 22:52
@hc-github-team-consul-core
Copy link
Collaborator

🍒 If backport labels were added before merging, cherry-picking will start automatically.

To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/399092.

@hc-github-team-consul-core
Copy link
Collaborator

🍒❌ Cherry pick of commit 1041ba7 onto release/1.10.x failed! Build Log

dnephin added a commit that referenced this pull request Jun 29, 2021
…aming

streaming: fix not being able to enable streaming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/health-checks Health Check functionality theme/streaming Related to Streaming connections between server and client type/bug Feature does not function as expected type/docs Documentation needs to be created/updated/clarified
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants