From 1b904ec6975ce32add89adab8144964901f53504 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Sat, 29 Mar 2014 16:57:08 +0000 Subject: [PATCH] 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 --- doc/source/configuration.rst | 8 +++++--- nodepool/nodepool.py | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 0350355b8..5152cc66b 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -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 diff --git a/nodepool/nodepool.py b/nodepool/nodepool.py index 311bc52db..a2bb13226 100644 --- a/nodepool/nodepool.py +++ b/nodepool/nodepool.py @@ -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