192 Commits

Author SHA1 Message Date
Lee Yarwood
e906a8c0ec nova-manage: Introduce volume show, refresh, get_connector commands
Add a combination of commands to allow users to show existing stashed
connection_info for a volume attachment and update volume attachments
with fresh connection_info from Cinder by recreating the attachments.

Unfortunately we don't have an easy way to access host connector
information remotely (i.e. over the RPC API), meaning we need to also
provide a command to get the compute specific connector information
which must be run on the compute node that the instance is located on.

Blueprint: nova-manage-refresh-connection-info
Co-authored-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I2e3a77428f5f6113c10cc316f94bbec83f0f46c1
2021-08-25 10:26:07 +01:00
Zuul
cca1bb1bae Merge "Block servers with vGPU and device profile in heal_allocations" 2021-08-18 14:43:06 +00:00
Stephen Finucane
905c9723e9 db: Integrate alembic
This looks more complicated than it is, but it's really quite simple.
Essentially we have to deal with two possible configurations:

- For existing deployments, the DB sync operation should apply any
  outstanding sqlalchemy-migrate-based migrations, dummy apply the
  initial alembic migration, and then apply any additional alembic-based
  migrations requested (or any available, if no version is specified).

- For new deployments, the DB sync operation should apply the initial
  alembic migration and any additional alembic-based migrations
  requested (or any available, if no version is specified). No
  sqlalchemy-migrate-based migrations will ever be applied.

While we continue to allow users to request a specific database
migration version to upgrade to, we *do not* allow them to request a
sqlalchemy-migrate-based migration version. There's no good reason to do
this - the deployment won't run with an out-of-date DB schema (something
that's also true of the alembic migration, fwiw) - and we want to get
people off of sqlalchemy-migrate as fast as possible. A change in a
future release can remove the sqlalchemy-migrate-based migrations once
we're sure that they'll have upgraded to a release including all of the
sqlalchemy-migrated-based migrations (so Wallaby).

Tests are modified to validate the sanity of these operations. They're
mostly trivial changes, but we do need to do some funky things to ensure
that (a) we don't use logger configuration from 'alembic.ini' that will
mess with our existing logger configuration and (b) we re-use connection
objects as necessary to allow us to run tests against in-memory
databases, where a different connection would actually mean a different
database. We also can't rely on 'WalkVersionsMixin' from oslo.db since
that only supports sqlalchemy-migrate [1]. We instead must re-invent the
wheel here somewhat.

[1] https://github.com/openstack/oslo.db/blob/10.0.0/oslo_db/sqlalchemy/test_migrations.py#L42-L44

Change-Id: I850af601f81bd5d2ecc029682ae10d3a07c936ce
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-08-09 15:34:40 +01:00
Balazs Gibizer
59c2262ca5 Block servers with vGPU and device profile in heal_allocations
Nested allocations are only partially supported in nova-manage placement
heal_allocations CLI. This patch documents the missing support and
blocks healing instances with VGPU or Cyborg device profile request in
the embedded flavor. Blocking is needed as if --forced is used with such
instances then the tool could recreate an allocation ignoring some of
these resources.

Change-Id: I89ac90d2ea8bc268940869dbbc90352bfad5c0de
Related-Bug: bug/1939020
2021-08-06 15:58:39 +02:00
Zuul
97f1741352 Merge "Add --task-log option to nova-manage db archive_deleted_rows" 2021-06-18 11:54:56 +00:00
melanie witt
bc71331bca Add --task-log option to nova-manage db archive_deleted_rows
The task_log table contains instance usage audit records if
nova-compute has been configured with [DEFAULT]instance_usage_audit =
True. This will be the case if OpenStack Telemetry is being used in the
deployment, as the option causes nova to generate audit information
that Telemetry then retrieves from the server usage audit log API [1].

Historically, there has been no way to delete task_log table records
other than manual database modification. Because of this, task_log
records could pile up over time and operators are forced to perform
manual steps to periodically truncate the table.

