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

Flag to add active query tracker. #5555

Merged
merged 7 commits into from Aug 6, 2022
Merged

Conversation

metonymic-smokey
Copy link
Contributor

@metonymic-smokey metonymic-smokey commented Jul 30, 2022

Signed-off-by: Aditi Ahuja ahuja.aditi@gmail.com
Fixes #5521

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Added a new flag which creates a query.active file in the filepath specified by the flag.

Verification

yeya24
yeya24 previously approved these changes Jul 30, 2022
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Love this change. LGTM.

Fixes part of #5521

For this pr, I feel it is good to fix 5521. If you plan to also add the UI part of the active queries I would say let's do it in another PR.

Let's also fix docs and add a changelog entry

@metonymic-smokey metonymic-smokey marked this pull request as ready for review July 30, 2022 16:47
@metonymic-smokey metonymic-smokey changed the title Flag to add file to track active queries. Flag to add active query tracker. Jul 30, 2022
@metonymic-smokey metonymic-smokey marked this pull request as draft July 30, 2022 17:10
@metonymic-smokey
Copy link
Contributor Author

Thanks @yeya24 :)
This breaks the E2E tests and I have a feeling it's due to the fact that they're run in containers. This seems to be an existing issue - prometheus/prometheus#5976

Looking into how I can fix this failing test.
Thanks!

Dockerfile Outdated Show resolved Hide resolved
cmd/thanos/query.go Outdated Show resolved Hide resolved
saswatamcode
saswatamcode previously approved these changes Jul 31, 2022
Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

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

Thanks for awesome work! This would be awesome to have! 🌟

Some tiny suggestions to fix CI!

@@ -345,6 +345,9 @@ func (q *QuerierBuilder) collectArgs() ([]string, error) {

args = append(args, "--store.sd-files="+filepath.Join(q.InternalDir(), "filesd.yaml"))
}

args = append(args, "--query.active-query-path="+q.InternalDir())
Copy link
Member

Choose a reason for hiding this comment

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

So this breaks a test, specifically the TestQueryCompatibilityWithPreInfoAPI e2e test, reason being that we use specific images for the test cases on that one here. The new -query.active-query-path flag won't exist on any image but the latest, so this cannot be an always-enabled option. 🙂

Maybe you can address @GiedriusS's comment and make the flag optional, and add a new WithActiveQueryTracker method on QuerierBuilder and use that instead in a dedicated e2e test which checks for this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So from my attempts at an E2E test, I think the same issues that plagued this PR during CI will occur during an E2E test. The issue I'm referring to is related to container permissions and seems to be a known issue: prometheus/prometheus#5976.
Is there any alternative way I could try?

Copy link
Contributor

Choose a reason for hiding this comment

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

After making this flag optional in E2E and add WithActiveQueryTracker then you should be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pushed a draft of the test I created and I have added these but I still face an issue.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, what I think you could do is maybe execute a command, to change permissions for the data dir, as mentioned in this comment! 🙂

Copy link
Member

Choose a reason for hiding this comment

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

It might be a bit too difficult to make it work in an e2e setup, so I think it would be fine to skip an e2e test for this. But maybe you can document this issue in Querier docs instead? So users are aware of the implications of using this! 🙂

docs/components/query.md Outdated Show resolved Hide resolved
@yeya24
Copy link
Contributor

yeya24 commented Aug 1, 2022

@metonymic-smokey I think this feature is ready for merge now. Can you please mark it as ready for review?

@metonymic-smokey
Copy link
Contributor Author

@yeya24 marked it as ready, but I think I need to add an E2E test right?

@yeya24
Copy link
Contributor

yeya24 commented Aug 2, 2022

Yeah, please add it.

@metonymic-smokey
Copy link
Contributor Author

@GiedriusS @yeya24 pls take a final look at this when you're free :)

docs/components/query.md Outdated Show resolved Hide resolved
Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

We should also pass the parameter here. That code creates different engines for different lookback deltas depending on the parameters. Thus, I suggest creating subdirectories like raw, 5m and 1h for the different engines in the provided directory. Maybe you could even move the creation of the ActiveQueryTracker to that function because you will possibly need to create multiple trackers

Signed-off-by: Aditi Ahuja <ahuja.aditi@gmail.com>
Signed-off-by: Aditi Ahuja <ahuja.aditi@gmail.com>
Signed-off-by: Aditi Ahuja <ahuja.aditi@gmail.com>
Signed-off-by: Aditi Ahuja <ahuja.aditi@gmail.com>
Signed-off-by: Aditi Ahuja <ahuja.aditi@gmail.com>
Signed-off-by: Aditi Ahuja <ahuja.aditi@gmail.com>
saswatamcode
saswatamcode previously approved these changes Aug 4, 2022
Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

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

Awesome work! LGTM!

cmd/thanos/query.go Outdated Show resolved Hide resolved
cmd/thanos/query.go Outdated Show resolved Hide resolved
resActiveQueryDir := filepath.Join(activeQueryDir, getActiveQueryDirBasedOnResolution(r))
newEngineOpts.ActiveQueryTracker = promql.NewActiveQueryTracker(resActiveQueryDir, maxConcurrentQueries, logger)
} else {
newEngineOpts.ActiveQueryTracker = eo.ActiveQueryTracker
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this else block? If activeQueryDir is empty string then the ActiveQueryTracker is just nil if I understand correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yeya24 in the current implementation, this line explicitly adds eo.ActiveQueryTracker

ActiveQueryTracker: eo.ActiveQueryTracker,
.
I have attempted to retain that when I added the else.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove it to avoid confusion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or you could add a comment about it is nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done.
If possible could you please retrigger the CI tests once again?
Thanks!

Signed-off-by: Aditi Ahuja <ahuja.aditi@gmail.com>
Copy link
Contributor

@yeya24 yeya24 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 for the great work!

@yeya24 yeya24 merged commit 79a6335 into thanos-io:main Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

query: implement active query tracker
4 participants