Commit Graph

326 Commits

Author SHA1 Message Date
Rodrigo Barbieri 650f3a5d51 [v2] Fix migration across nova-compute apps using ceph
This change reworks previous changes [1] and [2] that had
been respectively reverted and abandoned.

When using the config libvirt-image-backend=rbd, VMs
created from image have their disk data stored in ceph
instead of the compute node itself.

When performing live-migrations, both nodes need to
access the same ceph credentials to access the VM's
disk in ceph, but this is currently not possible
if the nodes involved pertain to different
nova-compute charm apps.

This patch changes app name sent to ceph to
'nova-compute-ceph-auth-c91ce26f', a unique name common to
all nova-compute apps, allowing all nova-compute apps to
use the same ceph auth.

This change also ensures newly deployed nodes install
the old credentials first on ceph-joined hook,
and then supercedes it with the new credentials
on ceph-changed hook, therefore also retaining
the old credentials.

This patch also includes the charmhelpers sync
from PR: #840

[1] https://review.opendev.org/889642
[2] https://review.opendev.org/896155

Closes-bug: #2028559
Related-bug: #2037003

Func-Test-Pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/1149

Change-Id: I1ae12d787a1f8e7761ca06b5a80049c1c62e9e90
2024-01-05 15:23:50 +00:00
Alex Kavanagh d90d6ee847 Improve platform mocking
Patch out charmhelpers.osplatform.get_platform() and
charmhelpers.core.host.lsb_release() globally in the unit tests to
insulate the unit tests from the platform that the unit tests are being
run on.

Change-Id: I33d473d83a7c8f4f23840b6b6bcf153ed423ccdc
2023-10-24 12:33:41 +01:00
Zuul e70f228916 Merge "Revert "Fix migration across apps when using VMs created from image"" 2023-10-05 13:17:46 +00:00
Rodrigo Barbieri 11845c7aab Revert "Fix migration across apps when using VMs created from image"
This reverts commit c3c2cf0349.

Reason for revert: This introduces an undesired behavior when scaling-out that needs to be addressed in a complementary patch.

Change-Id: I21c127aa565e489ba4d93a1efc8ddba63ef32e87
2023-10-05 09:22:10 +00:00
Zuul ccea3ee467 Merge "Fix migration across apps when using VMs created from image" 2023-08-30 13:56:27 +00:00
Rodrigo Barbieri c3c2cf0349 Fix migration across apps when using VMs created from image
When using the config libvirt-image-backend=rbd, VMs
created from image have their disk data stored in ceph
instead of the compute node itself.

When performing live-migrations, both nodes need to
access the same ceph credentials to access the VM's
disk in ceph, but this is currently not possible
if the nodes involved pertain to different
nova-compute charm apps.

This patch changes app name sent to ceph to 'nova-compute',
allowing all nova-compute apps to use the same ceph auth.

This patch also includes the charmhelpers sync
from PR: #840

Closes-bug: #2028559
Change-Id: I7222661017655fd7225db0c677f1a8f5ebb7984d
2023-08-22 10:33:06 -03:00
Zuul f6892d228c Merge "Do not manage subordinate service restarts" 2023-08-22 13:32:57 +00:00
Rodrigo Barbieri e61d89aa47 Set nova config for rbd instance folder cleanup after evacuations
After evacuations and revert resizes when using rbd storage backend,
the instance folder is usually left behind and causes issues when
migrating the instance back to the host.
With the config option set, the nova-compute service will cleanup
those folders as part of the periodic checks that run for instances
that have been evacuated/migrated.

Closes-bug: #2019141
Change-Id: I846ccb0a95d04139b41fdad6cbf465d303d6cc09
2023-06-06 10:15:41 -03:00
Jorge Merlino 3c53110282 Add support for using service tokens
This patch configures Nova to send a service token along with the
received user token on requests to other services. This can allow those
other services to accept the request even if the user token has been
invalidated since received by Nova. Also with this patch Nova will
accept request from other services with invalid user tokens but valid
service tokens. Service tokens exist since Openstack Queens.

Closes-Bug: #1992840
Change-Id: I78b43ef77dc1d7b5976ec81ecddf63c9e6c8b6c1
2023-05-03 12:32:06 +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
ljhuang fadbf178fd Replace deprecated assert_ with assertTrue
The assert_ method alias has been deprecated in unittest since version 3.2[1].