This adds a --task-log option to the 'nova-manage db
archive_deleted_rows' CLI to also archive task_log records while
archiving the database. --task-log works in conjunction with --before
if operators desire archving only records that are older than <date>.
The 'updated_at' field is used by --task-log --before <date> to
determine the age of a task_log record for archival.

Closes-Bug: #1877189

[1] https://docs.openstack.org/api-ref/compute/#server-usage-audit-log-os-instance-usage-audit-log

Change-Id: Ibed67854a693c930effd4dba7aca6cd03b65bd92
2021-06-17 01:57:12 +00:00
Zuul
df3655cfdc Merge "docs: Correct typos in 'nova-manage db' docs" 2021-04-22 11:45:31 +00:00
Zuul
a8eb79804d Merge "docs: Add man pages for 'nova-policy'" 2021-04-21 18:05:08 +00:00
Zuul
5ea4f712c5 Merge "docs: Correct typos in 'nova-manage cells_v2' docs" 2021-04-19 22:17:50 +00:00
Stephen Finucane
b5edc294a1 docs: Add man pages for 'nova-policy'
I don't actually grok what this does that 'oslopolicy-checker' couldn't
do, so perhaps we can deprecate this in the future. For now though,
simply document the thing. While we're here, we make some additional
related changes:

- Remove references to the 'policy.yaml' file for services that don't
  use policy (i.e. everything except the API services and, due to a bug,
  the nova-compute service).
- Update remaining references to the 'policy.yaml' file to include the
  'policy.d/' directory
- Update the help text for the '--api-name' and '--target' options of
  the 'nova-policy policy check' command to correct tense and better
  explain their purpose.

Also, yes, 'nova-policy policy check' is dumb. Don't blame me :)

Change-Id: I913b0de9ec40a615da7bf9981852edef4a88fecb
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Related-bug: #1675486
2021-04-19 10:47:17 +01:00
Stephen Finucane
9e5feb051c docs: Populate "See Also" section with meaningful links
Change-Id: I28dbbb22f1752081615722a3932394741654a9da
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-04-13 17:22:24 +01:00
Stephen Finucane
99e5a1ac9a docs: Document options for remaining nova-* commands
Most of these share the same collection of oslo.config and oslo.log
options so it makes sense to group them together. The only exception is
nova-rootwrap, which is a wrapper around the 'oslo_rootwrap.cmd.main'
module, which curiously does not use argparse and doesn't have any
options.

Change-Id: I393ff162be58700956fbab29ff6b9ba3cf5860a6
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-04-13 17:17:27 +01:00
Stephen Finucane
03ff08c7fe docs: Correct typos in 'nova-manage cells_v2' docs
Per review feedback.

Change-Id: Ib14c8901920a0844d22674b768bc543a10298c4b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-03-31 12:01:17 +01:00
Stephen Finucane
96bf8a0ab5 docs: Correct typos in 'nova-manage db' docs
Per review feedback.

Change-Id: Id157e3614bfe9adca44e6ca0adc56e3ae9efee59
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-03-31 11:37:25 +01:00
Stephen Finucane
fe3a04be80 docs: Rewrite 'nova-manage libvirt' docs
Change-Id: Ice641a8ce2658e0df4eea08f527fe7813617218f
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-03-30 12:21:12 +01:00
Stephen Finucane
2f8ab439a7 docs: Rewrite 'nova-manage api_db', 'cell_v2' docs
Change-Id: I82c718cdf2134005d0a1639072cefe037da78f15
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-03-30 12:21:12 +01:00
Stephen Finucane
5f6aae3753 docs: Rewrite 'nova-manage placement' docs
Change-Id: Ie973de1eb411db6379b544987b55199913eb62b6
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-03-30 12:21:12 +01:00
Stephen Finucane
cefa8e0938 docs: Rewrite 'nova-manage db' docs to use proper directives
We have them. Let's use them. The resulting man pages aren't perfect,
but they're *much* better.

Change-Id: I84d54a246fecbd2f7d2950d6c6044f7cd1b8e9df
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-03-30 12:18:03 +01:00
Stephen Finucane
59e2b38c80 docs: Use proper headers in nova-manage man page
This is step one in improving the usability of these docs. The current
style makes it impossible to link to individual commands from the built
docs. There is a better way. Use headers along with code blocks to show
the actual command. This was mostly generated from a find-replace along
with some follow-up manual fixes.

Change-Id: Icd25006f31c8e34fe33d79779e0577dc78f96a24
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-03-30 11:23:44 +01:00
Lee Yarwood
8cddd243bf nova-status: Add hw_machine_type check for libvirt instances
This change introduces a new nova-status check to ensure a machine type
has been recorded for each instance within an environment.

nova-status will fail with a warning when instances are found, directing
the operator to use the previously added nova-manage list_unset and
update commands to set a machine type for these instances. The logic for
this check comes entirely from the list_unset command.

It is noted in the warning output that this can be ignored if no libvirt
or HyperV based computes are present in the environment as
hw_machine_type is only used by these two virt drivers at present.

blueprint: libvirt-default-machine-type
Change-Id: Ic3ae48c57e61c4e45883fbae1328a448be025953
2021-03-03 14:03:49 +00:00
Lee Yarwood
9a5b07d9fc nova-manage: Add libvirt list_unset_machine_type command
This change adds a libvirt command to list all instance UUIDs with
hw_machine_type unset in their image metadata. This will be useful to
operators attempting to change the [libvirt]hw_machine_type default in
the future as it allows them to confirm if it is safe to change the
configurable without impacting existing instances.

blueprint: libvirt-default-machine-type
Change-Id: I39909ace97f62e87f326d4d822d4e4c391445765
2021-03-03 14:03:49 +00:00
Lee Yarwood
c70cde057d nova-manage: Add libvirt update_machine_type command
This change adds a second update command to the libvirt group
within nova-manage. This command will set or update the machine type of
the instance when the following criteria are met:

* The instance must have a ``vm_state`` of ``STOPPED``, ``SHELVED`` or
  ``SHELVED_OFFLOADED``.

* The machine type is supported. The supported list includes alias and
  versioned types of ``pc``, ``pc-i440fx``, ``pc-q35``, ``q35``, ``virt``
  or ``s390-ccw-virtio``.

* The update will not move the instance between underlying machine types.
  For example, ``pc`` to ``q35``.

* The update will not move the instance between an alias and versioned
  machine type or vice versa. For example, ``pc`` to ``pc-1.2.3`` or
  ``pc-1.2.3`` to ``pc``.

A --force flag is provided to skip the above checks but caution
should be taken as this could easily lead to the underlying ABI of the
instance changing when moving between machine types.

blueprint: libvirt-default-machine-type
Change-Id: I6b80021a2f90d3379c821dc8f02a72f350169eb3
2021-03-03 14:03:49 +00:00
Lee Yarwood
20692c245c nova-manage: Add libvirt get_machine_type command
This change introduces the first machine_type command to nova-manage to
fetch and display the current machine type if set in the system metadata
of the instance.

blueprint: libvirt-default-machine-type
Change-Id: Idc035671892e4668141a93763f8f2bed7a630812
2021-03-03 14:03:49 +00:00
Stephen Finucane
35b58a5035 cmd: Remove 'nova-manage db ironic_flavor_migration'
This command was helpful to assist users FFUing past the Pike release,
however, it's no longer helpful and should be removed now. Do just that.

Change-Id: Ib42f65dbcf61ead571e9107e7ffbba2b29f48d64
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-02-10 15:32:03 +00:00
Stephen Finucane
2d4eff0ef7 cmd: Remove 'nova-manage db null_instance_uuid_scan'
Change I2aae01ed235f1257b0b3ddc6aee4efc7be38eb6e indicated that this
command was no longer necessary and could be removed. In hindsight, it's
been unnecessary since Liberty, which introduced a blocking migration
requiring this script be run, and it could have been deleted years ago.
No time like the present though.

Change-Id: I532c7918a8e2c887f29d2f0e1e33b80f2b3a7507
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-02-02 17:16:12 +00:00
Balazs Gibizer
3b8257cd23 Add upgrade check about old computes
Report a warning during upgrade checks if there are computes older than
the previous major nova release in the system.

So if code is upgraded to Wallaby and the upgrade check was run before
the restart of the services with W code then the check warns for Ussuri
computes in the system.

Change-Id: I873b0c1e6e695ae88241bbf75ac9f80ecc6f5664
2020-11-04 15:43:09 +01:00
Ghanshyam Mann
ef769443fb [Trivial] Replace ref of policy.json to policy.yaml
policy file default and JSON format 'policy.json' is now
deprecated. Let's replace all the ref and test start using the
policy.yaml.

Change-Id: I78a273576702fb95d831bd9b801b5774fb9fd19e
2020-09-09 16:46:43 +00:00
Ghanshyam Mann
fe545dbe5f Migrate default policy file from JSON to YAML
Default value of 'CONF.oslo_policy.policy_file' config option
has been changed from 'policy.json' to 'policy.yaml'. If new default
file 'policy.yaml' does not exist but old default 'policy.json' exist
then fallback to use old default file.

An upgrade checks is added to check the policy_file format and
fail upgrade checks if it is JSON formatted.

Added a warning in policy doc about JSON formatted file is deprecated,
also removed all the reference to policy.json file in doc as well as
in tests.

Related Blueprint: policy-json-to-yaml

Closes-Bug: #1875418

Change-Id: Ic4d3b998bb9701cb1e3ef12d9bb6f4d91cc19c18
2020-09-09 08:09:38 -05:00
Stephen Finucane
79e6d3e135 docs: Remove subtitles, metadata from man pages
These do not render correctly when generating man pages and likely exist
from a time when the pages were built with rst2man (i.e. docutils)
instead of Sphinx. They're not necessary when using Sphinx since that
information is provided via the 'man_pages' config option in 'conf.py',
which are updated here to reflect reality.

Change-Id: I133e7231112cc9025e57a29d43bfa7002ca775e7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-05-21 11:17:26 +01:00
Zuul
5b76ae4e66 Merge "Support for --force flag for nova-manage placement heal_allocations command" 2020-05-11 18:15:34 +00:00
jay
87936baaac Support for --force flag for nova-manage placement heal_allocations command
Use this flag to forcefully heal allocation for a specific instance

Change-Id: I54147d522c86d858f938df509b333b6af3189e52
Closes-Bug: #1868997
2020-05-06 13:39:13 +02:00
Takashi Natsume
2b82575f3f doc: Fix list rendering in cli/nova-status.rst
Change-Id: I29ebb4c956ce979d60f74346d93510797f8de76b
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
2020-05-02 15:17:26 +09:00
Ghanshyam Mann
d4af91f349 Add nova-status upgrade check and reno for policy new defaults
There are cases where policy file is re-generated freshly
and end up having the new defaults only but expectation is that
old deprecated rule keep working.

If a rule is present in policy file then, that has priority over
its defaults so either rules should not be present in policy file
or users need to update their token to match the overridden rule
permission.

This issue was always present when any policy defaults were changed
with old defaults being supported as deprecated. This is we have
changed all the policy for new defaults so it came up as broken case.

Adding nova-status upgrade check also to detect such policy file.

Related-Bug: #1875418

