Commit Graph

209 Commits

Author SHA1 Message Date
James Page 6603a7f323 Retire master branch of nova-lxd
Drop content and replace with retirement notice.

Change-Id: I2de2eff7694d60597a6413a0a64124fbbede69bb
2019-07-23 13:56:57 +01:00
Sahid Orentino Ferdjaoui d0faf787d9 driver: add missing use_cache parameter for get_info()
With 19cb8280232 The driver interface has been updated. Now that the
method get_info() has an extra parameter 'use_cache'. That one is
currently not going to be used in lxd driver since we don't cache such
info.

Change-Id: Iaa1c7e9717619b087b98cc5171de2984954ccc6e
Closes-Bug: #1824300
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
2019-04-12 12:16:13 +00:00
Alex Kavanagh e2aab580bd Add snapped version of LXD support to nova-lxd
If LXD is installed via a snap, then the location of the console log
changes from the package version.  This patchset detects whether LXD is
snapped, and if so, provides a slightly different path for the console.

Change-Id: I369a8cf63bee86b78411c72d3c1d9d8a6da6b70d
2019-04-03 10:02:56 +00:00
Sahid Orentino Ferdjaoui 067e4bd1bf driver: catch any cleanup exceptions during spawning process
If something wrong happens during the process of spawning an
instance. The process is calling 'cleanup' to rollback, unfortunately
this process is also sensible and can fail in a way that the original
error would be hidden.

In this commit we ensure to catch any exceptions coming from cleanup
to keep the original and root error well logged.

Change-Id: I81e5d0a9532e88b11ad2ef14c995db6e6a966f2f
Related-bug: #1821878
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
2019-04-02 16:34:31 +00:00
Zuul 3c01bfcb7e Merge "Update json module to jsonutils" 2019-03-01 10:15:49 +00:00
jacky06 9bc72163ae Update json module to jsonutils
oslo project provide jsonutils, and lxd use it in many place[1],
this PS to update the remained json module to oslo jsonutils for
consistency.

[1]: https://github.com/openstack/nova-lxd/search?utf8=%E2%9C%93&q=jsonutils&type=

Change-Id: I7bfbb523f2427d8c798868964eecec955078d0fe
2019-03-01 00:41:06 +08:00
Michael Johnson 15cdfc071b Fix 'filter' object is not subscriptable
nova-lxd has a python3 compatibility issue where it will fail with:
TypeError: 'filter' object is not subscriptable

This patch corrects that problem.

Change-Id: Ib2208fdc2289b6a52e5ad41ca540c75e9d1d94b4
Closes-Bug: #1815325
2019-02-10 10:25:31 -08:00
Sahid Orentino Ferdjaoui 7e39428691 add mutex to protect container instances
(SO) Without protecting it, several methods can access in same time to
the container instance and updating the state.

(AJK) Also fix py27 change where nova.network.linux_utils has moved
to/as nova.privsep.linux_net

Closes-Bug: #1809114
Change-Id: I28e68e150f5d6e3efdb243aae9e3cf15fda01a65
Co-authored-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
Co-authored-by: Alex Kavanagh <alex.kavanagh@canonical.com>
2019-01-21 15:18:26 +00:00
Sahid Orentino Ferdjaoui bf3e123e1f fix error on delete interface when destroying instance
An instance may be destroyed prior nova-compute receives a
vif-delete-event. detach_interface() will so try to get the lxd
profile related to the instance which does not exist anymore, the
process will fail with a NotFound exception raised by lxclib.

In this commit we solve the issue by handling the exception and so
avoiding on updatating the lxc profile. We still continue the process
of vif_driver.un_plug() to ensure all got cleaned.

Change-Id: If7fd5dd17323ec625df3518311dfb012302b2711
Closes-Bug: #1808819
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
2018-12-17 10:14:20 -05:00
Sahid Orentino Ferdjaoui 01c81314b8 fix object has no attribute 'create_ovs_vif_port'
The module from vif_plug_ovs from os_iv does not exist anymore. In
this commit we import in our tree those two methods create_ovs_port()
and delete_ovs_port().

Change-Id: Ie9474e781922ea8edd413a3df59abe99a1a6db05
Closes-Bug: #1808388
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
2018-12-17 10:14:20 -05:00
Zuul 270b55759d Merge "Fix sizing and quotas nova to lxd on unsupported backends" 2018-11-14 12:17:03 +00:00
Alex Kavanagh cd95839e4e Fix sizing and quotas nova to lxd on unsupported backends
The dir and lvm backends don't support sizing and quotas.  This was made
more complicated with LXD3 as "storage" became the default and the dir
backend, if used, has to be set up as a storage pool.  LXD3 is the
default on bionic.  To resolve an openstack-ansible issue and lay the
ground work for nova-lxd and storage pools and the lxd charm, this patch
makes resolves sending sizes and quotas for a profile root device on lvm
and dir backends.

