Skip to content

Fixed condition, when local dns lookup should happen. #1272

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

Merged

Conversation

ulikl
Copy link
Contributor

@ulikl ulikl commented Jul 26, 2024

Bug was introduced with option proxy_from_enviroment with release V0.24.
fixes Issue #1154

@ulikl ulikl force-pushed the fix-SkipResolvePhaseWithProxy branch 2 times, most recently from 0412f5a to 54ea96b Compare July 30, 2024 09:13
@github-actions github-actions bot added the stale label Dec 30, 2024
@github-actions github-actions bot removed the stale label Dec 31, 2024
@ulikl ulikl force-pushed the fix-SkipResolvePhaseWithProxy branch from 827c1a4 to 94f8094 Compare May 5, 2025 10:08
ulikl and others added 2 commits May 5, 2025 13:44
Bug was introduced with option proy_from_enviroment with release V0.24.

Signed-off-by: Ulrike Klusik <[email protected]>
Signed-off-by: Urike Klusik <[email protected]>
@ulikl ulikl force-pushed the fix-SkipResolvePhaseWithProxy branch from 94f8094 to 9d42375 Compare May 5, 2025 12:24
@ulikl
Copy link
Contributor Author

ulikl commented May 12, 2025

@electron0zero: when are you planning to build a new release, where this fix could be included?

@ulikl
Copy link
Contributor Author

ulikl commented Jun 3, 2025

@electron0zero : Can this be merged to main?

@@ -1686,7 +1688,39 @@ func TestSkipResolvePhase(t *testing.T) {

checkMetrics(expectedMetrics, mfs, t)
})
t.Run("With Proxy", func(t *testing.T) {
t.Run("With Proxy and resolve", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

is this test name correct? I see the SkipResolvePhaseWithProxy: false is false? same for the With Proxy and without resolve test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see what should be wrong for "With Proxy and resolve".
SkipResolvePhaseWithProxy: false means resolve is used.
The default is with resolve.

Here the grep on the new versions for all tests with the resolve settings. They look of for me.
$ git grep -n -i resolve prober/http_test.go prober/http_test.go:1612: "resolve": {}, prober/http_test.go:1653:func TestSkipResolvePhase(t *testing.T) { prober/http_test.go:1662: // Note: just tested, if local resolve is done or not via metrics. No proxy with diffent resolving available. prober/http_test.go:1669: config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, HTTPClientConfig: pconfig.DefaultHTTPClientConfig, SkipResolvePhaseWithProxy: true}}, registry, promslog.NewNopLogger()) prober/http_test.go:1682: "resolve": {}, prober/http_test.go:1691: t.Run("With Proxy and resolve", func(t *testing.T) { prober/http_test.go:1704: config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, HTTPClientConfig: httpCfg, SkipResolvePhaseWithProxy: false}}, registry, promslog.NewNopLogger()) prober/http_test.go:1714: "resolve": {}, prober/http_test.go:1723: t.Run("With Proxy and without resolve", func(t *testing.T) { prober/http_test.go:1736: config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, HTTPClientConfig: httpCfg, SkipResolvePhaseWithProxy: true}}, registry, promslog.NewNopLogger()) prober/http_test.go:1754: t.Run("With Proxy from env var and without resolve", func(t *testing.T) { prober/http_test.go:1762: config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, HTTPClientConfig: httpCfg, SkipResolvePhaseWithProxy: true}}, registry, promslog.NewNopLogger()) prober/http_test.go:1780: t.Run("With Proxy from env var and with resolve", func(t *testing.T) { prober/http_test.go:1788: config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, HTTPClientConfig: httpCfg, SkipResolvePhaseWithProxy: false}}, registry, promslog.NewNopLogger()) prober/http_test.go:1798: "resolve": {},

Copy link
Member

Choose a reason for hiding this comment

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

sorry, that double negation is making it hard to read and reason about.

let's simplify the chained OR and AND condition where negation on already negated config SkipResolvePhaseWithProxy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test have been compacted.

@@ -1659,6 +1659,8 @@ func TestSkipResolvePhase(t *testing.T) {
}))
defer ts.Close()

// Note: just tested, if local resolve is done or not via metrics. No proxy with diffent resolving available.
Copy link
Member

Choose a reason for hiding this comment

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

can we reword or remove this comment? I am not sure what this comment is trying to say?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this better?
// Note: just testing via metrics, if local DNS resolve is executed or not. We have in the test setup no proxy with different DNS resolution available.

Copy link
Member

Choose a reason for hiding this comment

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

I am still not sure what is comment is saying, maybe we can drop this and add a more local comment inside the test or drop this comment altogether.

Copy link
Contributor Author

@ulikl ulikl Jun 5, 2025

Choose a reason for hiding this comment

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

Test have been refactored.
I would keep test test on ProbeHttp, as these also test if all the other Proxy configurations are working.
The comment was moved. I hope it makes more sense now.

@electron0zero
Copy link
Member

@electron0zero : Can this be merged to main?

left some review comments, can you address them?

@berkitamas berkitamas force-pushed the fix-SkipResolvePhaseWithProxy branch from 19ade87 to 0a9ab0a Compare June 5, 2025 10:41
@ulikl
Copy link
Contributor Author

ulikl commented Jun 5, 2025

@electron0zero : Can you please have another look at the refactored code?

Signed-off-by: Tamas Berki <[email protected]>
Copy link
Member

@electron0zero electron0zero left a comment

Choose a reason for hiding this comment

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

thank you for your contribution 👏🏼

@electron0zero electron0zero merged commit f77c50e into prometheus:master Jun 6, 2025
5 checks passed
SuperQ added a commit that referenced this pull request Jun 26, 2025
* [FEATURE] Support matching JSON body with CEL expressions #1255
* [BUGFIX] Fix condition when local dns lookup should happen #1272
* [BUGFIX] Stop scrape logger spam #1381

Signed-off-by: SuperQ <[email protected]>
@SuperQ SuperQ mentioned this pull request Jun 26, 2025
SuperQ added a commit that referenced this pull request Jun 30, 2025
* [FEATURE] Support matching JSON body with CEL expressions #1255
* [BUGFIX] Fix condition when local dns lookup should happen #1272
* [BUGFIX] Stop scrape logger spam #1381

Signed-off-by: SuperQ <[email protected]>
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.

4 participants