342 Commits

Author SHA1 Message Date
Brian Haley
9706bba3cb Remove six library from requirements.txt
Six is unused in the code, and generally unused in all of
Openstack, so remove it.

Removed setuptools pin in test-requirements.txt since it
was causing an older pkg_resources to be used, which was
trying to import six.

Fixed some invalid assertion statements in unit tests.

Change-Id: Id8c182a9aec5e25a8078b33127095ab8dce9dc33
2024-08-07 13:40:40 -04:00
Nikolay Vinogradov
31df8c6bf2 Add storage-backend subordinate relation
Implement initial support for container-scoped storage-backend
relation to integrate nova-compute with storage providers.

Transition to blocked state if multiple storage backend
relations are connected

Change-Id: I03e67731df0263887d2d0f671750f420d6e62c1c
2024-04-12 01:44:30 +00:00
Liam Young
cb04103e08 Do not manage subordinate service restarts
The subordinate charms should manage the services that
they deploys and configure, not the principle they are related to.
This change switches the approach for restarting services
from having the nova-compute charm doing it directly to having
nova-compute triggering the restart by request a restart down
the existing relations.

Closes-Bug: #1947585

Change-Id: I7419e39d68c70d21a11d03deeff9699421b0571e
2023-03-02 13:54:15 +00:00
Felipe Reyes
2bad8a0522 Use a stable hostname to render nova.conf
OVS introduced a new service called ovs-record-hostname.service which
records the hostname on the first start in the ovs database to identify
the ovn chassis, this is how it achieved a stable hostname and be
resilient to the changes in the FQDN when the DNS gets available.

This change introduces the same approach for nova-compute charm. In the
first run of the NovaComputeHostInfoContext the value passed in the
context as host_fqdn is stored in the unit's kv db, and re-used on every
subsequent call.

This change affects only new installs since the hint to store (or not)
the host fqdn is set in the install hook.

Change-Id: I2aa74442ec25b21201a47070077df27899465814
Closes-Bug: #1896630
2023-02-20 11:37:14 -03:00
Felipe Reyes
75a3dbd0ef Refactor unit tests to avoid leaks of mocks.
It was found that the modules test_actions_openstack_upgrade and
test_actions_package_upgrade were mocking different classes and
functions right before importing the modules under test
(openstack_upgrade and package_upgrade respectively), although these
mocks weren't being reset making tests executions coming after them to
get benefitted (or impacted) by the mocks in memory.

This patch takes advantage of mock.patch() decorator at the class level
and importlib.reload() to make sure the mocks don't outsurvive the
module.

When the teardown was in place it was found a different set of functions
that were relying on that mocking, so they were patched to allow the
tests run in the expected (mock'ed) environment.

Summary of changes:

 - Move get_availability_zone() to contexts module, nova_compute_utils
   depends on nova_compute_context, the latter shouldn't be importing
   code from the former since it breaks the layering, even when the
   import is being done within a function's body.
 - Mock env variable JUJU_UNIT_NAME per test case, the tests defined
   in the test_nova_compute_utils and test_nova_compute_contexts were
   relying on the leakage of mocks set by other test modules, this
   makes them run in an isolated fashion.
 - Move update_nrpe_config testing to its own class, the main class
   NovaComputeRelationsTests mocks the function update_nrpe_config()
   making it difficult to test it in a test method, hence making the
   test part of its own class it's posible to not mock the function
   and correctly runs its implementation.
 - Teardown mocks made at import level.

Func-Test-Pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/997
Change-Id: I4468ef1a0619befc75c6af2bad8df316125a7cf5
2023-02-20 11:37:01 -03:00
Edward Hope-Morley
98191ea5bf Make virt_mkfs configurable with ext4 default
Closes-Bug: #1960231
Change-Id: Ia2ac7318f1164a9015bdf9e7ce7d20a129e22af4
2023-01-18 15:51:16 +00:00
Liam Young
abe5a289ed Only render qemu.conf for hypervisors using qemu
Change-Id: I02a250c27d1b52d5cc9df3f1d6256bfc3ab982ea
Closes-Bug: #1968547
2022-04-11 10:37:24 +00:00
Zuul
d53aa79b96 Merge "Enable vTPM support in nova-compute" 2022-04-04 23:47:03 +00:00
Billy Olsen
a8c4cd7b29 Enable vTPM support in nova-compute
Enable vTPM support in nova-compute charm. This adds new packages to be
installed swtpm and swtpm-tools as well as updates the nova-compute.conf
file and the qemu.conf file to set appropriate user/groups for swtpm.

func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/696

Change-Id: Idf0d19d75b9231f029fa6a7dc557d2a9ee04915b
2022-04-04 11:34:11 -07:00
Aurelien Lourot
140be9d0a9 Restart failed subordinate services
Change-Id: Id34e9c6f85886dbf880df0b7002110a40ef41ad6
Closes-Bug: #1947585
2022-04-04 10:47:10 -07:00
Zuul
71567080b3 Merge "Make sure lsscsi is installed for os-brick" 2022-03-11 09:16:22 +00:00
Zuul
bf490c9c3c Merge "Remove python-oslo.privsep on upgrades to >=rocky" 2022-02-22 15:27:22 +00:00
Felipe Reyes
5da120ad5d Remove python-oslo.privsep on upgrades to >=rocky
Ubuntu OpenStack Rocky migrated from python2 to python3, the package
python-oslo.privsep provides the privsep-helper program as an
alternative, when having it installed next to python3-oslo.privsep the
first installed will stay as a default.

This change add python-oslo.privsep to the list of packages that need to
be purged on OpenStack>=rocky.

Change-Id: Ib64dfa30b6705a45f82051dfc3634740a5f3a661
Closes-Bug: #1822763
2022-02-21 16:51:54 -03:00
Nobuto Murata
7a3982d987 Make sure lsscsi is installed for os-brick
os-brick upstream made some changes and started to use lsscsi for
discovering iSCSI devices. Make sure lsscsi is installed by the charm
until the os-brick package in Ubuntu pulls it as a dependency.

Closes-Bug: #1939390
Change-Id: I509d5edb3c6e3a4c35b7252b567a1672cf5e0bbe
2022-02-21 22:54:10 +09:00
Aurelien Lourot
f723109911 Add nova-vgpu relation
Change-Id: Ie034a263c85c2909ce87ada632196772dbd265d2
2022-02-17 15:34:22 +01:00
Zuul
1d132e68cc Merge "Add numactl to nova_compute_utils.py base packages" 2021-12-17 11:34:32 +00:00
Aurelien Lourot
0a4acd6d03 Fix resume action failure
Services have interdependencies and the order in which
we attempt to resume them is important, otherwise the
resume action may fail.

Uncovered while and validated by running the
openstack-upgrade tests. [1]

[1]: https://github.com/openstack-charmers/charmed-openstack-tester

Change-Id: I12218b47dc56b502ecc8578c6ab13acbd321bf26
Related-Bug: #1927277
Related-Bug: #1952882
2021-12-01 12:12:25 +01:00
Aurelien Lourot
8fb37dc0c1 Process subordinate releases packages map
For principal - subordinate plugin type relations where the
principal Python payload imports code from packages managed by a
subordinate, upgrades can be problematic.

This change will allow a subordinate charm that have opted into the
feature to inform its principal about all implemented release -
packages combinations ahead of time. With this information in place
the principal can do the upgrade in one operation without risk of
charm relation RPC type processing at a critical moment.

This makes use of
https://github.com/juju/charm-helpers/pull/643

This is similar to
https://review.opendev.org/c/openstack/charm-keystone/+/781822

Also fixed broken link to charm-guide.

Change-Id: Iaf5b44be70ee108cbe88b4a26f0f15f915d507fe
Closes-Bug: #1927277
2021-11-26 13:39:33 +01:00
James Troup
034d6e36c2 Spelling fixes found by codespell.
Change-Id: I819aa04eef6cc72a24ecaf39a350b30015612165
2021-11-15 21:54:13 +00:00
James Page
41242c797f Fix misc issues with instances-path usage
Fix use of ephemeral-device with instances-path to ensure that
the configured block device is mounted in the desired location.

Ensure instances-path directory actually exists.

Change-Id: I81725f602ba3086bc142d59104e4bfc80918d8cf
Closes-Bug: 1909141
2021-09-16 10:27:53 +01:00
James Page
af2e403625 Block nova-compute startup on mountpoint
If an ephemeral-device storage configuration has been provided,
ensure that the nova-compute service will not start until the
mountpoint (currently /var/lib/nova/instances) has actually
been mounted.  If this does not happen the nova-compute service
will fail to start in a failsafe condition.

Change-Id: Ic16691e119e430faec9994f6e207596629e47bb6
Closes-Bug: 1863358
2021-09-16 09:22:27 +01:00
Arif Ali
8048e6c74a
Add ovmf package for uefi support
When creating an instance with uefi support it is looking for various
files that are typically provided by ovmf package. This is automatically
installed from train and above, but is lacking in queens. This will
solve it for any deployment.

Change-Id: I7665a596112d673624ea5edd7438b915834918df
2021-09-06 16:41:37 +01:00
Bayani Carbone
1d5c980616 Add numactl to nova_compute_utils.py base packages
This tool is useful for numa usage reporting.

Change-Id: Id0aaba514b06fe3dfa79e9e1d263b1dbde20f494
2021-08-10 14:23:11 +02:00
Brett Milford
43acdd4f80 Added allocation-ratio config opts
Nova supports setting allocation ratios at the nova-compute level from
Liberty onwards. Prior to this allocation ratios were set at the
nova-scheduler level.

Newton introduced the Placement API, and Ocata introduced the ability to
have compute resources (Core/RAM/Disk) precomputed before passing
candidates to the FilterScheduler [0]. Pike removed CoreFilter,
RAMFilter and DiskFilter scheduler filters.

From Pike onwards valid methods for settings these allocation ratios are via:
- A call to the Placement API [1].
- Config values to supplied to nova-compute (xxx_allocation_ratio).

Stein introduced initial_xxx_allocation_ratio in response to the runtime
behaviour of the ResourceTracker [2].

Currently, the precedence of resource ratio values are:
xxx_allocation_ratio > Placement API call > initial_xxx_allocation_ratio

That is a (compute) resource provider's allocation ratios will default
to initial_xxx_allocation_ratio which may be overridden at run time by a
call to the Placement API. If xxx_allocation_ratio is set it will
override all configurations for that provider.

When not otherwise configured, we set initial_xxx_allocation_ratio to
the values provided by ncc to maintain backwards compatibility. Where
initial_xxx_allocation_ratio is not available we set
xxx_allocation_ratio.

[0] https://specs.openstack.org/openstack/nova-specs/specs/ocata/implemented/resource-providers-scheduler-db-filters.html
[1] https://docs.openstack.org/api-ref/placement/#update-resource-provider-inventories
[2] https://specs.openstack.org/openstack/nova-specs/specs/stein/implemented/initial-allocation-ratios.html

Change-Id: Ifa314e9e23e0ae5d16113cd91a7507e61f9de704
Closes-Bug: #1677223
2021-05-24 15:39:47 +10:00
Zuul
e76484fcd0 Merge "Added actions that enable clean removal of nova-compute unit from model" 2021-03-25 08:15:40 +00:00
Martin Kalcok
ceb8a68868 Added actions that enable clean removal of nova-compute unit from model
List of added actions:
* disable
* enable
* remove-from-cloud
* register-to-cloud

More detailed explanation of the process added to the README.md

Closes-Bug: #1691998
Change-Id: I45d1def2ca0b1289f6fcce06c5f8949ef2a4a69e
func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/470
2021-03-24 16:07:58 +01:00
Liam Young
372da646b6 Allow neutron-plugin sub to publish nothing
A change landed to charm helpers to mark the
SubordinateConfigContext as incomplete if the subordinate supplied
no data *1. But the neutron-plugin subordinate may legitimately
supply no data if no special config is needed. This restores the
previous behaviour of marking the subordinate context for the
neutron-plugin relation as complete even if not data was supplied.

*1 https://github.com/juju/charm-helpers/pull/519

Change-Id: I34fa2d39171132e4fe7d0b7e5fd29162161a5060
Closes-Bug: #1912187
2021-01-19 14:49:57 +00:00
Zuul
b398e40165 Merge "Add Ceph BlueStore Compression support" 2020-09-30 07:52:18 +00:00
Frode Nordahl
772291003b
Add Ceph BlueStore Compression support
Sync c-h.

Func-Test-Pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/429
Change-Id: I3bbf41350c18ac5cc045392ace6e14118b04e1e8
2020-09-25 11:22:30 +02:00
Gabriel Adrian Samfira
7ff7001982 Add Ironic virt type
Adds support for the Ironic virt driver.

Change-Id: I72a7fb65395e4ceddc77a92bccc7b4563af0750a
2020-09-21 12:12:13 +00:00
James Page
747fa2d68d Misc fixes for charm infra
Update pydev project definition to use python 3.

Drop upper bound on flake8.

Tidy misc lint across codebase with newer flake8.

Change-Id: I9637ac603cb3801c9e3ffa8c2b0897968d42ada5
2020-05-26 09:38:07 +01:00
Frode Nordahl
1869bfbc97
Use hosts official name for FQDN
The current implementations use of a specific interface to build
FQDN from has the undesired side effect of the ``nova-compute`` and
``neutron-openvswitch`` charms ending up with using different
hostnames in some situations.  It may also lead to use of a
identifier that is mutable throughout the lifetime of a deployment.

Use of a specific interface was chosen due to ``socket.getfqdn()``
not giving reliable results (https://bugs.python.org/issue5004).

This patch gets the FQDN by mimickingthe behaviour of a call to
``hostname -f`` with fallback to shortname on failure.

Add relevant update from c-h.

Needed-By: Ic8f8742261b773484687985aa0a366391cd2737a
Change-Id: I82db81937e5a46dc6bd222b7160ca1fa5b190c10
Closes-Bug: #1839300
2020-01-13 00:32:09 +01:00
Edward Hope-Morley
3e67cc5387 Charmhelpers sync to get vaultlocker fixes
Also gates checking vaultlocker status until it is installed

Change-Id: I07f92132b0340b538ee472887c7fd0e0cc911453
Closes-Bug: #1849323
2019-12-11 14:29:42 +00:00
David Ames
6a1e3a799e Start libvirt in post-series-upgrade
A recent change (commit ceab1e91dc2e3948f6ba7c121c1801ad1641643c)
removed libvirt from the pause/resume list of services. This affected
series upgrade. Libvirt stayed down and did not start back up on resume.

This change checks the hook being executed and if it is
post-series-upgrade it includes libvirt as a service to start on resume.

Closes-Bug: #1839495
Change-Id: Ibfa24b678c1077b441464da8c38114ce23d14963
2019-08-08 20:51:45 +00:00
Alex Kavanagh
2e2d19f7c7 Refactor import_authorized_keys() function for performance
The main change is to fetch all of the relation_data() at once, and then
iterate through the python dictionary.  This speeds up processing of
potentially hundreds of hosts and authorized_keys.

Change-Id: I095104f535c1eae1554f842502ae93ebb92e44fe
Related-Bug: #1833420
2019-06-19 17:08:45 +01:00
Rodrigo Barbieri
af051c4fba Propagate vendor_data from nova-cloud-controller
When using DVR and L3HA neutron deployment options,
Nova API Metadata requests are served from compute nodes,
instead of from neutron-gateway nodes.

This change allows nova-compute to receive vendor_data
configuration values from nova-cloud-controller charm
relation and write to nova-compute's nova.conf
appropriately.

This will be effictive for Queens and later OpenStack
releases.

Synced charm-helpers in order to import new context
for writing the vendor_data.json file.

Change-Id: I0c79e1bfac9fbe7009a7e862ad010cfa2de8cfda
Closes-Bug: #1777714
2019-06-03 12:25:18 -03:00
Zuul
247a645b6b Merge "Added verification to ensure iscsid is running" 2019-05-29 07:41:44 +00:00
Corey Bryant
96b5e8a249 py3: deal with more subordinate dependencies
Ensure subordinate py3 packages are installed if their py2
counter-parts are currently installed for neutron-openvswitch.
In this case we had missed python(3)-neutron-fwaas.

Change-Id: I9d5e7c2ad034cd7bdf9cbf292b9107577860dac1
Closes-Bug: #1828259
2019-05-09 08:19:18 -04:00
tpsilva
3b91afa9ce Added verification to ensure iscsid is running
Currently, the charm does not verify if iscsid is installed or
running. This patch adds those verifications on install and
update hooks.

Closes-bug: #1816435

Change-Id: I23992832a82557f406999427fe8d151f6a2b63af
2019-03-22 17:02:37 -03:00
Zuul
a0ef37513c Merge "Add support for nfs cinder volumes" 2019-02-21 09:34:59 +00:00
Liam Young
e5fc658b26 Add support for nfs cinder volumes
Cinder volumes which are provisioned via nfs need to be mounted on
the compute nodes. For this to work the nfs-common package is needed.

Closes-Bug: #1816820
Change-Id: I5d536817b2098698cecd4627408a82321bf7fb9b
2019-02-20 17:22:45 +00:00
Corey Bryant
32ef5b4cca py3: deal with more subordinate dependencies
Ensure subordinate py3 packages are installed if their py2
counter-parts are currently installed for neutron-openvswitch
and ceilometer-agent.

Change-Id: I940fb2ce9d671e919c817cee7adda2ac22ecb3fb
Closes-Bug: #1816299
2019-02-20 13:57:37 +00:00
Billy Olsen
a445a33add Install multipath dependencies when use-multipath is True
This change ensures that the multipath dependencies are installed
on the compute node when the use-multipath config flag is enabled.

Change-Id: I39b017398b95f5901d9bc57ffa0c59ff59f3a359
Closes-Bug: #1806830
2019-02-04 19:55:49 -07:00
Felipe Reyes
ceab1e91dc Don't include libvirtd on pause/resume
libvirt needs to be running even when the pause action runs, this allows
commands like "virsh secret-list" run and having it running is safe
enough from a nova-compute unit point of view, because it won't touch
the already running instances.

Change-Id: Idec9e2b7c6275c4c5485942574120289552f2955
Closes-Bug: 1802917
2019-01-25 16:51:59 -03:00
lijunjie
2c7750e8c6 Fix the misspelling of "import"
Change-Id: Ifd5f91a566184b27c12f4488727ce87013ea0d0a
2019-01-16 10:45:45 +08:00
James Page
ade7586da4 Don't write files to /etc/init if not present
Only write the libvirt-bin.override file if /etc/init actually
exists; This is really present to support upstart based deployments
so is not required on Ubuntu Xenial or later.

If nova-compute is deployed in a LXD container, this directory is
unlikely to be present in a pristine container image.

Change-Id: Ie68be0f3e7ca610478159f5f1dd491b8b755e82e
Closes-Bug: 1805191
2018-11-27 11:18:34 +00:00
Liam Young
9ff97e429d Purge old packages on upgrade-charm
On charm upgrade the charm may switch to py3 packages. If so, ensure
the old py2 packages are purged. If the purge occurs then restart
services.

Change-Id: I17abef16afbb8c62dae1b725c74c39cec414f4f8
Closes-Bug: 1803451
2018-11-15 15:40:58 +00:00
Edward Hope-Morley
f60aa4a8fb Ensure ceph python3 deps installed for >= R
Change-Id: I65ddf1dfd4082a8b8ea452d00c6098ed70f3395a
Closes-Bug: #1802484
2018-11-09 10:22:15 +00:00
Edward Hope-Morley
6c8d3b47fc Properly remove libvirt default network
As well as destroying the network we should also undefine it
to ensure it does not return.

Change-Id: I57738856adb25c190357b1b23dd8a1245798cb14
Closes-Bug: #1800160
2018-11-01 09:02:11 -06:00
James Page
7f15c2f5ce py3: deal with subordinate dependencies
Switch to marking non-leaf python-* packages as automatically
installed so that they will be purged once the last remaining
package that depends on them that was manually installed is
removed.

Force install of python3-nova-lxd for Rocky and above to ensure
that py versions are matched with python3-nova.

Change-Id: I79d528bfb7732490aa42da2158244350c03dfa59
Closes-Bug: 1797879
2018-10-18 13:53:51 +01:00