Change-Id: Idba4f5f3c6015616160d85f25a658cb7e5c43652
Closes-Bug: #1698761
2018-11-13 18:36:12 +00:00
Alex Kavanagh b49d78d033 Fix i18n import issue when using _ in storage.py
Essentially, one of the error messages (which is rarely hit), uses
the underscore (_) from nova.i18n, but it wasn't imported into the
module.

Change-Id: If72f5d16943602f2479c7558324b2ce76cbeed7b
2018-10-24 16:14:09 +01:00
Alex Kavanagh f1bbc03b65 Fix problem with 'storage.zfs_pool_name' being removed from lxd 3
LXD 3.x onwards removes the key 'storage.zfs_pool_name' from the config.
This means the storage_pool API needs to be used to get the name of the
pool that juju is using for ZFS.  This is a temporary fix until storage
pools can be threaded into nova-lxd properly. This occurs on bionic due
to LXD 3 being shipped as standard.

Change-Id: I6527640438331b86f2140cf0a772f7d207a6fd40
Closes-Bug: #1782329
2018-07-23 09:36:22 +01:00
Alex Kavanagh dbe0846b60 Add back in instance to logging entries
In a previous commit, I erroneously deleted the instance=instance dict
entry from some of the logging calls, not realising they were a feature
of oslo.logging.  This commit puts them back, and adds them in a few
more useful places for debuggin purposes.

Change-Id: I0a1be5a46a888db9f0782db90815a74d50ead298
2018-06-12 10:00:44 +00:00
Zuul 33a55bc978 Merge "'create_ovs_vif_port' function moved to os-vif" 2018-06-12 08:57:32 +00:00
Alex Kavanagh b4c89d0677 'create_ovs_vif_port' function moved to os-vif
A few functions from nova migrated to os-vif, and two were the
create_ovs_vif_port and delete_ovs_vif_port that nova-lxd uses to
do the post vif wiring on the container to connect it to the appropriate
bridge.  This just gets the correct import, and adds a bit to the
docstrings to help maintainers understand the code.

Change-Id: I0787a919275c544e4faddc9d42d8db5880ba57ee
Closes-Bug: #1776205
2018-06-11 18:10:45 +01:00
Zuul b3b4555b09 Merge "Fix file descriptors leak which as result disk usage leak produced by wrong use of python tempfile.mkstemp" 2018-06-05 12:19:45 +00:00
Alex Kavanagh 84a7945bca Fix broken debug logs and modernise string interpolation
Some of the debug logs were not actually outputing the instance;
it was just tagged in the LOF.<type>(...) command.

Also took the opportunity to modernise to '.format()' the string
interpolation to meet current guidelines.

Change-Id: I99c56ff738713140b2af16199e9e58b39bb4e396
Closes-Bug: #1657339
2018-06-01 15:40:14 +01:00
Alex Kavanagh 97cb7ea742 Enable ZFS to work with datasets and all locales
This fixes two bugs (independently) to get nova-lxd to work with
datasets (pool/set) as well as pools (just 'pool').  It also, switches
the attributes to use the '-p' option with 'zfs list' and 'zpool list'
which returns the values in bytes rather than human readable format,
which is more useful in nova-lxd.

Change-Id: I2eb1b3ba7bd482e680933808414a3992a9a1feba
Closes-Bug: #1756900
Closes-Bug: #1757371
2018-05-30 16:19:00 +01:00
Alexander Kharkov 9c411c8828 Fix file descriptors leak which as result disk usage leak
produced by wrong use of python tempfile.mkstemp

Change-Id: Ia5e015c4d7a838f7e7701e078204e7e9d0d363bb
Closes-Bug: 1771928
2018-05-18 04:54:20 +00:00
Doug Hellmann 2a17b6674d add lower-constraints job
Create a tox environment for running the unit tests against the lower
bounds of the dependencies.

Create a lower-constraints.txt to be used to enforce the lower bounds
in those tests.

Add openstack-tox-lower-constraints job to the zuul configuration.

See http://lists.openstack.org/pipermail/openstack-dev/2018-March/128352.html
for more details.

Also: fix up test due to changes in requirements/make it work with
Python 3.6

