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

Create shared server for loki.source.+ network targets #3581

Merged
merged 29 commits into from
May 3, 2023

Conversation

thepalbi
Copy link
Contributor

@thepalbi thepalbi commented Apr 20, 2023

PR Description

This PR is a port of this Promtail PR: grafana/loki#9181.

Flow supports many loki.source that expose a network server, which underneath uses weaveworks commons server. When configuring this server, there's usually some boilerplate code to apply some defaults, scope the metrics under a namespace to avoid collisions, etc.

This PR creates an abstraction that we can re-use on these kind of sources.

Which issue(s) this PR fixes

Notes to the Reviewer

PR Checklist

  • CHANGELOG updated
  • Documentation added
  • Tests updated

@thepalbi thepalbi requested a review from tpaschalis April 20, 2023 20:46
component/common/loki/http/config.go Outdated Show resolved Hide resolved
component/common/loki/http/server_test.go Outdated Show resolved Hide resolved
@thepalbi
Copy link
Contributor Author

@tpaschalis still have some docs to add, and some cleanup, but let me know if this goes in the right direction

Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

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

I think we're heading to the right direction. Looking forward to seeing how this progresses!

component/common/loki/http/config.go Outdated Show resolved Hide resolved
component/common/loki/http/config.go Outdated Show resolved Hide resolved
component/common/loki/http/config.go Outdated Show resolved Hide resolved
component/common/loki/http/server.go Outdated Show resolved Hide resolved
thampiotr
thampiotr previously approved these changes Apr 27, 2023
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.

LGMT, though I'm pretty new to this codebase.

I'm looking forward to this merging so I can incorporate the changes to my PR #3648

component/common/loki/http/config.go Outdated Show resolved Hide resolved
component/loki/source/heroku/heroku.go Show resolved Hide resolved
component/common/loki/http/server.go Outdated Show resolved Hide resolved
component/common/loki/http/server.go Outdated Show resolved Hide resolved
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.

Got a few more questions as I was working on docs for a new component.

component/loki/source/heroku/heroku.go Show resolved Hide resolved
@thampiotr thampiotr self-requested a review April 27, 2023 13:24
@thampiotr thampiotr dismissed their stale review April 27, 2023 13:25

Got a few more questions

@thepalbi
Copy link
Contributor Author

@tpaschalis @thampiotr added all settings to the config model as discussed above, and added some tests covering the river unmarshalling. Will add the docs tomorrow

@thepalbi
Copy link
Contributor Author

@tpaschalis @thampiotr added the docs, leaving some Qs on how to best organize them

@thepalbi
Copy link
Contributor Author

thepalbi commented May 2, 2023

@thampiotr @tpaschalis should be good now

Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

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

LGTM, just a few documentation-related nits and we're good to go!

Comment on lines 96 to 100
// If set, override. Don't allow a zero-value since it configure a context.WithTimeout, so the user should at least
// give a >0 value to it
if c.GracefulShutdownTimeout != 0 {
cfg.ServerGracefulShutdownTimeout = c.GracefulShutdownTimeout
}
Copy link
Member

Choose a reason for hiding this comment

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

Just to make sure, what happens when the user does not set this? Is the "30s" default applied? I'm not sure where exactly this happened.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, covered by this test and applied in here that applies the defaults from the server cli flags

component/common/loki/net/config.go Outdated Show resolved Hide resolved

Name | Type | Description | Default | Required
------------------------|------------|----------------------------------------------------------------------------------------------------------------------|----------|----------
`listen_address` | `string` | Network address on which the server will listen for new connections. Defaults to accepting all incoming connections. | `""` | no
Copy link
Member

Choose a reason for hiding this comment

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

Is the default here 0.0.0.0?

Copy link
Contributor Author

@thepalbi thepalbi May 3, 2023

Choose a reason for hiding this comment

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

Nop, is empty string which has the same effect of listening to tcp conns from every incoming ip. Explained here. Either way we could display it as 0.0.0.0 on the docs, but it's explained also in the description column


Name | Type | Description | Default | Required
---------------------------------|------------|----------------------------------------------------------------------------------------------------------------------|--------------|----------
`listen_address` | `string` | Network address on which the server will listen for new connections. Defaults to accepting all incoming connections. | `""` | no
Copy link
Member

Choose a reason for hiding this comment

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

Same here, does the description mean that the default is 0.0.0.0? Or is it implied to be 0.0.0.0 by the weaveworks.Server code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

component/common/loki/net/server.go Outdated Show resolved Hide resolved
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.

LGTM! Just one rename suggestion, happy for this to merge :)

component/common/loki/net/server.go Outdated Show resolved Hide resolved
@thepalbi
Copy link
Contributor Author

thepalbi commented May 3, 2023

@thampiotr @tpaschalis should be good to go now 😃

@tpaschalis
Copy link
Member

Great work @thepalbi 🙌 thanks for making writing Loki components a lot easier!

@tpaschalis tpaschalis merged commit 4a3c4a7 into main May 3, 2023
@tpaschalis tpaschalis deleted the pablo/common-loki-source-http-server branch May 3, 2023 16:24
rfratto pushed a commit to rfratto/agent that referenced this pull request May 11, 2023
@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 27, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 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.

3 participants