Fill APE Request proprties with source IP in services #1142

Merged
fyrchik merged 3 commits from aarifullin/frostfs-node:feat/ape_sourceip into master 2024-05-27 10:17:21 +00:00
Member
  • container: Fill APE-request property with source IP
  • object: Fill APE-request with source IP property
  • tree: Fill APE-request with source IP property
* container: Fill APE-request property with source IP * object: Fill APE-request with source IP property * tree: Fill APE-request with source IP property
aarifullin force-pushed feat/ape_sourceip from 356c6c1cb7 to 80f28b82a7 2024-05-20 13:37:09 +00:00 Compare
aarifullin requested review from storage-core-committers 2024-05-20 13:37:13 +00:00
aarifullin requested review from storage-core-developers 2024-05-20 13:37:30 +00:00
fyrchik reviewed 2024-05-21 09:51:48 +00:00
@ -378,2 +386,4 @@
return nil, nil, err
}
if p, ok := peer.FromContext(ctx); ok {
reqProps[commonschema.PropertyKeyFrostFSSourceIP] = p.Addr.String()
Owner

net.Addr is an interface and it can contain port. The port is random for outgoing connections and we are probably interested in the IP only.
Is it explicit in the spec?

`net.Addr` is an interface and it can contain port. The port is random for outgoing connections and we are probably interested in the IP only. Is it explicit in the spec?
Owner
@dkirillov
Member

We need only IP

We need only IP
Author
Member

I have fixed that. Please, check this out

if p, ok := peer.FromContext(ctx); ok {
   addr, err := net.ResolveTCPAddr("", p.Addr.String())
   if err != nil {
			return nil, nil, err
    }
	reqProps[commonschema.PropertyKeyFrostFSSourceIP] = addr.IP.String()
}

Since, tcp-address is parsed and IP is put to the property

I have fixed that. Please, check this out ```go if p, ok := peer.FromContext(ctx); ok { addr, err := net.ResolveTCPAddr("", p.Addr.String()) if err != nil { return nil, nil, err } reqProps[commonschema.PropertyKeyFrostFSSourceIP] = addr.IP.String() } ``` Since, tcp-address is parsed and IP is put to the property
Owner

Have you checked what type is returned here? I believe it shoud be TCPAddr as we provide TCP listener to the gRPC server. ResolveTCPAddr can consult DNS, which is definitely what we do not want to do.

Have you checked what type is returned here? I believe it shoud be `TCPAddr` as we provide TCP listener to the gRPC server. `ResolveTCPAddr` can consult DNS, which is definitely what we do not want to do.
Author
Member

ResolveTCPAddr can consult DNS, which is definitely what we do not want to do.

Sorry, I don't get your point. Let it be able to consult DNS, but

we provide TCP listener to the gRPC server.

so, peer.Addr is coming within context as tcp 192.92.9.2:4032. So, it successfully parses the tcp address and we keep IP in addr.IP

> ResolveTCPAddr can consult DNS, which is definitely what we do not want to do. Sorry, I don't get your point. Let it be able to consult DNS, but >we provide TCP listener to the gRPC server. so, `peer.Addr` is coming within context as tcp `192.92.9.2:4032`. So, it successfully parses the tcp address and we keep `IP` in `addr.IP`
Author
Member

Okay, I got it. Fixed as you requested 👍

Okay, I got it. Fixed as you requested 👍
fyrchik requested review from dkirillov 2024-05-21 14:49:18 +00:00
aarifullin force-pushed feat/ape_sourceip from 80f28b82a7 to 409c3ae2ff 2024-05-21 15:42:54 +00:00 Compare
dkirillov approved these changes 2024-05-23 08:11:07 +00:00
dkirillov left a comment
Member

LGTM

LGTM
aarifullin force-pushed feat/ape_sourceip from 409c3ae2ff to 297e4b4984 2024-05-24 11:17:33 +00:00 Compare
aarifullin requested review from dkirillov 2024-05-24 11:20:03 +00:00
fyrchik approved these changes 2024-05-27 07:31:26 +00:00
acid-ant approved these changes 2024-05-27 08:00:38 +00:00
@ -133,3 +134,3 @@
t.Run("missing signature, no panic", func(t *testing.T) {
require.Error(t, s.verifyClient(req, cid2, nil, op))
require.Error(t, s.verifyClient(context.TODO(), req, cid2, nil, op))
Member

You are planning to extend these tests with proper context? Why not to use Background() here?

You are planning to extend these tests with proper context? Why not to use `Background()` here?
Author
Member

Fixed

Fixed
aarifullin force-pushed feat/ape_sourceip from 297e4b4984 to 75881cf908 2024-05-27 09:06:01 +00:00 Compare
acid-ant approved these changes 2024-05-27 09:33:41 +00:00
fyrchik merged commit 3627b44e92 into master 2024-05-27 10:17:21 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1142
No description provided.