Change-Id: Iedb7fe7e5bbb8935a5a958a301ed3c5540005bbc
Depends-On: https://review.openstack.org/555034
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-05-04 16:27:33 +01:00
Alex Kavanagh 8b947ea7a5 Update nova to use nova.network.linux_utils
Commit 543776483b changed nova.network.utils ->
nova.network.linux_utils in change:
I10382329524bcd217299df15c586615193205bdc

This just updates the nova-lxd reference to it.

Change-Id: Icc3fd1c37f04399b95d822bb13e76759a3125ef3
2018-04-17 11:06:13 +01:00
Jimmy McCrory f571c64283 Use new location for nova network utilities
The 'device_exists' method moved from nova.network.linux_net to
nova.network.utils in Ieac8621217c42f8b2d08dbc58c2025262f325e1e

The 'set_device_mtu' and 'delete_net_dev' moved in
I9872056c440a706b89dd51d3b9f2418951723efa

The 'detach_volume' method has user context passed to it as of
I751fcb7532679905c4279744919c6cce84a11eb4.

The 'lxd_mock' fixture has also been updated to work with recent changes
to oslotest for autospec.

Change-Id: Iac52d616517a55984b13d3762c88c66a64292ef5
2018-04-10 12:27:40 -07:00
Alexander Kharkov 5512808831 Fixed 'privileged' instance creation using config-drive
Exsiting config drive creation flow assume that LXD
ALWAYS return UID mapping for instance.
For privieged this is not true, as not UID mapping perfomed.
Existing code which try simply split JSON answer and
lookup in it failed as result.
Parser switched to JSON based parsing and have fallback
to zero UID if no mapping found in LXD answer.

Change-Id: If11bf72a9fdeeaff4f55cfca0ec0bc0a1bc6ce3c
Closes-Bug: 1707101
2018-02-28 10:36:49 +00:00
Alex Kavanagh 6b56b30e8b Add a test for destroying an instance when in rescue mode
A previous commit added some code to delete the rescued comtainer
when the instance was in rescue mode.  This means that there are two
containers for the instance (and thus using the profile).  However, no
test was added at that stage.  This patchset adds a test to verify that
the containers do get deleted and modifies the destroy code to also
ensure that the rescue container is also stopped before deletion.

Change-Id: I586261f25e8c8b9b8acdba6cafe67491bd55b46a
2018-02-27 13:51:36 +00:00
Alexander Kharkov 3a6ea27da3 Memory hog during image import from glance fixed
In case when unified image format is used it is possible
to pass file like object to pylxd API to import image to LXD.
In that case image not read to memory and nova-compute does
not utilize abnormal amount of RAM.

requirements.txt bumped pylxd to 2.2.5 as the change requires pylxd
change "Image import - memory hog fix"
(8588c3afb316299f204ae502b1c35dd7d7e3420e)

Change-Id: I4d47ab4e40b62925c0b63e7ac740f35709df1e3d
Closes-Bug: 1714415
2018-02-22 17:46:18 +00:00
Alex Kavanagh cb136ab1e6 Add capabilities flag "supports_multiattach" flag
This adds the flag "supports_multiattach" as False to the
driver's capabilities dictionary to enable it to work with
nova from commit baa8278ca78f onwards.

Change-Id: I08defc8b506a8936bd206885c189a5f1a393d260
2018-02-22 14:18:30 +00:00
Jimmy McCrory 4e4bc6d0a7 Unblock nova-lxd gate
A recent change in nova[1] added an allocations argument to the
compute driver spawn function. Include it in nova-lxd's implementation
as well.

Also allow deletion of instances that are in a rescued state.

[1] https://review.openstack.org/#/c/511879/

Change-Id: Ie99ef6c7249b0b43cf21de6aaa883d04cdfafba2
2017-11-03 12:14:21 -07:00
James Page aaa8b60215 Redux use of InstanceInfo object
Recent changes in Nova [0] remove a number of parameters from the
InstanceInfo object; re-align the nova-lxd driver to not provide
these values when constructing this object.

Also add chown & chmod to rootwrap configuration file until
nova-lxd moves to using privsep rather than rootwrap.

Include minor change to .testr.conf to deal with switch to
stestr (via os-testr).

[0] I5fe5c8121800e2b8da0860d53d818b7bd83c9e9d

Change-Id: I21caccaeb8794d1ee82956bd8c897b3f1cc366b0
2017-09-12 10:21:17 -06:00
Jenkins e968708f66 Merge "Implemented resume_state_on_host_boot driver callback" 2017-08-24 10:58:12 +00:00
Alexander Kharkov d82fc3347d Implemented resume_state_on_host_boot driver callback
As result it is possible to use nova configuration option
'resume_guests_state_on_host_boot' option.
This option allow to keep instance RUNNING state across reboots
so if instance was in RUNNING state before reboot it will
started after reboot.

Change-Id: I884e0d1bf136488c1930673b25a560d0add12beb
Closes-Bug: 1708393
2017-08-14 07:12:05 +00:00
Alexander Kharkov 9307fcc208 Raise understandable by nova exception when LXD instance not found on host.
If LXD instance on host lost for some reason (corrupted, host
reinstall) but present in controller DB nova compute service
on compute node fails to start.
Nova manager asks LXD driver about instance info and got
LXD specific exception instead of responce or proper InstanceNotFound.
As result nova compute manager service became unusable - it does not
even register itself in controller and shown as 'down'.

Change-Id: I98b6b7ec0a9ccd31aa6d46ec3dedb923022cfcca
Closes-Bug: 1708589
2017-08-04 06:47:14 +00:00
Jenkins b10ec6f34e Merge "Added support for the LXD unified tarball format" 2017-08-03 12:57:40 +00:00
Alexander Kharkov b947a9afb3 Added support for the LXD unified tarball format
Attempt to detect if image imported from glance is in unified LXD format
(metadata + rootfs/) and import this image to LXD 'as is' if any -
without implicit metdata injection.

Existing behavior leads to unusable for instance creation LXD images
if they are in unified format and imported via nova LXD driver
as LXD can not instantiate rootfs properly for such images

Simple use case does not work without this fix:
1. create instance -> create snapshot -> launch instance from snapshot
image

Image format identification is straightforward - attempt to search
metadata.yaml in tarball /. If found 'unified' format assumed.

Additional issues fixed:
1. fixed issue when instance from snapshot image can not be launched
   on compute node where snapshot was created. The reason is image
   already present in LXD without glance alias after snapshot creation.
   As result nova tries to import it again from glance and got error
   from LXD - "Image with same fingerprint already exists".
   Attempt to lookup LXD image also by fingerprint during import
   and if any do not import but simply add required by nova alias.

Closes-Bug: 1651506
Change-Id: I77d3b7c8d7cf43d505fd86b294779dada204919a
2017-08-02 05:42:27 +00:00
Chuck Short af15cd09d4 Fix traceback when running nova-console
Recently utils.last_bytes has moved to libvirt/utils.py in nova.
(2341a41eaee5152e95379e5ed38012270af82ef5). Duplicate the function
that was in nova/utils.py.

Also includes a fix for nova-lxd's gate:
Update test-requirements with wsgi-intercept

Closes-Bug: #1707096

Change-Id: Ie77c8e67e29e8a01bbf58ab9277c5110cd7c112e
Signed-off-by: Chuck Short <charles.short@ericsson.com>>
2017-07-31 10:14:14 +02:00
James Page 78b6c14f2c vif: redux interface wiring approach
The nova-lxd driver has to take a slightly different approach
to virtual interface wiring due to a lack of an equivalent to
'launch and pause' in LXD.

For some interface types, the last mile tap device needs to
be present for vif plugging to complete successfully which
occurs prior to the instance being launched; This change
refactors the vif module to create veth pairs directly
in nova-lxd, rather than delegating this to LXD as part of
a bridged network interface type.  This allows vif plugging
to complete prior to the instance being created in LXD.

The side effect of this change is that all currently supported
interface types are now configured as 'physical' interfaces
in LXD profiles for instances - wiring to bridges is handled
directly by the nova-lxd driver instead.

This change has been validated with:

   ovs driver + iptables hybrid firewall driver
   ovs driver + openvswitch native firewall driver
   linuxbridge driver + iptables hybrid firewall driver

The VIF wiring approach is described in detail in the VIF
wiring documentation included in this change.

Closes-Bug: 1681758
Change-Id: Ic268e989d1ee19f696298fb1e0db729a00352a12
2017-07-12 15:45:59 +01:00
Jenkins bfb061d02c Merge "Using assertIsNone(xxx) instead of assertEqual(None, xxx)" 2017-06-15 15:58:01 +00:00
James Page 16866d2cf8 Refactor container VIF handling for linuxbridge
Neutron recently changed behaviour to complete all bridge setup
and configuration for the linuxbridge driver via the neutron
linuxbridge agent, requiring Nova simply to setup the tap device
that subsequently gets plugged into a linuxbridge.

Rework plug/unplug handling based on libvirt driver to fallback
to a legacy style plug/unplug driver for tap devices of this kind.

