Add pause support for diskimages
There are times where you want to disable diskimage builds happening by nodepool-builder. For example, if diskimage-builder is producing broken images. In this example, we'd want to pause image builds and roll back to a good image. This prevents nodepool-builder from replacing the good image with a potentially bad one. Change-Id: Ib39e1914598a8007cccc31e261099dd7565b7527 Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
1e4955e773
commit
4d3ae444b4
|
@ -237,6 +237,7 @@ on this configuration::
|
|||
|
||||
diskimages:
|
||||
- name: devstack-precise
|
||||
pause: False
|
||||
rebuild-age: 86400
|
||||
- ubuntu
|
||||
- vm
|
||||
|
@ -274,6 +275,9 @@ on this configuration::
|
|||
Arbitrary environment variables that will be available in the spawned
|
||||
diskimage-builder child process.
|
||||
|
||||
``pause`` (bool)
|
||||
When set to True, nodepool-builder will not build the diskimage.
|
||||
|
||||
.. _provider:
|
||||
|
||||
provider
|
||||
|
|
|
@ -457,6 +457,10 @@ class BuildWorker(BaseWorker):
|
|||
if diskimage.name not in self._config.images_in_use:
|
||||
return
|
||||
|
||||
# Check if diskimage builds are paused.
|
||||
if diskimage.pause:
|
||||
return
|
||||
|
||||
now = int(time.time())
|
||||
builds = self._zk.getMostRecentBuilds(1, diskimage.name, zk.READY)
|
||||
|
||||
|
@ -512,6 +516,10 @@ class BuildWorker(BaseWorker):
|
|||
'''
|
||||
Query ZooKeeper for a manual image build request for one image.
|
||||
'''
|
||||
# Check if diskimage builds are paused.
|
||||
if diskimage.pause:
|
||||
return
|
||||
|
||||
# Reduce use of locks by adding an initial check here and
|
||||
# a redundant check after lock acquisition.
|
||||
if not self._zk.hasBuildRequest(diskimage.name):
|
||||
|
|
|
@ -174,6 +174,10 @@ class NodePoolCmd(NodepoolApp):
|
|||
raise Exception("Trying to build a non disk-image-builder "
|
||||
"image: %s" % diskimage)
|
||||
|
||||
if self.pool.config.diskimages[diskimage].pause:
|
||||
raise Exception(
|
||||
"Skipping build request for image %s; paused" % diskimage)
|
||||
|
||||
self.zk.submitBuildRequest(diskimage)
|
||||
|
||||
def alien_list(self):
|
||||
|
|
|
@ -264,6 +264,7 @@ def loadConfig(config_path):
|
|||
# "should be a dict" % d.name)
|
||||
d.env_vars = {}
|
||||
d.image_types = set()
|
||||
d.pause = bool(diskimage.get('pause', False))
|
||||
# Do this after providers to build the image-types
|
||||
for provider in newconfig.providers.values():
|
||||
for image in provider.images.values():
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
script-dir: .
|
||||
elements-dir: .
|
||||
images-dir: '{images_dir}'
|
||||
|
||||
cron:
|
||||
check: '*/15 * * * *'
|
||||
cleanup: '*/1 * * * *'
|
||||
|
||||
zmq-publishers:
|
||||
- tcp://localhost:8881
|
||||
|
||||
gearman-servers:
|
||||
- host: localhost
|
||||
port: {gearman_port}
|
||||
|
||||
zookeeper-servers:
|
||||
- host: {zookeeper_host}
|
||||
port: {zookeeper_port}
|
||||
chroot: {zookeeper_chroot}
|
||||
|
||||
labels:
|
||||
- name: fake-label
|
||||
image: fake-image
|
||||
min-ready: 1
|
||||
providers:
|
||||
- name: fake-provider
|
||||
- name: fake-label2
|
||||
image: fake-image2
|
||||
min-ready: 1
|
||||
providers:
|
||||
- name: fake-provider
|
||||
|
||||
providers:
|
||||
- name: fake-provider
|
||||
region-name: fake-region
|
||||
keypair: 'if-present-use-this-keypair'
|
||||
username: 'fake'
|
||||
password: 'fake'
|
||||
auth-url: 'fake'
|
||||
project-id: 'fake'
|
||||
max-servers: 96
|
||||
pool: 'fake'
|
||||
networks:
|
||||
- net-id: 'some-uuid'
|
||||
rate: 0.0001
|
||||
images:
|
||||
- name: fake-image
|
||||
min-ram: 8192
|
||||
name-filter: 'Fake'
|
||||
meta:
|
||||
key: value
|
||||
key2: value
|
||||
- name: fake-image2
|
||||
min-ram: 8192
|
||||
|
||||
targets:
|
||||
- name: fake-target
|
||||
|
||||
diskimages:
|
||||
- name: fake-image
|
||||
pause: True
|
||||
elements:
|
||||
- fedora
|
||||
- vm
|
||||
release: 21
|
||||
env-vars:
|
||||
TMPDIR: /opt/dib_tmp
|
||||
DIB_IMAGE_CACHE: /opt/dib_cache
|
||||
DIB_CLOUD_IMAGES: http://download.fedoraproject.org/pub/fedora/linux/releases/test/21-Beta/Cloud/Images/x86_64/
|
||||
BASE_IMAGE_FILE: Fedora-Cloud-Base-20141029-21_Beta.x86_64.qcow2
|
||||
- name: fake-image2
|
||||
elements:
|
||||
- fedora
|
||||
- vm
|
||||
release: 21
|
||||
env-vars:
|
||||
TMPDIR: /opt/dib_tmp
|
||||
DIB_IMAGE_CACHE: /opt/dib_cache
|
||||
DIB_CLOUD_IMAGES: http://download.fedoraproject.org/pub/fedora/linux/releases/test/21-Beta/Cloud/Images/x86_64/
|
||||
BASE_IMAGE_FILE: Fedora-Cloud-Base-20141029-21_Beta.x86_64.qcow2
|
|
@ -20,6 +20,7 @@ from unittest import skip
|
|||
|
||||
import fixtures
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from nodepool.cmd import nodepoolcmd
|
||||
from nodepool import tests
|
||||
|
@ -121,6 +122,23 @@ class TestNodepoolCMD(tests.DBTestCase):
|
|||
self.waitForImage('fake-provider', 'fake-image')
|
||||
self.assert_listed(configfile, ['dib-image-list'], 4, zk.READY, 1)
|
||||
|
||||
def test_dib_image_build_pause(self):
|
||||
configfile = self.setup_config('node_diskimage_pause.yaml')
|
||||
self._useBuilder(configfile)
|
||||
self.patch_argv("-c", configfile, "image-build", "fake-image")
|
||||
with testtools.ExpectedException(Exception):
|
||||
nodepoolcmd.main()
|
||||
self.assert_listed(configfile, ['dib-image-list'], 1, 'fake-image', 0)
|
||||
|
||||
def test_dib_image_pause(self):
|
||||
configfile = self.setup_config('node_diskimage_pause.yaml')
|
||||
self._useBuilder(configfile)
|
||||
pool = self.useNodepool(configfile, watermark_sleep=1)
|
||||
pool.start()
|
||||
self.waitForNodes(pool)
|
||||
self.assert_listed(configfile, ['dib-image-list'], 1, 'fake-image', 0)
|
||||
self.assert_listed(configfile, ['dib-image-list'], 1, 'fake-image2', 1)
|
||||
|
||||
def test_dib_image_delete(self):
|
||||
configfile = self.setup_config('node.yaml')
|
||||
pool = self.useNodepool(configfile, watermark_sleep=1)
|
||||
|
|
Loading…
Reference in New Issue