Commit Graph

131 Commits

Author SHA1 Message Date
James E. Blair 4ef3ebade8 Update references of build "number" to "id"
This follows the previous change and is intended to have little
or no behavior changes (only a few unit tests are updated to use
different placeholder values).  It updates all textual references
of build numbers to build ids to better reflect that they are
UUIDs instead of integers.

Change-Id: I04b5eec732918f5b9b712f8caab2ea4ec90e9a9f
2023-08-02 11:18:15 -07:00
James E. Blair be3edd3e17 Convert openstack driver to statemachine
This updates the OpenStack driver to use the statemachine framework.

The goal is to revise all remaining drivers to use the statemachine
framework for two reasons:

1) We can dramatically reduce the number of threads in Nodepool which
is our biggest scaling bottleneck.  The OpenStack driver already
includes some work in that direction, but in a way that is unique
to it and not easily shared by other drivers.  The statemachine
framework is an extension of that idea implemented so that every driver
can use it.  This change further reduces the number of threads needed
even for the openstack driver.

2) By unifying all the drivers with a simple interface, we can prepare
to move them into Zuul.

There are a few updates to the statemachine framework to accomodate some
features that only the OpenStack driver used to date.

A number of tests need slight alteration since the openstack driver is
the basis of the "fake" driver used for tests.

Change-Id: Ie59a4e9f09990622b192ad840d9c948db717cce2
2023-01-10 10:30:14 -08:00
Zuul 9d98386b62 Merge "Add username to detailed node list output" 2022-12-09 20:26:39 +00:00
James E. Blair 44bf72785d Remove unecessary function
There was only one caller to the change_node_state function, and
it was the one-line hold function.  Remove the unecessary indirection.

Change-Id: I13efc73edf807c8cb6b430f207bf7cb067520ba3
2022-11-30 08:29:17 -08:00
Dr. Jens Harbott abe6ba9759 Add username to detailed node list output
With the static driver it is possible to have multiple static nodes
defined that only differ by their username. In order to be able to
distinguish them, include the username in the output of the
"nodepool list --detail" output.

Signed-off-by: Dr. Jens Harbott <harbott@osism.tech>
Change-Id: I702ccbf412731ef3400eb722386629356a244334
2022-11-14 10:24:50 +01:00
mbecker 1658aa9851 Add hold command to disable nodes
This allows nodes to be set in an idle state
so that they will not have jobs scheduled
while e.g. maintenance tasks are performed.
This is probably most useful for static nodes.

Change-Id: Iebc6b909f370fca11fab2be0b8805d4daef33afe
2022-10-13 12:43:34 +02:00
James E. Blair eb9121a733 Include user/driver data in node detail list
This lets operators see the user_data and driver_data in the node
list when passing --detail.  That can be useful for identifying
issues with the metastatic driver, or any other debugging which
would benefit from seeing that data.

Change-Id: I2f36ce98a183b7a8e289376f2228b6370900a057
2022-06-30 15:25:25 -07:00
James E. Blair 138b68a5a7 Convert dib-request-list to image-status command
This augments the dib-request list (which shows what images have
manual build requests) with information about whether the image
is paused.  The resulting command is renamed to "image-status".

Change-Id: If75a8757b4ec93563e47bfdf0a239a9c21660c45
2022-06-21 14:12:22 -07:00
Simon Westphahl d6e8bd72df Expose image build requests in web UI and cli
Image build requests can now be retrieved through the /dib-request-list
endpoint or via the dib-request-list sub-command. The list will show the
age of the request and if it is still pending or if there is already a
build in progress.

Change-Id: If73d6c9fcd5bd94318f389771248604a7f51c449
2022-06-21 13:32:35 -07:00
James E. Blair a63f128d73 Suppress component registry logging in command
Users of the "nodepool" command don't need to see the component
registry logs at info level (which output at least a line for each
connected component).  Set the minimum level to warning to avoid
that.

The component registry may still be useful for command-line use
in the future, so we leave it in place rather than disabling it
entirely.

Change-Id: I8c0937d7304ddc536773cf74fc40bbf6e79918d4
2022-06-20 07:07:01 -07:00
James E. Blair 10df93540f Use Zuul-style ZooKeeper connections
We have made many improvements to connection handling in Zuul.
Bring those back to Nodepool by copying over the zuul/zk directory
which has our base ZK connection classes.

