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

Adding a sync() function to filetarget #293

Merged
merged 5 commits into from
Feb 13, 2019
Merged

Adding a sync() function to filetarget #293

merged 5 commits into from
Feb 13, 2019

Conversation

slim-bean
Copy link
Collaborator

I still want to add a test to verify the sync function will remove files properly.

I ran into a circular imports issue when adding a config to the FileTarget, because the targets package depends on the api package for ScrapeConfig, so if I put the FileTarget config in the targets package it creates a circular import.
I think it made most sense to put the TargetConfig in the api package rather than move the ScrapeConfig to the target package. Though this leads me to think all the other configs (positions, client) should also be moved to the api package for consistency?
I'm also open to another solution if I'm missing something obvious

@tomwilkie
Copy link
Contributor

Re: config structs, I tend to put them alongside the structs that they configure, to prevent circular imports. The only alternative is having them all in one place, and that means everything tends to import the config package, which I don't like.

@tomwilkie
Copy link
Contributor

Re: config structs, I tend to put them alongside the structs that they configure, to prevent circular imports. The only alternative is having them all in one place, and that means everything tends to import the config package, which I don't like.

@tomwilkie
Copy link
Contributor

Given the complexity of the sync code, I'm coming round to the idea of removing the ionotify watcher and just relying on sync. WDYT?

@slim-bean
Copy link
Collaborator Author

To move the TargetConfig struct back to the targets package we would have to move the ScrapeConfig out of the api package and put it somewhere else to avoid the circular import, thoughts on what a good place for it would be?

@slim-bean
Copy link
Collaborator Author

slim-bean commented Feb 7, 2019

Re: the ionotify watcher, I was playing around yesterday with how the tailer works, and when pointed at a new file it will start at the beginning and "catch up" so to speak, so the polling nature of the sync function should work just fine. I'll think about it a little more but at the moment I don't think the event driven ionotify watcher is gaining us anything except some additional complexity and I would support removing it.

@woodsaj
Copy link
Member

woodsaj commented Feb 8, 2019

move the targetConfig struct to the targets package and move the Config struct to its own package, eg mv api/{config,entry_parser}.go to config/

that should resolve address the circular dependency issues

@slim-bean slim-bean force-pushed the refactor-sync branch 4 times, most recently from 602651e to 28c76a0 Compare February 11, 2019 02:56
@slim-bean slim-bean changed the title [WIP]Adding a sync() function to filetarget Adding a sync() function to filetarget Feb 11, 2019
@slim-bean
Copy link
Collaborator Author

I think I'd like to bring up removing the fsnotify code in another issue/PR and get this merged as it's already getting hard to review with the refactorings

@slim-bean
Copy link
Collaborator Author

Updated based on feedback, cleaned up the sync function and simplified as much as I could, also attempted to reuse code between the fsnotify watcher stuff so there shouldn't be any duplicated logic in there as well either.

@tomwilkie
Copy link
Contributor

Sorry @slim-bean! Super nit picky. But its super close now.

…osed in testing, we want to stop the tailer before shutting down our tailer loop
moved tailer to its own file
refactoring filetarget to make synclogic easier to follow and reused as much as possible
@@ -7,3 +7,4 @@ cmd/loki/loki
cmd/promtail/promtail
/loki
/promtail
.idea/
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats this? Probably belongs in ~/.gitignore and then do git config --global core.excludesfile $HOME/.gitignore

@@ -27,8 +29,7 @@ func TestLongSyncDelayStillSavesCorrectPosition(t *testing.T) {

err := os.MkdirAll(dirName, 0750)
if err != nil {
t.Error(err)
return
t.Fatal(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should have mentioned this earlier, but I prefer require.NoError(t, err) instead of these 3 lines. We can come back and tidy this up.

Copy link
Contributor

@tomwilkie tomwilkie left a comment

Choose a reason for hiding this comment

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

One nit about using require in tests, but lets merge and fix that up later.

@tomwilkie tomwilkie merged commit f6d0857 into master Feb 13, 2019
@tomwilkie tomwilkie deleted the refactor-sync branch February 13, 2019 11:29
trevorwhitney added a commit that referenced this pull request Aug 23, 2023
This changes the forGivenIngestors function in
pkg/querier/ingester_querier.go to use `DoUntilQuorum` (from [PR
#293](grafana/dskit#293)) instead of `Do`.

`DoUntilQuorum` is much more efficient than `Do`. The exact differences
between them can be seen
[here](grafana/dskit#293).

---------

Co-authored-by: Trevor Whitney <trevorjwhitney@gmail.com>
periklis pushed a commit to periklis/loki that referenced this pull request Sep 10, 2024
Update from upstream repository
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