Change-Id: Id9cd65877e53577bff22e408ca07bbeec4407f6e
2020-05-01 15:32:51 +00:00
Zuul
ae39f0395f Merge "Support for nova-manage placement heal_allocations --cell" 2020-04-03 15:13:00 +00:00
hackertron
1a39ed9005 Support for nova-manage placement heal_allocations --cell
Closes-bug: #1868531

Change-Id: I98b3280583a6d12461d8aa52e5714d7606b84369
2020-04-02 16:06:38 -04:00
Sylvain Bauza
35ec5a0bd1 FUP for Add a placement audit command
Since I537ed74503d208957f0a97af3ab754a6750dac20 had some clean-up comments,
we can just provide a follow-up change.

Change-Id: Ie8b5147322e13ad7df966b5c3c41ef0418e4f64c
Related-Bug: #1793569
2020-03-30 12:18:05 +02:00
Sylvain Bauza
c03716be1f Add a placement audit command
There are different situations when allocations can be orphaned.
Adding a new nova-manage command to lookup at all resource providers
and check against the related compute nodes whether they have
orphaned allocations.

Change-Id: I537ed74503d208957f0a97af3ab754a6750dac20
Closes-Bug: #1793569
2020-01-30 14:54:03 +01:00
Zuul
7c54ec6b81 Merge "Print help if nova-manage subcommand is not specified" 2020-01-15 01:55:37 +00:00
Zuul
3d3d6d5250 Merge "Use Placement 1.35 (root_required)" 2020-01-10 02:44:45 +00:00
Eric Fried
bcc893a2b0 Use Placement 1.35 (root_required)
Placement microversion 1.35 gives us the root_required queryparam to GET
/allocation_candidates, allowing us to filter out candidates where the
*root* provider has/lacks certain traits, independent of traits
specified in any of the individual request groups.

Use it.

And add affordance for specifying such traits to the RequestSpec.

Which allows us to fix up the couple of request filters that were
hacking traits into the RequestSpec.flavor.

Change-Id: I44f02044ce178e84c23d178e5a23a3aa1208e502
2020-01-07 16:46:56 -06:00
Stephen Finucane
02eb9cffe6 Remove 'nova-xvpvncproxy'
This legacy service is no longer used and was deprecated during the
Stein cycle [1]. It's time to say adios and remove them in their
entirety. This is pretty straightforward, with the sole exception of
schema for the 'remote-consoles' API, which has to continue supporting
requests for type 'xvpvnc' even if we can't fulfil those requests now.

[1] https://review.opendev.org/#/c/610076/

Part of blueprint remove-xvpvncproxy

Depends-On: https://review.opendev.org/695853
Change-Id: I2f7f2379d0cd54e4d0a91008ddb44858cfc5a4cf
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-12-23 14:20:28 +00:00
Matt Riedemann
51b0d4ca58 Print help if nova-manage subcommand is not specified
If a nova-manage command is executed without the -h option
or a subcommand the user gets an ugly traceback. This is
easily recreated:

  $ tox -e venv -- nova-manage db

Make the action argument required, so we get a helpful error message
instead.

  $ nova-manage db
  usage: nova-manage db [-h]
                      {archive_deleted_rows,ironic_flavor_migration,
                       null_instance_uuid_scan,online_data_migrations,
                       purge,sync,version}
                      ...
  nova-manage db: error: the following arguments are required: action

Note that unit tests appear to be impossible for this, since doing so
attempts to initialize an oslo.config 'CONF' singleton and this is
something we've already done in 'nova.test' and can't do again.

Change-Id: I24d03eed3aa3b882c49916938f4c25d76fd4e831
Closes-Bug: #1837199
Co-Authored-By: Stephen Finucane <stephenfin@redhat.com>
2019-12-20 11:40:02 +00:00
Matt Riedemann
1a17fe8aab Add troubleshooting doc about rebuilding the placement db
This has come up a few times via support questions from operators
that have a nova cell database out of sync with the placement
database resulting in a mismatch in compute nodes to provider
uuids and they just want to wipe the placement database and rebuild
it from the current data in nova. This provides a document with the
high level steps to do that.

