Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

pmap: Let brick choose it's own port #1257

Merged
merged 2 commits into from Oct 4, 2018

Conversation

prashanthpai
Copy link
Contributor

With glusterfs change https://review.gluster.org/21249, glusterd2 can choose
to not to pass an explicit port when starting brick process. The brick process
shall choose a free port provided by the kernel and reports this port number
to glusterd2 via a SIGN IN request.

The pmap package will no longer manage and track available free ports. This
means that running multiple glusterd2 instances on same machine (e2e) are
now not prone to races in finding a free port to assign to a brick.

Fixes #924
Signed-off-by: Prashanth Pai ppai@redhat.com

With glusterfs change https://review.gluster.org/21249, glusterd2 can choose
to not to pass an explicit port when starting brick process. The brick process
shall choose a free port provided by the kernel and reports this port number
to glusterd2 via a SIGN IN request.

The pmap package will no longer manage and track available free ports. This
means that running multiple glusterd2 instances on same machine (e2e) are
now not prone to races in finding a free port to assign to a brick.

Signed-off-by: Prashanth Pai <ppai@redhat.com>
@ghost ghost assigned prashanthpai Oct 3, 2018
@ghost ghost added the in progress label Oct 3, 2018
@prashanthpai
Copy link
Contributor Author

Sample output:

[ppai@gd2-1 glusterd2]$ glustercli volume status test
Volume : test
+--------------------------------------+-----------+---------------------+--------+-------+-------+
|               BRICK ID               |   HOST    |        PATH         | ONLINE | PORT  |  PID  |
+--------------------------------------+-----------+---------------------+--------+-------+-------+
| bedf6c5c-859d-4f52-9b68-523e0f4b9cdd | 127.0.0.1 | /export/brick1/data | true   | 46501 | 29081 |
| 28c10e8e-f8c9-4131-a4a1-b36dcfb1e6eb | 127.0.0.1 | /export/brick2/data | true   | 40467 | 29103 |
| b1664b0e-9abf-4d8c-8ef6-3bf0ba9fb168 | 127.0.0.1 | /export/brick3/data | true   | 44037 | 29125 |
| 867d1cc5-743e-46d9-b3ce-166d612bcc2f | 127.0.0.1 | /export/brick4/data | true   | 45479 | 29147 |
+--------------------------------------+-----------+---------------------+--------+-------+-------+
[ppai@gd2-1 glusterd2]$ glustercli volume stop test
Volume test stopped successfully
[ppai@gd2-1 glusterd2]$ glustercli volume status test
Volume : test
+--------------------------------------+-----------+---------------------+--------+------+-----+
|               BRICK ID               |   HOST    |        PATH         | ONLINE | PORT | PID |
+--------------------------------------+-----------+---------------------+--------+------+-----+
| 28c10e8e-f8c9-4131-a4a1-b36dcfb1e6eb | 127.0.0.1 | /export/brick2/data | false  |    0 |   0 |
| b1664b0e-9abf-4d8c-8ef6-3bf0ba9fb168 | 127.0.0.1 | /export/brick3/data | false  |    0 |   0 |
| 867d1cc5-743e-46d9-b3ce-166d612bcc2f | 127.0.0.1 | /export/brick4/data | false  |    0 |   0 |
| bedf6c5c-859d-4f52-9b68-523e0f4b9cdd | 127.0.0.1 | /export/brick1/data | false  |    0 |   0 |
+--------------------------------------+-----------+---------------------+--------+------+-----+
[ppai@gd2-1 glusterd2]$ glustercli volume start test
Volume test started successfully


[ppai@gd2-1 glusterd2]$ glustercli volume status test
Volume : test
+--------------------------------------+-----------+---------------------+--------+-------+-------+
|               BRICK ID               |   HOST    |        PATH         | ONLINE | PORT  |  PID  |
+--------------------------------------+-----------+---------------------+--------+-------+-------+
| bedf6c5c-859d-4f52-9b68-523e0f4b9cdd | 127.0.0.1 | /export/brick1/data | true   | 35607 | 29190 |
| 28c10e8e-f8c9-4131-a4a1-b36dcfb1e6eb | 127.0.0.1 | /export/brick2/data | true   | 38785 | 29212 |
| b1664b0e-9abf-4d8c-8ef6-3bf0ba9fb168 | 127.0.0.1 | /export/brick3/data | true   | 43205 | 29234 |
| 867d1cc5-743e-46d9-b3ce-166d612bcc2f | 127.0.0.1 | /export/brick4/data | true   | 33987 | 29256 |
+--------------------------------------+-----------+---------------------+--------+-------+-------+
[ppai@gd2-1 glusterd2]$ curl -s -X GET http://127.0.0.1:24007/statedump | grep pmap
"pmap": {"ports":{"33987":{"/export/brick4/data":{}},"35607":{"/export/brick1/data":{}},"38785":{"/export/brick2/data":{}},"43205":{"/export/brick3/data":{}}}},

Signed-off-by: Prashanth Pai <ppai@redhat.com>
for i := 1000; i <= (r.basePort + 100); i++ {
r.ports[i].State = PortLeased
}
basePort := 49152
Copy link
Member

Choose a reason for hiding this comment

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

How are you sure about this? Should this be 1024?

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 is arbitrary. It can be anything in the range 1024 to 65535.

Copy link
Member

@amarts amarts left a comment

Choose a reason for hiding this comment

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

Other than the tests where you set basePort as 49152, everything else LGTM

Copy link
Member

@aravindavk aravindavk left a comment

Choose a reason for hiding this comment

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

LGTM

@prashanthpai prashanthpai merged commit 39fc7ab into gluster:master Oct 4, 2018
@ghost ghost removed the in progress label Oct 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants