-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Change default values for two GRPC setting we have to set so the queriers can connect to a frontend or scheduler #4435
Merged
+102
−1
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package loki | ||
|
||
import ( | ||
"bytes" | ||
"flag" | ||
"io" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestFlagDefaults(t *testing.T) { | ||
c := Config{} | ||
|
||
f := flag.NewFlagSet("test", flag.PanicOnError) | ||
c.RegisterFlags(f) | ||
|
||
buf := bytes.Buffer{} | ||
|
||
f.SetOutput(&buf) | ||
f.PrintDefaults() | ||
|
||
const delim = '\n' | ||
|
||
minTimeChecked := false | ||
pingWithoutStreamChecked := false | ||
for { | ||
line, err := buf.ReadString(delim) | ||
if err == io.EOF { | ||
break | ||
} | ||
|
||
require.NoError(t, err) | ||
|
||
if strings.Contains(line, "-server.grpc.keepalive.min-time-between-pings") { | ||
nextLine, err := buf.ReadString(delim) | ||
require.NoError(t, err) | ||
assert.Contains(t, nextLine, "(default 10s)") | ||
minTimeChecked = true | ||
} | ||
|
||
if strings.Contains(line, "-server.grpc.keepalive.ping-without-stream-allowed") { | ||
nextLine, err := buf.ReadString(delim) | ||
require.NoError(t, err) | ||
assert.Contains(t, nextLine, "(default true)") | ||
pingWithoutStreamChecked = true | ||
} | ||
} | ||
|
||
require.True(t, minTimeChecked) | ||
require.True(t, pingWithoutStreamChecked) | ||
|
||
require.Equal(t, true, c.Server.GRPCServerPingWithoutStreamAllowed) | ||
require.Equal(t, 10*time.Second, c.Server.GRPCServerMinTimeBetweenPings) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: how is it different than just changing default values of those two configs directly in
c.Server.RegisterFlags
?It's confusing because, all our default values are in
c.Server.RegisterFlags()
currently. And IMHO, its bit odd to move only those two into separate function with throwaway flagset :)I see you tried explaining it in the comment. But I think I failed to understand what that exactly means and why it matters here :( Shouldn't this be treated as normal default values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kavirajk
c.Server.RegisterFlags()
is defined in theweaveworks/common
library. We could make a PR into that if we think this is a better default for all cases, but I'm not sure if that's the case. I think we need to change this because of something to do specifically with memberlist. They're currently using the grpc defaults which they might prefer to keep. Either way, I still think this makes sense in the meantime to override them here until such a PR is made and merged.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wish there were a better way.