In the case of LXD we actually still use a veth pair so that:

  a) security group rules are applied to the tap named
     device on the host.
  b) the container still gets part of a nic to use, named
     ethX internally to the container.
  c) the neutron linuxbridge agent can see the required tapXXX
     device prior to the container being created, allowing
     VIF plugging to be completed.

This looks something like this once wired and running:

           Host       |     Container

  [bridge] <-> [tapXXX|tinXXX] <-> [ethX]

The veth pair is mapping into a LXD container using the physical
LXD nic type.

As the drive now creates the veth pair for unbridged network
types, unplug must occur after the device has been removed
from the container during interface_detach.

Rework LXD device profile naming for consistency:

  a) VIFs attaching to bridges will be named inline with the
     bridge (no-change)
  b) VIFs not being attached to a bridge will be named with
     the VIF devname (changed from 'unbridged' which did not
     support any multiplicity).

Change-Id: I2fdf41e5640f5ca5e3bcd7df1aa159a65b706138
Closes-Bug: 1694719
2017-06-12 15:14:28 +01:00
James Page 698f3da561 Re-check image alias prior to sync from glance
If two processes attempt to upload the same image at the same
time, the second will fail as the image alias will already have
been created by the first process.

Re-check by image alias as part of the lock context for the image
prior to syncing the image from glance to ensure that a duplicate
sync is not executed.

Change-Id: Ie5ef1fcf9170e18cf41767683036162fd509ee94
Closes-bug: 1697455
2017-06-12 14:57:13 +01:00
Vu Cong Tuan 2760941c2f Using assertIsNone(xxx) instead of assertEqual(None, xxx)
Refer to OpenStack Style Guidelines:
https://docs.openstack.org/developer/hacking/#unit-tests-and-assertraises

[H203] Unit test assertions tend to give better messages for more
specific assertions. As a result, assertIsNone(xxx) is preferred over
assertEqual(None, xxx)

Change-Id: I8ccc344a40762ddc01253e23b533e27f3618d5f1
2017-06-03 16:13:20 +07:00
Jenkins 52232047f1 Merge "Add storage pool support" 2017-05-22 10:37:40 +00:00
Chris MacNaughton d883fa99eb Add storage pool support
LXD has grown support for multiple storage pools
defined by name and type (btrfs, zfs, lvm, etc)
and we would like to support this in nova-lxd

Change-Id: I702d1600fdf70bfd1e2402e3455dd868e25214c0
2017-05-19 08:55:30 +02:00
James Page 95e1db84bc Pass readonly flag as a string, not a boolean.
The LXD API requires that data be passed as strings; pass the
readonly flag for config-drive support as a string to ensure
it can be parsed by LXD avoiding the following error:

  json: cannot unmarshal bool into Go value of type string

Change-Id: I0c5dbd9cb8b8ea4f43398849f8b4c33305231d54
Closes-Bug: 1691428
2017-05-17 10:54:06 +01:00
Chris MacNaughton ff1c8cd12c Update output to match our specs
python 2.x matched these correctly without the casts but a version
bump to python 3.x (identified in 3.5.3) changes the output, this
change casts to int when we expect an integer output

Change-Id: Id6010b95a3c90d5538497c9936a6484400436ca6
2017-04-27 11:42:02 +02:00
James Page 02ce341738 Report ZFS pool capacity and usage statistics
When LXD is using a ZFS backend, correctly report disk stats
based on the usage of the ZFS pool rather than the usage of
the filesystem at /var/lib/lxd.

Change-Id: I2f2b843156cdc47c2f3324d69c384f943a0e1499
Closes-Bug: 1680869
2017-04-07 17:17:41 +01:00
Jenkins a91cdd62ce Merge "Allow mounting more device types" 2017-04-05 14:29:07 +00:00
Jenkins 2d1db850e2 Merge "Remove log translations" 2017-04-05 13:42:04 +00:00
James Page c3f55e797e Ensure config-drive is read-only
The /config-drive dir presented from the host OS should
be presented as read only to ensure that the instance
can write directly to the host OS filesystem.

Change-Id: I997ef68048fa0a77f9cb0b70c325b9b96c079e2f
Closes-Bug: 1675741
2017-03-24 13:14:18 +00:00
James Page 991b2bd550 Fix config-drive support inline with cloud-init
Proposed changes to cloud-init under the same bug will
introduce behaviour to support a config-drive type concept
for LXD containers at /config-drive.

The current path is broken; switch to this new path to
support offline configuration of cloud instances.

Change-Id: I4996a34f84eb088c408a6454de9281908490a8eb
Closes-Bug: 1673411
2017-03-24 08:06:55 +00:00