Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
allgo
allgo
Commits
f47c63be
Commit
f47c63be
authored
Feb 09, 2017
by
BAIRE Anthony
Browse files
fix race condition
parent
772f9100
Changes
1
Hide whitespace changes
Inline
Side-by-side
docker/controller.py
View file @
f47c63be
...
...
@@ -1110,7 +1110,8 @@ class JobManager(Manager):
# pull the image to the swarm
if
info
.
ver_id
is
not
None
:
# FIXME: race condition: will fail if ver.state==sandbox
# NOTE: race condition: will fail if ver.state==sandbox
# jobs must be submitted after the image is committed
yield
from
ctrl
.
image_manager
.
pull
(
info
.
ver_id
,
swarm
=
True
)
# lock the semaphore (to limit the total number of jobs)
...
...
@@ -1187,6 +1188,8 @@ class PushManager(Manager):
log
.
info
(
"push from the %-8s %s:%s"
,
"sandbox"
,
image
,
tag
)
yield
from
self
.
run_in_executor
(
docker_check_error
,
self
.
ctrl
.
sandbox
.
push
,
image
,
tag
)
reset
()
with
ses
.
begin
():
prev
=
ses
.
query
(
WebappVersion
).
filter_by
(
webapp_id
=
version
.
webapp_id
,
...
...
@@ -1202,16 +1205,10 @@ class PushManager(Manager):
for
key
in
"updated_at"
,
"changelog"
,
"published"
:
setattr
(
prev
,
key
,
getattr
(
version
,
key
))
# TODO get rid of this 'replaced' state (and delete the record immediately)
# The 'replaced' state was introduced to avoid a race condition
# if multiple tasks are calling push() concurrently. If
# the version row is deleted, then the second call to push()).
# However this 'replaced' state does not need to be
# written to the db (because is only important for the
# running controller process). We could use another way
# of storing this state.
# mark this version as replaced
# TODO: purge this entry after some time
version
.
state
=
int
(
VersionState
.
replaced
)
ses
.
add
(
version
)
class
ImageManager
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment