Commit Graph

55 Commits

Author SHA1 Message Date
David Shrewsbury 511ffd9c29
Add tox functional testing for drivers
Reorganizes the unit tests into a new subdirectory, and
adds a new functional test subdirectory (that will be further
divided into subdirs for drivers).

Change-Id: I027bba619deef9379d293fdd0457df6a1377aea8
2018-11-01 15:33:44 +01:00
Markus Hosch 185f59d97d Add metric for image build result
Add a metric that shows on a per-image basis whether an image build was
successful or not.

Change-Id: I8e97017dd3f91cebef3791168371b29899b83389
2018-09-05 09:39:47 +02:00
Zuul 0d5f50b4e2 Merge "Fix adding qcow2 format without need" 2018-06-06 21:18:02 +00:00
Tobias Henkel 6ec75970b3
Fix adding qcow2 format without need
Currently nodepool is defaulting to the qcow2 if no format was given
in the diskimage config. However nodepool also can auto-detect the
image format based on clouds.yaml. This is not taken into account
leading to qcow2 added when using raw-only clouds and auto-detection.

This can be fixed by delaying the fallback to the point where we
actually do the build.

Change-Id: Ic1d9b5abd837a3225cc13da30a80ebf1dda61b64
2018-06-06 21:58:21 +02:00
James E. Blair e20858755f Have Drivers create Providers
Use the new Driver class to create instances of Providers

Change-Id: Idfbde8d773a971133b49fbc318385893be293fac
2018-06-06 14:57:40 -04:00
James E. Blair baa831192f Store build logs automatically
This updates the builder to store individual build logs in dedicated
files, one per build, named for the image and build id.  Old logs are
automatically pruned.  By default, they are stored in
/var/log/nodepool/builds, but this can be changed.

This removes the need to specially configure logging handler for the
image build logs.

Change-Id: Ia7415d2fbbb320f8eddc4e46c3a055414df5f997
2018-02-09 07:50:20 -08:00
Tristan Cacqueray d0a67878a3 Add a plugin interface for drivers
This change adds a plugin interface so that driver can be loaded dynamically.
Instead of importing each driver in the launcher, provider_manager and config,
the Drivers class discovers and loads driver from the driver directory.

This change also adds a reset() method to the driver Config interface to
reset the os_client_config reference when reloading the OpenStack driver.

Change-Id: Ia347aa2501de0e05b2a7dd014c4daf1b0a4e0fb5
2018-01-19 00:45:56 +00:00
Zuul a5173f8f46 Merge "Do pep8 housekeeping according to zuul rules" into feature/zuulv3 2018-01-17 17:07:28 +00:00
Tobias Henkel 7d79770840 Do pep8 housekeeping according to zuul rules
The pep8 rules used in nodepool are somewhat broken. In preparation to
use the pep8 ruleset from zuul we need to fix the findings upfront.

Change-Id: I9fb2a80db7671c590cdb8effbd1a1102aaa3aff8
2018-01-17 02:17:45 +00:00
David Shrewsbury 26b122d131 Rename _useBuilder method to useBuilder
Consistency in method naming and usage is good...  mmmkay?

Change-Id: I87d1d54807dd73f74ad86fb72ad4c8d98fbd5acb
2018-01-10 22:23:59 +00:00
Tristan Cacqueray b01227c9d4 Move the fakeprovider module to the fake driver
This change is a follow-up to the drivers spec and it makes the fake provider
a real driver. The fakeprovider module is merged into the fake provider and
the get_one_cloud config loader is simplified.

Change-Id: I3f8ae12ea888e7c2a13f246ea5f85d4a809e8c8d
2017-07-28 11:35:07 +00:00
Jenkins d574f6d6ab Merge "Support UUID as builder identifier" into feature/zuulv3 2017-07-26 15:41:59 +00:00
Tristan Cacqueray 4d201328f5 Collect request handling implementation in an OpenStack driver
This change moves OpenStack related code to a driver. To avoid circular
import, this change also moves the StatsReporter to the stats module so that
the handlers doesn't have to import the launcher.

Change-Id: I319ce8780aa7e81b079c3f31d546b89eca6cf5f4
Story: 2001044
Task: 4614
2017-07-25 14:27:17 +00:00
Tristan Cacqueray 27b600ee2c Abstract Nodepool provider management code
This change adds a generic Provider meta class to the common
driver module to support multiple implementation. It also renames
some method to better match other drivers use-cases, e.g.:
* listServers into listNodes
* cleanupServer into cleanupNode

Change-Id: I6fab952db372312f12e57c6212f6ebde59a1a6b3
Story: 2001044
Task: 4612
2017-07-25 14:27:13 +00:00
David Shrewsbury fcc68b8fd6 Support UUID as builder identifier
We currently use the hostname of the builder host as the
identifier for the owner of built images. This value is
recorded in ZooKeeper and is used to make sure that only
the owner of an image build ever deletes the entry from
ZooKeeper.

Using hostname can be problematic if it ever changes. It will
cause orphaned builds that will not get deleted. This change
allows us to use a UUID as the identifier, deprecating use of
hostname altogether (although we continue storing that info).
The UUID will be stored in a file in the images directory so
that it may persist across nodepool-builder restarts.

In order to help with transitioning existing builders to using
UUID instead of hostname, the code will always compare the UUID
value AND the hostname so that existing ZK entries will be
matched until they age away.

Change-Id: Ifafbab9fb0f41564cc1af595586fa7353ce1d0d0
2017-07-19 11:46:30 -04:00
Paul Belanger 841f120ff6
Rename nodepool.py to launcher.py
Since we are working towards python3 support, lets rename nodepool.py
to launcher.py to make relative imports nicer, otherwise we'd have to
use:

  from . import foo

Change-Id: Ic38b6a8c2bf25d53625e159cb135b71d383b700c
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-05-17 15:19:47 -04:00
Paul Belanger 78dcd29fa3 Disable CleanupWorker thread for test_image_upload_fail
We currently have a race condition between our cleanup worker and our
unit test. My hope is, if we agree to disable the CleanupWorker thread
for the test, we still consider this a valid test.

Change-Id: I04b87ef044de7f99cc9cbd0c08747e53d383693b
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-02-17 10:50:09 -05:00
Paul Belanger b740c8907e Disable test_image_upload_fail
This test is currently flapping and needs to be reworked. Disable
again as not to side track the PTG effort.

Change-Id: I23ed4024fc3d2b906c2ae4702042ed65ce020a6b
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-02-17 09:44:28 -05:00
Paul Belanger b5b3ad84d0 Re-enable test_image_upload_fail test
Update test to use new zookeeper syntax.

Change-Id: I2ace2f1f9e0827ab391821094674973d75e8b556
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-02-15 12:13:52 -05:00
Paul Belanger ba4eafa5a8 Re-enable test_diskimage_build_only test
Remove gearman and zmq settings from yaml file.

Change-Id: I8f0938ce132af89b1c7fcd2e9b1d217f23d4df0f
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-02-15 12:13:52 -05:00
Paul Belanger 93b9b54883 Re-enable working test_builder.py tests
But leave the current failing tests disabled. These will be cleaned up
in a follow up patch.

Change-Id: Iea7d56ceb14684c77cb991d362bff992ca061590
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-02-15 12:13:52 -05:00
Joshua Hesketh 5d9bdd4d3a Merge branch 'master' into feature/zuulv3
Change-Id: I5d16c217bd4264ab22daa26103e1e293ca8bb684
2017-01-26 09:17:43 -08:00
David Shrewsbury eac6ca73f3 Disable tests for nodepoold changes
Disables all tests that depend on a working nodepoold and removes
obsolete tests since the database and gearman are going away.

Change-Id: Ic973c8a657fbfa38523e73231bdb5fce53a81f3a
2017-01-11 13:35:21 -05:00
Paul Belanger a3bbeb725a Allow nodepool-builder to only build diskimages
Users can now use nodepool-builder as a front end to
diskimage-builder. The main reason to do this, is we can leverage the
nodepool.yaml file to store the diskimage configuration. Plus
distributed builders.

To actually support this, we need to expose a formats field into the
diskimages section.

Change-Id: I1c0c196828c5c1bf2bf26e278598dbb680d0263e
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-01-10 13:27:29 -05:00
Paul Belanger acf8c2e8ea Properly cleanup failed diskimage builds
If disk-image-create fails, we also mark the image as failed.
However, when we run the cleanup worker, we expect images to exist.
In the case of a failed build, this will never happen.

Change-Id: I6f27a30e77ca11499f6ae2ea91922b379692f499
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-12-12 19:40:45 -05:00
David Shrewsbury 454d14c271 Do not truncate state_time precision
Casting state_time with int(), which lost us time precision, is a
holdover from the old builder code. It is unnecessary and causes
strange problems in rare cases where we sort by state_time and that
precision is lost (see I2dc127b7cd42d3ee7afb1f0677810554a800e8a8
which is reverted by this change).

Change-Id: I6785232f760e29468b21be41224efe7f89543c4d
2016-12-06 11:51:02 -05:00
David Shrewsbury 5f29ab1e36 Fix race in test_image_rotation
We have a very rare failure: waiting for build 001 to be deleted
sometimes fails in test_image_rotation. This is because if things
happen quickly enough, builds 001 and 002 will get the same upload
state_times, which can throw off the CleanupWorker's calculation
of "most recent uploads" (it would think 001 is more recent than 002,
due to sorting on state_time). Add a slight delay to make sure they
have different times.

Change-Id: I2dc127b7cd42d3ee7afb1f0677810554a800e8a8
2016-12-06 10:11:12 -05:00
Paul Belanger c1f1ed4c4d Fix race condition in test_image_rotation_invalid_external_name
We had a race condition waiting for image002 being uploaded to the
cloud. Now, ensure we are waiting for the right images in our
waitForImage() calls.

Change-Id: I814b97360a62b6c447baa7c5eddc783c5ed82c8c
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-12-06 10:10:09 -05:00
David Shrewsbury 7ba37b7774 Delete hard upload failures from current builds
Hard upload fails (those where we could not record the state in
ZooKeeper as FAILED, thus they remain as UPLOADING) are not cleaned
up from current builds, only when the build ages out. This adds
code to clean those up by removing the ZK records for them.

Change-Id: Ie1e06fc897f87ec1226ad48a355e096c659e5090
Story: 2000811
2016-12-02 16:41:13 -08:00
Paul Belanger 28eb62de86 Make sure we clean up diskimages with invalid external_name
It is possible for external_name on our upload images to be empty.
Either we have written the data to zookeeper incorrect or some other
unknown.

As a result, check if external_name is set, then delete the image.
This will allow our cleanup worker to properly delete unneeded
diskimages from the HDD.

Change-Id: I2bad5f2c2585c54879497de3c8997dd6234be5a7
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-12-02 13:41:18 -05:00
Jenkins 6c1c19e981 Merge "Test rotation of builds in nodepool-builder" into feature/zuulv3 2016-12-01 10:45:03 +00:00
David Shrewsbury 7daa218449 Make build/upload worker sleep time configurable
Also changes the default sleep time from .1s to 10s for the
BuildWorker and UploadWorker.

Change-Id: I273f2c6d6f498f8c49010ecbf6b55be07676a570
2016-11-29 17:03:10 -05:00
David Shrewsbury 97f5096ba0 Fix nits in test_image_upload_fail
Fixing nits from change: I26bb641c8673a5c62900b9a81f2dd11eaad78eba

Change-Id: Ibf147ec9e4f3084b8b8cf8349e11c72c6c059908
2016-11-29 10:03:52 -05:00
David Shrewsbury d1361d7730 Re-enable test: test_image_upload_fail
Test that a failed upload is recorded as FAILED in ZooKeeper.
While coding this test, discovered that failed uploads were
being left in the UPLOADING state, rather than FAILED. That
is also fixed here.

Change-Id: I26bb641c8673a5c62900b9a81f2dd11eaad78eba
2016-11-29 10:01:28 -05:00
Paul Belanger 4fe1810e5c Test rotation of builds in nodepool-builder
Add test coverage to ensure images in nodepool are rotated properly.

Change-Id: I8fe545b87dcd7c94bf301820b34cd640ab6bbeeb
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-11-29 09:51:57 -05:00
Paul Belanger e3b43528f7 Add test to validate rebuilds are scheduled
Add a unit test to validate our rebuild schedule is working correctly
for diskimage-builder.

Change-Id: Id36a64191c13938aede657d4cb70c20595cd7dd3
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-11-21 10:00:16 -05:00
James E. Blair 5d576d3eb0 Remove builds that are no longer in use
When a build is no longer used, make sure that all of its uploads
are deleted, then the build itself.

Change-Id: I56fc6677c27fa653889b0720a5d9b06aac32612f
2016-11-18 08:09:14 -08:00
James E. Blair ab3a9d2d24 Add image addition test to builder
Change-Id: Ibdbc45223ab19a16322de0c01043e31ab5d4992e
2016-11-17 15:41:33 -08:00
James E. Blair e56874b7aa Remove obsolete uploaded images
This will delete an upload if an image is removed from a provider.

Change-Id: Iebcf1f899dff8a12a5257641f5569d23c10c6cfc
2016-11-17 14:27:57 -08:00
James E. Blair 5a2f141280 Add test_provider_addition to builder
This tests that when we add a provider, the builder uploads an
image to that provider.

Change-Id: If529c2dc297e842f4bc34985f4a0fb2575f4a7bc
2016-11-17 14:27:57 -08:00
Paul Belanger f40587e4d6 Replace node_dib.yaml with node.yaml for tests
Now that we only support DIB for testing, start to simplify our
configuration files for testing. For example, replace fake-dib-image
with fake-image.

Change-Id: Iaf7a7ff714ab2d22f220e497def7c1cb6987c386
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-11-16 10:31:01 -05:00
David Shrewsbury 55c42d1252 Add janitor thread
Adds a thread to remove local DIB builds and images uploaded to
providers.

Change-Id: I7f2f5e9daeb160baf1bdabd672478dc892120dc5
2016-10-18 15:55:06 -04:00
James E. Blair 3a78447bd6 Rename BuilderScheduler to NodePoolBuilder
The function is the same, but the name reflects that this class
is the central piece of the builder.

Change-Id: I7baa0d1b43140f63ad62b105d462f447c83dbb57
2016-08-25 14:05:13 -04:00
James E. Blair f3fc0c88e6 Simplify builder start/stop methods
Having two start and stop methods was a holdover for when the
builder and scheduler were separate classes.  Move the private
_start method into the public startBuilder method, and just call
it start for consistency.  Same for stop.

Change-Id: I924c718a8435adc12831e34ad8803a41bf81346f
2016-08-25 14:03:40 -04:00
James E. Blair f833deec48 Remove 'running' as a public method from builder
This is no longer necessary as the start method is synchronous.

We also move setting the flag to the beginning of the method to
avoid potential race conditions where the sub-threads might
exit before the _running flag is set.

Also, set the stub-method sleep calls to 0.1 seconds rather than
5 seconds so that tests finish faster.

Change-Id: I75baff21ce0e9180b12a7f126c9328692d5527c1
2016-08-25 14:02:52 -04:00
David Shrewsbury 82ba603dbf Stop using NodePoolBuilder class
The NodePoolBuilder class was only serving as a stop/start manager for
the scheduler. We can move that functionality directly into the
BuilderScheduler class and eliminate use of NodePoolBuilder altogether.
We keep NodePoolBuilder class around for reference until all
functionality can be moved into the new scheduler class.

Change-Id: I89b126ed033a86a1d2b4092edee61981aee60c09
2016-08-25 08:03:28 -04:00
David Shrewsbury 04c81431aa Remove unnecessary NodePoolBuilder thread
Originally, the thread started with the NodePoolBuilder.runForever()
method did all the work of the builder. This functionality is moving
to inside the BuildScheduler. As a result, the thread used for
NodePoolBuilder is no longer necessary. The intention is to (eventually)
totally decouple these classes so that NodePoolBuilder is used only to
start and stop the builder thread of execution. It's run() method is
renamed to start() to better reflect its purpose.

Change-Id: Ief00e4a06bd919e99dbff07f7238ac51035b06ef
2016-08-23 11:16:29 -04:00
David Shrewsbury d2e2babf3e Add scheduling thread to nodepool builder
This is the building block for the structure that nodepool builder will
take going forward. It introduces a new scheduling thread, and moves all
current build and upload worker threads underneath that. A new thread
for receiving ZooKeeper watch events is also introduced.

This code will run, but isn't currently functional because the worker
and watch threads just sleep. Later reviews will begin to add the
functionality.

A supporting developer's guide is added that shows the main components
and communication channels.

Since this is a partial implementation, several tests have to be
temporarily disabled until the ZooKeeper functionality is in place.

Change-Id: I210bb6ba1580403ddc3e5d87eb9bf60ffc7433d8
2016-08-18 12:31:02 -04:00
David Shrewsbury 9126b47650 Add config support for ZooKeeper servers
Allows defining a cluster of ZooKeeper servers within the nodepool
configuration file. Validation of the new config values is supported,
and the new values are documented.

Change-Id: I24401d08135a071dee1d00711fdd82c1d728b31a
2016-08-05 17:34:55 +00:00
David Shrewsbury a0dca6ae12 Allow testing with external zookeeper
It can be handy to test against an already running zookeeper, rather
than requiring one be installed in your test environment. Allow for
that by using the NODEPOOL_ZK_HOST environment variable.

This also gives each ZKTestCase based test a pre-existing client
connection that can be used for testing. To avoid znode path conflicts,
each connection is chroot'ed under /nodepool_test/{uniqueInt}. We
attempt to remove the {uniqueInt} znode and children as part of the
test cleanup (also removed at setUp time if cleanup fails). This will
leave a single znode for /nodepool_test, but if many tests fail for
some reason, it is easier to remove a single root node rather than
potentially many of them if we do not chroot.

Change-Id: I4fd61b16353c16bed2744e0d863ce188019430cd
2016-07-07 16:32:06 -04:00