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

clustering: fix handling of empty join-addresses flag #5454

Merged
merged 2 commits into from
Oct 13, 2023

Conversation

tpaschalis
Copy link
Member

PR Description

We recently almost had this bite us when porting the cadvisor integration to a new component.

strings.Split returns the input string itself if the separator is not found; this meant that for an empty flag, strings.Split("", ",") returned a 1-element slice with the empty string, and not an empty slice.

Which issue(s) this PR fixes

Fixes #5449

Notes to the Reviewer

Nothing to note.

PR Checklist

  • CHANGELOG.md updated
  • Documentation added (N/A)
  • Tests updated

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
@tpaschalis tpaschalis marked this pull request as ready for review October 12, 2023 12:52
@tpaschalis tpaschalis requested a review from a team as a code owner October 12, 2023 12:52

func TestBuildClusterService(t *testing.T) {
opts := clusterOptions{
JoinPeers: []string{"foo", "bar"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we have a test with JoinPeers empty string somewhere, or setting a flag to it?

Copy link
Member Author

@tpaschalis tpaschalis Oct 12, 2023

Choose a reason for hiding this comment

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

Yes, looking into it.

Copy link
Member Author

Choose a reason for hiding this comment

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

(sorry, didn't post the comment beforehand).

After taking a look we don't have a good place for putting tests related to flag parsing. I'd like to (sooner or later) move ahead with #4973 which would cover this. I'm merging this to move ahead with the patch release.

Copy link
Contributor

@thampiotr thampiotr left a comment

Choose a reason for hiding this comment

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

Just one comment re: test, but not blocking :) Thanks for the quick fix!

@tpaschalis tpaschalis merged commit 0a5a5aa into grafana:main Oct 13, 2023
9 checks passed
@juyongli
Copy link

Hi, I am the one who reported this defect #108849 grafana-agent-flow clustering mode error. Seems you guys have fixed it. Thanks.

@tpaschalis
Copy link
Member Author

You're welcome @juyongli! Let us know how clustering works for you and any other feedback you may have!

tpaschalis added a commit to tpaschalis/agent that referenced this pull request Oct 16, 2023
Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
(cherry picked from commit 0a5a5aa)
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Feb 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clustering: fix condition for mutual exclusivity of join-addresses and discover-peers
3 participants