Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kolla Ansible
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Very Demiurge Very Mindful
Kolla Ansible
Commits
2e829acd
Commit
2e829acd
authored
9 years ago
by
Jenkins
Committed by
Gerrit Code Review
9 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Add retries to build.py"
parents
d3d7777e
4bce5cca
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/build.py
+19
-18
19 additions, 18 deletions
tools/build.py
with
19 additions
and
18 deletions
tools/build.py
+
19
−
18
View file @
2e829acd
...
@@ -12,11 +12,7 @@
...
@@ -12,11 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
# TODO(SamYaple): Allow image pushing
# TODO(SamYaple): Single image building w/ optional parent building
# TODO(SamYaple): Single image building w/ optional parent building
# TODO(SamYaple): Build only missing images
# TODO(SamYaple): Execute the source install script that will pull
# down and create tarball
# TODO(jpeeler): Add clean up handler for SIGINT
# TODO(jpeeler): Add clean up handler for SIGINT
import
argparse
import
argparse
...
@@ -33,7 +29,6 @@ import sys
...
@@ -33,7 +29,6 @@ import sys
import
tempfile
import
tempfile
from
threading
import
Thread
from
threading
import
Thread
import
time
import
time
import
traceback
import
docker
import
docker
import
jinja2
import
jinja2
...
@@ -47,11 +42,12 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
...
@@ -47,11 +42,12 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
class
WorkerThread
(
Thread
):
class
WorkerThread
(
Thread
):
def
__init__
(
self
,
queue
,
nocache
,
keep
,
thread
s
):
def
__init__
(
self
,
queue
,
arg
s
):
self
.
queue
=
queue
self
.
queue
=
queue
self
.
nocache
=
nocache
self
.
nocache
=
args
[
'
no_cache
'
]
self
.
forcerm
=
not
keep
self
.
forcerm
=
not
args
[
'
keep
'
]
self
.
threads
=
threads
self
.
retries
=
args
[
'
retries
'
]
self
.
threads
=
args
[
'
threads
'
]
self
.
dc
=
docker
.
Client
(
**
docker
.
utils
.
kwargs_from_env
())
self
.
dc
=
docker
.
Client
(
**
docker
.
utils
.
kwargs_from_env
())
Thread
.
__init__
(
self
)
Thread
.
__init__
(
self
)
...
@@ -60,13 +56,14 @@ class WorkerThread(Thread):
...
@@ -60,13 +56,14 @@ class WorkerThread(Thread):
while
True
:
while
True
:
try
:
try
:
data
=
self
.
queue
.
get
(
block
=
False
)
data
=
self
.
queue
.
get
(
block
=
False
)
self
.
builder
(
data
)
for
_
in
range
(
self
.
retries
):
self
.
builder
(
data
)
if
data
[
'
status
'
]
in
[
'
built
'
,
'
parent_error
'
]:
break
self
.
queue
.
task_done
()
self
.
queue
.
task_done
()
except
Queue
.
Empty
:
except
Queue
.
Empty
:
break
break
except
Exception
:
traceback
.
print_exc
()
self
.
queue
.
task_done
()
def
process_source
(
self
,
source
,
dest_dir
):
def
process_source
(
self
,
source
,
dest_dir
):
if
source
.
get
(
'
type
'
)
==
'
url
'
:
if
source
.
get
(
'
type
'
)
==
'
url
'
:
...
@@ -87,8 +84,8 @@ class WorkerThread(Thread):
...
@@ -87,8 +84,8 @@ class WorkerThread(Thread):
LOG
.
info
(
'
Processing: {}
'
.
format
(
image
[
'
name
'
]))
LOG
.
info
(
'
Processing: {}
'
.
format
(
image
[
'
name
'
]))
image
[
'
status
'
]
=
"
building
"
image
[
'
status
'
]
=
"
building
"
if
(
image
[
'
parent
'
]
is
not
None
and
if
image
[
'
parent
'
]
is
not
None
and
\
image
[
'
parent
'
][
'
status
'
]
==
"
error
"
)
:
image
[
'
parent
'
][
'
status
'
]
in
[
'
error
'
,
'
parent_error
'
]
:
image
[
'
status
'
]
=
"
parent_error
"
image
[
'
status
'
]
=
"
parent_error
"
return
return
...
@@ -116,7 +113,7 @@ class WorkerThread(Thread):
...
@@ -116,7 +113,7 @@ class WorkerThread(Thread):
if
'
errorDetail
'
in
stream
:
if
'
errorDetail
'
in
stream
:
image
[
'
status
'
]
=
"
error
"
image
[
'
status
'
]
=
"
error
"
LOG
.
error
(
stream
[
'
errorDetail
'
][
'
message
'
])
LOG
.
error
(
stream
[
'
errorDetail
'
][
'
message
'
])
r
aise
Exception
(
stream
[
'
errorDetail
'
][
'
message
'
])
r
eturn
image
[
'
status
'
]
=
"
built
"
image
[
'
status
'
]
=
"
built
"
...
@@ -166,6 +163,10 @@ def argParser():
...
@@ -166,6 +163,10 @@ def argParser():
'
logging.)
'
,
'
logging.)
'
,
type
=
int
,
type
=
int
,
default
=
8
)
default
=
8
)
parser
.
add_argument
(
'
-r
'
,
'
--retries
'
,
help
=
'
The number of times to retry while building
'
,
type
=
int
,
default
=
3
)
parser
.
add_argument
(
'
--template
'
,
parser
.
add_argument
(
'
--template
'
,
help
=
'
Create dockerfiles from templates
'
,
help
=
'
Create dockerfiles from templates
'
,
action
=
'
store_true
'
,
action
=
'
store_true
'
,
...
@@ -340,6 +341,7 @@ class KollaWorker(object):
...
@@ -340,6 +341,7 @@ class KollaWorker(object):
image
[
'
name
'
]
+
'
:
'
+
self
.
tag
image
[
'
name
'
]
+
'
:
'
+
self
.
tag
image
[
'
path
'
]
=
path
image
[
'
path
'
]
=
path
image
[
'
parent
'
]
=
content
.
split
(
'
'
)[
1
].
split
(
'
\n
'
)[
0
]
image
[
'
parent
'
]
=
content
.
split
(
'
'
)[
1
].
split
(
'
\n
'
)[
0
]
if
self
.
namespace
not
in
image
[
'
parent
'
]:
if
self
.
namespace
not
in
image
[
'
parent
'
]:
image
[
'
parent
'
]
=
None
image
[
'
parent
'
]
=
None
...
@@ -418,8 +420,7 @@ def main():
...
@@ -418,8 +420,7 @@ def main():
# Returns a list of Queues for us to loop through
# Returns a list of Queues for us to loop through
for
pool
in
pools
:
for
pool
in
pools
:
for
x
in
xrange
(
args
[
'
threads
'
]):
for
x
in
xrange
(
args
[
'
threads
'
]):
WorkerThread
(
pool
,
args
[
'
no_cache
'
],
args
[
'
keep
'
],
WorkerThread
(
pool
,
args
).
start
()
args
[
'
threads
'
]).
start
()
# block until queue is empty
# block until queue is empty
pool
.
join
()
pool
.
join
()
...
...
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