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

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

Merged
merged 1 commit into from
Apr 28, 2024

Conversation

TCeason
Copy link
Collaborator

@TCeason TCeason commented Apr 28, 2024

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

  • Logic Test

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

This change is Reviewable

@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Apr 28, 2024
@TCeason
Copy link
Collaborator Author

TCeason commented Apr 28, 2024

cc @wubx

@BohuTANG
Copy link
Member

In cloud, the client ip will be gateway?

@TCeason
Copy link
Collaborator Author

TCeason commented Apr 28, 2024

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.

pub fn get_client_ip(req: &Request) -> Option<String> {

Copy link
Member

@flaneur2020 flaneur2020 left a comment

Choose a reason for hiding this comment

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

oh, i think using databend/src/query/service/src/servers/http/middleware.rs get_client_ip might be better

@flaneur2020
Copy link
Member

flaneur2020 commented Apr 28, 2024

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
Copy link
Collaborator Author

TCeason commented Apr 28, 2024

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

@flaneur2020
Copy link
Member

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 🤔

@sundy-li sundy-li added this pull request to the merge queue Apr 28, 2024
@sundy-li sundy-li removed this pull request from the merge queue due to a manual request Apr 28, 2024
@BohuTANG BohuTANG merged commit f7e30c4 into datafuselabs:main Apr 28, 2024
72 checks passed
@TCeason
Copy link
Collaborator Author

TCeason commented Apr 28, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix this PR patches a bug in codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

show processlist host is NULL
5 participants