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

wire up all prometheus proxy config settings for flow and the converters #6306

Merged
merged 14 commits into from
Feb 9, 2024

Conversation

erikbaranowski
Copy link
Contributor

@erikbaranowski erikbaranowski commented Feb 5, 2024

PR Description

Wires in the 3 additional proxy configurations from promtheus to the http client config and elsewhere. I improved some code along the way and called out discrepancies between docs and code.

Which issue(s) this PR fixes

Closes #6261
Closes #5110

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

@@ -33,63 +33,44 @@ func (h *HTTPClientConfig) SetToDefault() {

// Validate returns an error if h is invalid.
func (h *HTTPClientConfig) Validate() error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This refactor pushes the responsibility for validating other types to their own Validate funcs except for ProxyConfig (squashed). It also tries to more sanely handle the scenarios where only 1 auth method can be set. I think this code got more and more convoluted over time.

}
}

func (p *ProxyConfig) Validate() error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -228,5 +228,5 @@ func TestHTTPClientBadConfig(t *testing.T) {

var httpClientConfig HTTPClientConfig
err := river.Unmarshal([]byte(exampleRiverConfig), &httpClientConfig)
require.ErrorContains(t, err, "at most one of bearer_token & bearer_token_file must be configured")
require.ErrorContains(t, err, "at most one of basic_auth password & password_file must be configured")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In some cases, the error changed because the order of validation will be different. I don't think this is harmful.

return err
}

return a.ProxyConfig.Validate()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to explicitly validate squashed properties

@@ -27,5 +27,5 @@ func TestBadRiverConfig(t *testing.T) {
// Make sure the squashed HTTPClientConfig Validate function is being utilized correctly
var args Arguments
err := river.Unmarshal([]byte(exampleRiverConfig), &args)
require.ErrorContains(t, err, "at most one of bearer_token & bearer_token_file must be configured")
require.ErrorContains(t, err, "at most one of basic_auth, authorization, oauth2, bearer_token & bearer_token_file must be configured")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These error messages got longer to encapsulate all potential overlapping auths.

@@ -29,6 +33,10 @@ func TestConvert(t *testing.T) {
TagSeparator: ";",
HTTPClientConfig: config.HTTPClientConfig{
BearerToken: "FOO",
BasicAuth: &config.BasicAuth{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prove out that an undocumented block could be set on the component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This component brings in portions of http client config and not the whole thing.

@erikbaranowski erikbaranowski marked this pull request as ready for review February 6, 2024 21:04
@erikbaranowski erikbaranowski requested a review from a team as a code owner February 6, 2024 21:04
`

// Make sure the squashed HTTPClientConfig Validate function is being utilized correctly
var args Arguments
err := river.Unmarshal([]byte(exampleRiverConfig), &args)
require.ErrorContains(t, err, "at most one of bearer_token & bearer_token_file must be configured")
require.ErrorContains(t, err, "at most one of basic_auth password & password_file must be configured")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prove that the cascading validation is happening for properties on HttpClientConfig

Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

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

LGTM % some final comments and pending a review from @clayton-cornell :)

Copy link
Contributor

@clayton-cornell clayton-cornell left a comment

Choose a reason for hiding this comment

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

Some comments. Since they apply to all doc files, I commented once with a suggestion. It's a lot easier to search/replace in your local branch vs a large number of identical suggested changes.

Copy link
Collaborator

@mattdurham mattdurham left a comment

Choose a reason for hiding this comment

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

Kubelet change seems reasonable though I doubt it actually supports all the auth parameters , but I guess that’s part of sharing. Either way this is better

@clayton-cornell clayton-cornell added the type/docs Docs Squad label across all Grafana Labs repos label Feb 8, 2024
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.

Huge chunk of work, nice one @erikbaranowski 🙌

@erikbaranowski erikbaranowski merged commit 47ce94b into main Feb 9, 2024
11 checks passed
@erikbaranowski erikbaranowski deleted the prom-proxy-configs branch February 9, 2024 16:15
BarunKGP pushed a commit to BarunKGP/grafana-agent that referenced this pull request Feb 20, 2024
…ers (grafana#6306)

* wire up all prometheus proxy config settings for flow and the converters

Signed-off-by: erikbaranowski <[email protected]>

* document new proxy client configs and fix a few undocumented args

Signed-off-by: erikbaranowski <[email protected]>

* document places where http client config was used for args but undocumented.

Signed-off-by: erikbaranowski <[email protected]>

* wire in proxy config for oauth2 and document

refactor http client config validation

Signed-off-by: erikbaranowski <[email protected]>

---------

Signed-off-by: erikbaranowski <[email protected]>
@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 Mar 11, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 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. type/docs Docs Squad label across all Grafana Labs repos
Projects
None yet
6 participants