Change-Id: Ie4fed22615f60e132a887fe541771c447fae1082
2019-12-11 10:40:44 -05:00
Eric Fried
54195a1bd9 Use Placement 1.34 (string suffixes & mappings)
This commit cuts us over to using placement microversion 1.34 for GET
/allocation_candidates, thereby supporting string request group suffixes
(added in 1.33) when specified in flavor extra_specs.

The mappings (added in 1.34) are not used in code yet, but a future
patch will tie the group suffixes to the RequestGroup.requester_id so
that it can be correlated after GET /a_c. This will allow us to get rid
of map_requested_resources_to_providers, which was a hack to bridge the
gap until we had mappings from placement.

Change-Id: I52499ff6639c1a5815a8557b22dd33106dcc386b
2019-12-05 17:02:46 -06:00
Stephen Finucane
c56a635de1 nova-net: Remove 'nova-network' binary
Get excited, people. It's finally dying, for real. There is a lot more
doc work needed here, but this is a start. No need for a release note
modification since we've already said that nova-network has been
removed, so there's no point in saying that the service itself has been
removed since that's implicit.

Change-Id: I18d73212f9d98bc75974a024cf6fd872fdfb1ca4
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-11-27 09:36:17 +00:00
Stephen Finucane
19424403f4 nova-net: Remove 'nova-dhcpbridge' binary
There are actually a few things here that rely on a running
nova-dhcpbridge instances, but since it's not possible to start
nova-network now, that shouldn't matter.

Change-Id: I63447baeaac0be3fb7f919bfe588da50133c74d7
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-11-25 16:43:36 +00:00
Stephen Finucane
6537a537f9 Remove 'nova-console' service, 'console' RPC API
This legacy service was only compatible with the XenServer driver and
has effectively been replaced by the noVNC console proxy service. Remove
the service. The API that provided remote access to this service,
'os-consoles', was removed in a previous change. Note that
'os-remote-consoles' is unrelated and therefore is not removed, though
it will now reject requests for XVP VNC consoles.

This was previously discussed and agreed on openstack-dev [1] and
openstack-discuss [1].

Part of blueprint remove-xvpvncproxy

[1] http://lists.openstack.org/pipermail/openstack-dev/2018-October/135413.html
[2] http://lists.openstack.org/pipermail/openstack-discuss/2019-April/005369.html

Change-Id: Ib1ff32f04b16af7981471f67c8e0bf04e6ecb6be
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-11-22 16:09:38 +00:00
Zuul
41c2513bb2 Merge "Remove service_uuids_online_data_migration" 2019-11-18 21:01:45 +00:00
Matt Riedemann
dcd3f516d2 doc: add troubleshooting guide for cleaning up orphaned allocations
While we do not have an automated fix for bug 1849479 this provides
a troubleshooting document for working around that issue where
allocations from a server that was evacuated from a down host need
to be cleaned up manually in order to delete the resource provider
and associated compute node/service.

In general this is also a useful guide for linking up the various
resources and terms in nova and how they are reflected in placement
with the relevant commands which is probably something we should
do more of in our docs.

Change-Id: I120e1ddd7946a371888bfc890b5979f2e19288cd
Related-Bug: #1829479
2019-11-13 15:31:32 -05:00
Matt Riedemann
de5c338792 Remove service_uuids_online_data_migration
A blocker migration was added in Train [1] to force
deployments to make sure they have completed the
services.uuid online migration (added in Pike). Now
that we're in Ussuri we can drop that online data
migration code.

Note that InstanceListWithServicesTestCase is removed
because the scenario is now invalid with the blocker
DB migration.

[1] I8927b8a4513dab242d34953d13dd2cc95393dc80

Change-Id: If77702f0c3212f904443f627037782f9ad7b3b55
2019-11-08 11:38:48 -05:00