Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.core
Commits
00459999
There was a problem fetching the pipeline summary.
Commit
00459999
authored
6 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Get an actual free random port instead of a random port number
parent
16d368b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!32
Merge development branch 1.6.x
,
!19
New Conda-based CI/CD Pipelines
Pipeline
#
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
beat/core/execution/docker.py
+2
-3
2 additions, 3 deletions
beat/core/execution/docker.py
beat/core/execution/subprocess.py
+1
-2
1 addition, 2 deletions
beat/core/execution/subprocess.py
beat/core/utils.py
+17
-0
17 additions, 0 deletions
beat/core/utils.py
with
20 additions
and
5 deletions
beat/core/execution/docker.py
+
2
−
3
View file @
00459999
...
...
@@ -32,7 +32,6 @@ import os
import
requests
import
simplejson
import
zmq
import
random
import
logging
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -254,7 +253,7 @@ class DockerExecutor(RemoteExecutor):
# Creation of the container
# Note: we only support one databases image loaded at the same time
database_port
=
random
.
randint
(
51000
,
60000
)
database_port
=
utils
.
find_free_port
(
)
cmd
=
[
'
databases_provider
'
,
...
...
@@ -293,7 +292,7 @@ class DockerExecutor(RemoteExecutor):
break
databases_container
.
reset_ports
()
database_port
=
random
.
randint
(
51000
,
60000
)
database_port
=
utils
.
find_free_port
(
)
cmd
=
[
x
if
not
x
.
startswith
(
'
0.0.0.0:
'
)
else
'
0.0.0.0:%d
'
%
database_port
for
x
in
cmd
]
databases_container
.
command
=
cmd
...
...
This diff is collapsed.
Click to expand it.
beat/core/execution/subprocess.py
+
1
−
2
View file @
00459999
...
...
@@ -33,7 +33,6 @@ from __future__ import absolute_import
import
os
import
requests
import
zmq
import
random
import
sys
import
subprocess
as
sp
import
tempfile
...
...
@@ -240,7 +239,7 @@ class SubprocessExecutor(RemoteExecutor):
#----- (If necessary) Instantiate the subprocess that provide the databases
databases_process
=
None
database_port
=
random
.
randint
(
51000
,
60000
)
database_port
=
utils
.
find_free_port
(
)
if
len
(
self
.
databases
)
>
0
:
...
...
This diff is collapsed.
Click to expand it.
beat/core/utils.py
+
17
−
0
View file @
00459999
...
...
@@ -29,6 +29,8 @@
import
os
import
sys
import
tempfile
import
socket
import
contextlib
import
numpy
import
simplejson
...
...
@@ -66,6 +68,9 @@ def uniq(seq):
return
result
#----------------------------------------------------------
def
send_multipart
(
socket
,
parts
):
"""
Send the parts through the socket after having encoded them if
...
...
@@ -77,3 +82,15 @@ def send_multipart(socket, parts):
parts
[
index
]
=
item
.
encode
(
'
utf-8
'
)
socket
.
send_multipart
(
parts
)
#----------------------------------------------------------
def
find_free_port
():
'''
Returns the value of a free random port
'''
with
contextlib
.
closing
(
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
))
as
s
:
s
.
bind
((
''
,
0
))
return
s
.
getsockname
()[
1
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment