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>
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
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>
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
(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>
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>
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>
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
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
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
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
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
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
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
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>
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
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
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
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
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
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
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
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
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
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
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
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>>
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
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
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
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
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
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
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
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
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
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