This will enable us to bring other Zuul classes over, such as the
component registry.

The existing connection-related code is removed and the remaining
model-style code is moved to nodepool.zk.zookeeper.  Almost every
file imported the model as nodepool.zk, so import adjustments are
made to compensate while keeping the code more or less as-is.

Change-Id: I9f793d7bbad573cb881dfcfdf11e3013e0f8e4a3
2022-05-23 07:40:20 -07:00
James E. Blair 0b1fa1d57d Add commands to export/import image data from ZK
Change-Id: Id1ac6403f4fe80059b90900c519e56bca7dee0a0
2021-08-24 10:28:39 -07:00
James E. Blair 63f38dfd6c Support threadless deletes
The launcher implements deletes using threads, and unlike with
launches, does not give drivers an opportunity to override that
and handle them without threads (as we want to do in the state
machine driver).

To correct this, we move the NodeDeleter class from the launcher
to driver utils, and add a new driver Provider method that returns
the NodeDeleter thread.  This is added in the base Provider class
so all drivers get this behavior by default.

In the state machine driver, we override the method so that instead
of returning a thread, we start a state machine and add it to a list
of state machines that our internal state machine runner thread
should drive.

Change-Id: Iddb7ed23c741824b5727fe2d89c9ddbfc01cd7d7
2021-03-21 14:39:01 -07:00
James E. Blair 00d62af3c3 Add image-pause CLI command
This adds a CLI commend to set a flag in ZK for images indicating
that the image should be paused.  This can be used to quickly pause
the building and uploading of one or more images globally.  This
will effectively be boolean OR'd with the pause value for diskimage
builds in the config file.

In particular, this can be used to pause images for short durations,
either because a fix is imminent, or to allow the system to remain
stable while a configuration change goes through the CI/CD workflow.

Change-Id: I21a573dfc337c51f319afe3695d5446b2c91d70b
2020-08-20 15:48:03 -07:00
Zuul 775cd32028 Merge "Add ZooKeeper TLS support" 2020-04-15 01:41:47 +00:00
James E. Blair b62fa3313d Add ZooKeeper TLS support
Change-Id: I009d9f90b32881aaef2d0694da6ff28074f48f8e
2020-04-14 16:03:53 -07:00
David Shrewsbury 394d549c07 Support image uploads in 'info' CLI command
Change the 'info' command output to include image upload data.
For each image, we'll now output each build and the uploads for the build.

Change-Id: Ib25ce30d30ed718b2b6083c2127fdb214c3691f4
2020-03-19 15:03:34 -04:00
Fabien Boucher f57ac1881a
Remove uneeded shebang and exec bit on some files
Having python files with exec bit and shebang defined in
/usr/lib/python-*/site-package/ is not fine in a RPM package.

Instead of carrying a patch in nodepool RPM packaging better
to fix this directly upstream.

Change-Id: I5a01e21243f175d28c67376941149e357cdacd26
2019-12-13 19:30:03 +01:00
Ian Wienand ddbcf1b07d Validate openstack provider pool labels have top-level labels
We broke nodepool configuration with
I3795fee1530045363e3f629f0793cbe6e95c23ca by not having the labels
defined in the OpenStack provider in the top-level label list.

The added check here would have found such a case.

The validate() function is reworked slightly; previously it would
return various exceptions from the tools it was calling (YAML,
voluptuous, etc.).  Now we have more testing (and I'd imagine we could
do even more, similar vaildations too) we'd have to keep adding
exception types.  Just make the function return a value; this also
makes sure the regular exit paths are taken from the caller in
nodepoolcmd.py, rather than dying with an exception at whatever point.

A unit test is added.

Co-Authored-By: Mohammed Naser <mnaser@vexxhost.com>
Change-Id: I5455f5d7eb07abea34c11a3026d630dee62f2185
2019-10-15 15:32:32 +11:00
Monty Taylor 7618b714e2 Remove unused use_taskmanager flag
Now that there is no more TaskManager class, nor anything using
one, the use_taskmanager flag is vestigal. Clean it up so that we
don't have to pass it around to things anymore.

Change-Id: I7c1f766f948ad965ee5f07321743fbaebb54288a
2019-04-02 12:11:07 +00:00
Tobias Henkel 9d77f05d8e
Only setup zNode caches in launcher
We currently only need to setup the zNode caches in the
launcher. Within the commandline client and the builders this is just
unneccessary work.

Change-Id: I03aa2a11b75cab3932e4b45c5e964811a7e0b3d4
2018-11-26 20:13:39 +01:00
Tristan Cacqueray 5745c807c9 status: add pool column to nodepool list output
This helps debug pool quota usage.

Change-Id: Id6cdef978e1ba80a4fea5e5bfa862755fb6d7e40
2018-07-15 23:07:22 +00:00
David Shrewsbury a418aabb7a Pass zk connection to ProviderManager.start()
In order to support static node pre-registration, we need to give
the provider manager the opportunity to register/deregister any
nodes in its configuration file when it starts (on startup or when
the config change). It will need a ZooKeeper connection to do this.
The OpenStack driver will ignore this parameter.

Change-Id: Idd00286b2577921b3fe5b55e8f13a27f2fbde5d6
2018-06-12 12:04:16 -04:00
Ian Wienand 89790013f3 Consolidate node_list, add generic filter
node_list takes an argument "detail" which adds a rather arbitrary
list of results to the output.  This comes from the command-line,
where we're trying to keep width under a certain length; but doesn't
make as much sense here (especially for json).

For dashboard type applications, replace this with a simple "fields"
parameter which, if set, will only return those fields it sees in the
common text output function.

Note, this purposely doesn't apply to the JSON output, as it expected
client-side filtering is more appropriate there.  We could also add
generic field support to the command-line tools, if considered
worthwhile.

Add some documentation on all the end-points, and add info about these
parameters.

Change-Id: Ifbf1019b77368124961e7aa28dae403cabe50de1
2018-03-01 11:14:03 +11:00
Ian Wienand 2d60240fec Consolidate status results
All the _list functions return the same thing; save the results and
use a common output function to generate the json or text output.

Change-Id: I9cb44b09de2cb948e7381ef10302b21040433a2c
2018-03-01 11:13:55 +11:00
David Shrewsbury 2e0e655cd0 Remove the hold command
This makes no sense in the zuulv3 world.

Change-Id: Id939ca174b490482007c32611ef8bbba9db4c7ca
2018-02-01 11:20:01 -05:00
David Shrewsbury aaecb282ee Split out erasing from 'info' command into 'erase'
This removes the --erase option from the 'info' command into
its own command.

Change-Id: I7f75e8efd49644f272102ff65c48d22a878334fe
2018-01-24 16:35:35 -05:00
David Shrewsbury 742b0b1d6b Add provider info command
This command will display all ZooKeeper data for a given provider,
and provide and option to remove all of the data from ZooKeeper.
This can be useful when an operator must permanently remove a
pre-existing provider from nodepool and cannot cleanly shutdown
the services otherwise.

Example:

   nodepool info rax
   nodepool info --erase rax

Change-Id: I527aae5ff89aac864f984af050abb83e7bc3ac04
2018-01-19 11:22:30 -05: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
Zuul 007ba7e660 Merge "Remove the default argument to secure in nodepoolcmd" into feature/zuulv3 2018-01-08 06:58:38 +00:00
David Shrewsbury a466e560da Remove alien_list command
This command has lost its usefulness in v3. Leaked instances
are automatically cleaned up by the CleanupWorker thread.

Change-Id: I99dced6c655fe865012d0d54f39bfc16b789d1a2
2017-12-04 07:56:58 -05:00
Rui Chen 73e5d8bdd4 Fix nodepool cmd TypeError when no arguemnts
When execute command "nodepool" without any argument,
an internal error TypeError and traceback info
will be raised out now. Output help message to instead.

Change-Id: If96761fd2342c76a2c69a5bb16bd526279502ac0
2017-11-20 09:43:05 +08:00
David Shrewsbury 97305a760c Fix node delete command
If we issue a 'nodepool delete' command for a node whose provider
is not defined on the current launcher, we would get an error
trying to pull up that provider info. Only pull that provider info
when using the --now option.

Change-Id: Ibe05b93b3c8a2b9105261c4df01c9c6a43352f9e
2017-09-22 15:06:50 -04:00
Jamie Lennox 5ae9b63737
Remove the default argument to secure in nodepoolcmd
The nodepool secure file is currently not being used for anything. By
having a default value in the nodepool command the config will try to
load this file. When the file then doesn't exist the program will exit.

This basically means you have to have an empty file at
/etc/nodepool/secure.conf to be able to use nodepoolcmd. Launcher does
not specify a default for secure, so follow that lead and remove the
default.

Change-Id: I244f097bcd1443588c03257394c5e8768ab3e785
Signed-off-by: Jamie Lennox <jamielennox@gmail.com>
2017-08-30 16:31:47 -05:00
David Shrewsbury 7383896833 Add --detail option to nodepool list command
The output of the 'list' command has gotten quite large. Simplify
the default output, and output the complete info when the --detail
option is given.

Also adds/modifies the list_nodes tests to assert that the column
output changes when the new option is used.

Change-Id: I60f849225c8c7fce1c524f132e54da58b25ae752
2017-08-02 09:42:46 -04: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
Tristan Cacqueray a5077fc344 Add support for custom ssh port
This change adds 'ssh_port' to the Node class.

Change-Id: I5e6d3969ae04f90abd1a3fd908c160cda4791bad
2017-07-06 06:34:28 +00:00
Paul Belanger d472628a60
Update exception message handling for python3
str(e.message) is not valid for python3, but str(e) is.

Change-Id: Ifb3e13ee035371e0534c7bf5dd1587690f3dd6f5
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-05-17 15:19:55 -04:00
Paul Belanger 4a611a53ce
Ensure zookeeper_servers is a list
For python3, dict.values() no longer is a list, but a view. So, we
need to explicitly enforce a list since we expect it for kazoo.

Change-Id: Ifa8d4101995b0933fc3f7e07cc78336edff598b9
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-05-17 15:19:50 -04:00
Paul Belanger d892837cad
Fix imports for python3
The syntax for imports has changed for python3, lets use the new
syntax.

Change-Id: Ia985424bf23b44e492f51182179d2e476cdcccbb
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-05-17 15:19:48 -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 5d423bee9a
Python 3.x incompatible use of print operator
Start working on low hanging fruit for python3 support.

Change-Id: I6d52c3a4ad4d383437925ecae6002de7528c9be0
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-05-12 14:09:15 -04:00
Jenkins bdaf1f4a1a Merge "Show message if node hold not found" into feature/zuulv3 2017-04-07 13:15:30 +00:00
Jenkins dbb0062482 Merge "Start adding operational docs to zuulv3" into feature/zuulv3 2017-04-06 22:30:00 +00:00
James E. Blair cc6e01824c Wait for lock when performing manual hold
So that an operator can choose to hold a node while it is in use,
update the 'nodepool hold' command to wait for the lock if that
is required.  The locking algorithm is ordered, so as long as this
command is run while the node is locked while in use, this command
will be able to obtain the lock on the node before the node
deleter does.

This means it will sit in the foreground until the node is locked,
which, in some cases, may be hours.  Perhaps that's not ideal,
but processes are easy to background in those cases, or abort if
the operator changes their mind.  It does provide an avenue for
notification that the node has been unlocked by returning to the
shell when complete.

Change-Id: I89721cbe1e53b30bb0e2b5f5440870df958cf2c1
2017-04-06 07:38:38 -07:00
Jamie Lennox 477f8e6fa1 Show message if node hold not found
When using the CLI to place a hold on a node the return value of getNode
is not checked. This leads to an AttributeError on the None object.
Other commands simply return a message and hold should as well.

Change-Id: I11bdd47644c8535f99500989c63993e04215f464
2017-04-06 14:05:58 +10:00
Clark Boylan f26f502fbf Start adding operational docs to zuulv3
This tries to capture common operation tasks in the documentation. It
also clears up some related items about what is necessary to have a
functioning Nodepool installation and what the dib-image-delete command
does.

Story: 2000790
Change-Id: I397fc4879fa84ffc667ddda0aff9c107eee0d694
2017-04-05 11:07:13 -07:00
Jenkins ec44794836 Merge "Update nodepool config syntax" into feature/zuulv3 2017-03-27 18:33:26 +00:00
James E. Blair dcc3b5e071 Update nodepool config syntax
This implements the changes described in:

http://lists.openstack.org/pipermail/openstack-infra/2017-January/005018.html

It also removes some, but not all, extraneous keys from test config files.

Change-Id: Iebc941b4505d6ad46c882799b6230eb23545e5c0
2017-03-27 09:34:02 -07:00