[1] https://docs.python.org/3/library/unittest.html#deprecated-aliases

Change-Id: I7aa4862c93feb0d6be2e3080a6689d49ca756cc3
2022-07-21 12:46:13 +08:00
Zuul da2142cca3 Merge "Add package-upgrade action" 2022-05-16 10:00:06 +00:00
Billy Olsen f6c536baec Render correct driver in nova-compute.conf
Commit abe5a289 fixed the rendering of the ironic driver in the
nova-compute.conf file for OpenStack versions >= Wallaby. However, it
always renders the nova-compute.conf file for train and above, which is
hard-coded to the Ironic libvirt driver.

This adds additional templating logic to the nova-compute.conf driver in
order to render the correct driver to use.

Related-Bug: #1968547
Change-Id: I12cd4bf5953170d227d52793764c49f3871e25f9
2022-04-19 20:00:02 -07: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
Zuul 0eb4579646 Merge "Restart failed subordinate services" 2022-04-04 23:45:13 +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
Billy Olsen 330086cb71 Add extra-repositories config option
Add an extra-repositories config option to nova-compute in order to
allow configuring additional apt repositories. This is useful when some
packages are not available in the distro or cloud archive.

Change-Id: Ie3b76ff3bc07b83e416c80fab1da2560d48df498
2022-04-03 19:12:11 -07:00
Zuul 723eb621fa Merge "Fix socket.fqdn() not returning full hostname" 2022-02-22 15:27:20 +00:00
Zuul 889fc01086 Merge "Use correct relation key for allocation defaults" 2022-02-21 10:07:17 +00:00
Zuul ff441eb1f8 Merge "Add nova-vgpu relation" 2022-02-18 09:49:25 +00:00
Aurelien Lourot f723109911 Add nova-vgpu relation
Change-Id: Ie034a263c85c2909ce87ada632196772dbd265d2
2022-02-17 15:34:22 +01:00
Zuul 5650741d59 Merge "Allow resizing to the same host" 2022-02-16 16:24:28 +00:00
James Page 764adf7007 Use correct relation key for allocation defaults
The nova-cloud-controller charm passes allocation ratio defaults
in the format '{cpu,disk,ram}_allocation_ratio' on the cloud-compute
relation.

Ensure that later OpenStack releases (>= Stein) query using this
key rather than one prefixed with 'initial_' which is used for the
target Nova Compute configuration option.

Closes-Bug: 1961065
Change-Id: I7d3e7f9f5c69f7ad06191a20bdfcfd6b5dca50d3
2022-02-16 13:26:26 +00:00
Marcin Wilk c3bd6788a7 Allow resizing to the same host
By default resizing an instance to the same host as the source is
not enabled. This change adds new charm config option that maps
directly to the nova.conf setting which effectively gives a user
possibility to enable/disable this functionality.

Closes-Bug: #1946620
Depends-On: I13d0c332cd0b110344b7a1645e3e4fd250fce33a
Change-Id: I2f2e9e44f6bba48e15621a216539089c7e3abc1d
2022-02-11 15:54:14 +00:00
Nobuto Murata 2283f12edd Expose block-device-allocate-retries and interval
The upstream has 3 min as the timeout (60 retries at 3-seconds
interval). It should work if an image is in a raw format to leverage
Ceph's copy-on-write or an image is small enough to be copied quickly.
However, there are some cases exeeding the 3 min deadline such as a big
enough image with Qcow2 or other formats like Windows images, or storage
backend doesn't have copy-on-write from Glance.

Let's bump the deadline to 15 min (300 retries at 3-seconds interval) to
cover most of the cases out of the box, and let operators tune it
further by exposing those options.

Co-authored-by: Mark Maglana <mark.maglana@canonical.com>
Closes-Bug: 1758607
Change-Id: I6f6da8e90c6bbcd031ee183ae86d88eccd392230
2022-02-08 18:03:20 +09:00
Martin Kalcok d23d25b3a0 Fix socket.fqdn() not returning full hostname
This change aims to make resolving of the unit's
FQDN more consistent. Python's standard
`socket.getfqdn()` can "fail" in some conditions
and return only hostname, without the domain
part, even in cases when `hostname -f` would
return correct fqdn.

This new approach provides behavior consistent
with executing `hostname -f`

Closes-Bug: #1955164
Change-Id: Icc39b32b3e471c1960402dfcba61bed5ce309a6f
2022-02-07 16:23:40 +01:00
Corey Bryant a61f5abc60 Add package-upgrade action
The package-upgrade action performs package upgrades for the current
OpenStack release.

The code path used is similar to the openstack-upgrade action, with the
difference being that package-upgrade will not execute if an openstack
upgrade is available (based on the openstack-origin setting).

This change includes a charm-helpers sync.

Change-Id: I88ccffad7af2d2e9cddc1f6514ebd07898e117dc
2022-01-08 01:28:04 +00:00
Hervé Beraud ba8a4f71f7 Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Note that https://github.com/openstack/charms.openstack is used during tests
and he need `mock`, unfortunatelly it doesn't declare `mock` in its
requirements so it retrieve mock from other charm project (cross dependency).
So we depend on charms.openstack first and when
Ib1ed5b598a52375e29e247db9ab4786df5b6d142 will be merged then CI
will pass without errors.

Depends-On: Ib1ed5b598a52375e29e247db9ab4786df5b6d142
Change-Id: Ibefa1987730d29c04beb41f6e129e47f5524d49a
2021-12-15 14:25:30 +00:00
Arif Ali dfd3bbe5e0
Ensure apparmor is configured when writing files
When re-writing files, the apparmor configuration is not written,
this will fix this to ensure that aa-profile-mode is respected

Closes-Bug: 1947389
Change-Id: I79e9625ab4d261845822d4825ba1ed7e31d0b1e0
2021-12-07 21:04:40 +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
Zuul 9724059fb9 Merge "Process subordinate releases packages map" 2021-11-26 15:09:20 +00: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
Nobuto Murata a5dc16393a Expose reserved_host_disk_mb for nova.conf
The config is necessary to calculate available disk space for VMs with
disk-allocation-ratio which is already exposed as a charm option.

Closes-Bug: #1952184
Change-Id: I0ef55987517bded50f855e0dbc5e420cfbff4c1b
2021-11-25 15:44:48 +09:00
James Troup 034d6e36c2 Spelling fixes found by codespell.
Change-Id: I819aa04eef6cc72a24ecaf39a350b30015612165
2021-11-15 21:54:13 +00:00
Zuul 6290b2577a Merge "Fix misc issues with instances-path usage" 2021-10-25 23:14:17 +00:00
Zuul c501f196d0 Merge "Block nova-compute startup on mountpoint" 2021-10-08 16:08:30 +00:00
Nobuto Murata 22523e5b54 Allow overriding libvirt/num_pcie_ports
Especially with arm64/aarch64, the default value limits the number of
volume attachments to two usually. And when more than two volumes are to
be attached, it will fail with "No more available PCI slots". There is
no one-size-fits-all value here so let operators override the default
value.

Closes-Bug: #1944214
Change-Id: I9b9565873cbaeb575704b94a25d0a8556ab96292
2021-09-28 12:31:20 +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
Stephan Pampel 6ab0d0d5f6 Added neutron_physnet and neutron_tunnel config
Adding neutron_physnet and neutron_tunnel as config options
for numa affinity to the charm.

Implementation of [0] config options.
Only affects OpenStack releases >= rocky

[0]https://docs.openstack.org/nova/rocky/configuration/config.html#neutron.physnets

Closes-Bug: #1921067
Change-Id: Ib050c23f5e4d2da8262c37f136dbc66129141017
2021-08-31 10:24:39 +02:00
Zuul aff2a0b182 Merge "Added allocation-ratio config opts" 2021-07-15 23:36:30 +00:00
Zuul 6713703894 Merge "Port ncc pci-alias list fix to nova-compute" 2021-06-17 18:25:56 +00:00
Rodrigo Barbieri d51e010fca Port ncc pci-alias list fix to nova-compute
Port of https://review.opendev.org/535350

Fix for this bug already exists for
nova-cloud-controller charm, therefore
port it over to nova-compute.

Closes-bug: #1921147
Change-Id: I0c37d2bce3b195f5dc18111bb70a30de03b2bbc6
func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/587
2021-06-14 14:39:56 -03:00
Zuul 06fbe4aa6c Merge "Set cross_az_attach mode from ncc relation configuration" 2021-06-11 14:49:42 +00:00
Zuul 203140252c Merge " Add 'virsh-audit' action in nova-compute" 2021-06-11 14:36:41 +00:00