Create snapshots when min-ready is >= 0

Currently, if min-ready is 0 a snapshot will not be created (nodepool
considers the image to be disabled). Now if min-ready is greater than or
equal 0, nodepool will create the snapshot.  The reason for the change is to
allow jenkins slaves to be offline waiting for a new job to be submitted. Once
a new job is submit, nodepool will properly launch a slave node from the
snapshot.

Additionally, min-ready is now optional and defaults to 2. If min-ready is -1
the snapshot will not be created (label becomes disabled).

Closes-Bug: #1299172

Change-Id: I7094a76b09266c00c0290d84ae0a39b6c2d16215
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
This commit is contained in:
Paul Belanger 2014-03-29 16:57:08 +00:00
parent 933a7e80dc
commit 1b904ec697
2 changed files with 8 additions and 5 deletions

View File

@ -106,9 +106,11 @@ providers or images are used to create them). Example::
providers:
- name: provider1
The `name`, `image`, and `min-ready` keys are required. The
`providers` list is also required if any nodes should actually be
created (e.g., the label is not currently disabled).
The `name` and `image` keys are required. The `providers` list is
also required if any nodes should actually be created (e.g., the
label is not currently disabled). The `min-ready` key is optional
and defaults to 2. If the value is -1 the label is considered
disabled.
The `subnodes` key is used to configure multi-node support. If a
`subnodes` key is supplied to an image, it indicates that the specified

View File

@ -907,7 +907,7 @@ class NodePool(threading.Thread):
l.name = label['name']
newconfig.labels[l.name] = l
l.image = label['image']
l.min_ready = label['min-ready']
l.min_ready = label.get('min-ready', 2)
l.subnodes = label.get('subnodes', 0)
l.ready_script = label.get('ready-script')
l.providers = {}
@ -1315,7 +1315,8 @@ class NodePool(threading.Thread):
# outside of its schedule.
self.log.debug("Checking missing images.")
for label in self.config.labels.values():
if not label.min_ready:
if label.min_ready < 0:
# Label is configured to be disabled, skip creating the image.
continue
for provider_name in label.providers:
found = False