datafuselabs / databend

๐——๐—ฎ๐˜๐—ฎ, ๐—”๐—ป๐—ฎ๐—น๐˜†๐˜๐—ถ๐—ฐ๐˜€ & ๐—”๐—œ. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.29k stars 701 forks source link

fix(query): show processlit host is null in HTTPQuery #15363

Closed TCeason closed 2 weeks ago

TCeason commented 2 weeks ago

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Fix show processlit host is null in HTTPQuery.

In HTTP auth , init the client addr.

Tests

Type of change


This change isโ€‚Reviewable

TCeason commented 2 weeks ago

cc @wubx

BohuTANG commented 2 weeks ago

In cloud, the client ip will be gateway?

TCeason commented 2 weeks ago

In cloud, the client ip will be gateway?

cc @flaneur2020 @ZhiHanZ Cloud you please answer this question?

BTW, we had a method get_client_ip it use the same way to parse req.uri.

https://github.com/datafuselabs/databend/blob/0d07cc648aff07c230c8b7dcc5fae249094bd4ed/src/query/service/src/servers/http/middleware.rs#L116

flaneur2020 commented 2 weeks ago

In cloud, the client ip will be gateway?

not only cloud, whenever you put a proxy up front of the query instances, you will get the ip of the proxy.

when you had a proxy, it'd better to utilize the get_client_ip() method to get the real client ip which proxy added into the headers like X-Real-IP.

TCeason commented 2 weeks ago

In cloud, the client ip will be gateway?

not only cloud, whenever you put a proxy up front of the query instances, you will get the ip of the proxy.

when you had a proxy, it'd better to utilize the get_client_ip() method to get the real client ip which proxy added into the headers like X-Real-IP.

So in cloud it will display as null? Because only a IP can not parse as socketaddr.

https://github.com/datafuselabs/databend/issues/15359#issuecomment-2081412247

Here the host is ip:port

flaneur2020 commented 2 weeks ago

In cloud, the client ip will be gateway?

not only cloud, whenever you put a proxy up front of the query instances, you will get the ip of the proxy. when you had a proxy, it'd better to utilize the get_client_ip() method to get the real client ip which proxy added into the headers like X-Real-IP.

So in cloud it will display as null? Because only a IP can not parse as socketaddr.

#15359 (comment)

Here the host is ip:port

IMHO it will be filled up with the proxy's ip address ๐Ÿค”

TCeason commented 2 weeks ago

In cloud, the client ip will be gateway?

not only cloud, whenever you put a proxy up front of the query instances, you will get the ip of the proxy. when you had a proxy, it'd better to utilize the get_client_ip() method to get the real client ip which proxy added into the headers like X-Real-IP.

So in cloud it will display as null? Because only a IP can not parse as socketaddr. #15359 (comment) Here the host is ip:port

IMHO it will be filled up with the proxy's ip address ๐Ÿค”

Does the show procelist need to display ports?

Now the get client ip address will be obtained from the header. But this is a pure ip, and it's represented by a string.

In our current session ctx, client_ip is Option.

This appears to be CK-compatible behavior. But the port should be meaningless information.

So you want to set session _ctx.client_ip: Option and discard the port.