Skip to content

Commit 20b64ed

Browse files
authored
Merge pull request #143 from stackhpc/upstream/wallaby-2025-01-20
Synchronise wallaby with upstream
2 parents d2f3ea5 + 66e2bfd commit 20b64ed

File tree

7 files changed

+63
-62
lines changed

7 files changed

+63
-62
lines changed

.zuul.yaml

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
11
# See https://docs.openstack.org/infra/manual/drivers.html#naming-with-zuul-v3
22
# for job naming conventions.
33

4-
- job:
5-
name: nova-dsvm-multinode-base
6-
parent: legacy-dsvm-base-multinode
7-
description: |
8-
Base job for multinode nova devstack/tempest jobs.
9-
Will setup firewall rules on all the nodes allowing them to talk to
10-
each other.
11-
timeout: 10800
12-
required-projects:
13-
- openstack/devstack-gate
14-
- openstack/nova
15-
- openstack/tempest
16-
irrelevant-files: &dsvm-irrelevant-files
17-
- ^api-.*$
18-
- ^(test-|)requirements.txt$
19-
- ^.*\.rst$
20-
- ^.git.*$
21-
- ^doc/.*$
22-
- ^nova/hacking/.*$
23-
- ^nova/locale/.*$
24-
- ^nova/policies/.*$
25-
- ^nova/tests/.*$
26-
- ^nova/test.py$
27-
- ^releasenotes/.*$
28-
- ^setup.cfg$
29-
- ^tools/.*$
30-
- ^tox.ini$
31-
324
- job:
335
name: nova-tox-functional-py38
346
parent: openstack-tox-functional-py38
@@ -95,7 +67,21 @@
9567
description: |
9668
Run tempest live migration tests against local qcow2 ephemeral storage
9769
and shared LVM/iSCSI cinder volumes.
98-
irrelevant-files: *dsvm-irrelevant-files
70+
irrelevant-files: &dsvm-irrelevant-files
71+
- ^api-.*$
72+
- ^(test-|)requirements.txt$
73+
- ^.*\.rst$
74+
- ^.git.*$
75+
- ^doc/.*$
76+
- ^nova/hacking/.*$
77+
- ^nova/locale/.*$
78+
- ^nova/policies/.*$
79+
- ^nova/tests/.*$
80+
- ^nova/test.py$
81+
- ^releasenotes/.*$
82+
- ^setup.cfg$
83+
- ^tools/.*$
84+
- ^tox.ini$
9985
vars:
10086
tox_envlist: all
10187
tempest_test_regex: (^tempest\.api\.compute\.admin\.(test_live_migration|test_migration))
@@ -189,24 +175,11 @@
189175
parent: devstack-tempest
190176
description: |
191177
Run tempest compute API tests using LVM image backend. This only runs
192-
against nova/virt/libvirt/* changes.
193-
# Copy irrelevant-files from nova-dsvm-multinode-base and then exclude
194-
# anything that is not in nova/virt/libvirt/* or nova/privsep/*.
195-
irrelevant-files:
196-
- ^(?!.zuul.yaml)(?!nova/virt/libvirt/)(?!nova/privsep/).*$
197-
- ^api-.*$
198-
- ^(test-|)requirements.txt$
199-
- ^.*\.rst$
200-
- ^.git.*$
201-
- ^doc/.*$
202-
- ^nova/hacking/.*$
203-
- ^nova/locale/.*$
204-
- ^nova/tests/.*$
205-
- ^nova/test.py$
206-
- ^releasenotes/.*$
207-
- ^setup.cfg$
208-
- ^tools/.*$
209-
- ^tox.ini$
178+
against nova/virt/libvirt/*, nova/privsep/* and .zuul.yaml changes.
179+
files:
180+
- ^nova/virt/libvirt/.*$
181+
- ^nova/privsep/.*$
182+
- .zuul.yaml
210183
vars:
211184
# We use the "all" environment for tempest_test_regex and
212185
# tempest_black_regex.
@@ -528,11 +501,12 @@
528501
- nova-ceph-multistore:
529502
irrelevant-files: *dsvm-irrelevant-files
530503
- neutron-tempest-linuxbridge:
531-
irrelevant-files:
504+
files:
532505
# NOTE(mriedem): This job has its own irrelevant-files section
533506
# so that we only run it on changes to networking and libvirt/vif
534507
# code; we don't need to run this on all changes.
535-
- ^(?!nova/network/.*)(?!nova/virt/libvirt/vif.py).*$
508+
- ^nova/network/.*$
509+
- nova/virt/libvirt/vif.py
536510
- nova-live-migration
537511
- nova-lvm
538512
- nova-multi-cell
@@ -582,11 +556,12 @@
582556
- nova-ceph-multistore:
583557
irrelevant-files: *dsvm-irrelevant-files
584558
- neutron-tempest-linuxbridge:
585-
irrelevant-files:
559+
files:
586560
# NOTE(mriedem): This job has its own irrelevant-files section
587561
# so that we only run it on changes to networking and libvirt/vif
588562
# code; we don't need to run this on all changes.
589-
- ^(?!nova/network/.*)(?!nova/virt/libvirt/vif.py).*$
563+
- ^nova/network/.*$
564+
- nova/virt/libvirt/vif.py
590565
- tempest-integrated-compute:
591566
irrelevant-files: *policies-irrelevant-files
592567
- nova-grenade-multinode:

nova/compute/manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6488,9 +6488,9 @@ def _shelve_offload_instance(self, context, instance, clean_shutdown,
64886488

64896489
instance.power_state = current_power_state
64906490
# NOTE(mriedem): The vm_state has to be set before updating the
6491-
# resource tracker, see vm_states.ALLOW_RESOURCE_REMOVAL. The host/node
6492-
# values cannot be nulled out until after updating the resource tracker
6493-
# though.
6491+
# resource tracker, see vm_states.allow_resource_removal(). The
6492+
# host/node values cannot be nulled out until after updating the
6493+
# resource tracker though.
64946494
instance.vm_state = vm_states.SHELVED_OFFLOADED
64956495
instance.task_state = None
64966496
instance.save(expected_task_state=[task_states.SHELVING,

nova/compute/resource_tracker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,8 @@ def _update_usage_from_instance(self, context, instance, nodename,
14651465
# NOTE(sfinucan): Both brand new instances as well as instances that
14661466
# are being unshelved will have is_new_instance == True
14671467
is_removed_instance = not is_new_instance and (is_removed or
1468-
instance['vm_state'] in vm_states.ALLOW_RESOURCE_REMOVAL)
1468+
vm_states.allow_resource_removal(
1469+
vm_state=instance['vm_state'], task_state=instance.task_state))
14691470

14701471
if is_new_instance:
14711472
self.tracked_instances.add(uuid)
@@ -1524,7 +1525,9 @@ def _update_usage_from_instances(self, context, instances, nodename):
15241525

15251526
instance_by_uuid = {}
15261527
for instance in instances:
1527-
if instance.vm_state not in vm_states.ALLOW_RESOURCE_REMOVAL:
1528+
if not vm_states.allow_resource_removal(
1529+
vm_state=instance['vm_state'],
1530+
task_state=instance.task_state):
15281531
self._update_usage_from_instance(context, instance, nodename)
15291532
instance_by_uuid[instance.uuid] = instance
15301533
return instance_by_uuid

nova/compute/stats.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def update_stats_for_instance(self, instance, is_removed=False):
105105
(vm_state, task_state, os_type, project_id) = \
106106
self._extract_state_from_instance(instance)
107107

108-
if is_removed or vm_state in vm_states.ALLOW_RESOURCE_REMOVAL:
108+
if is_removed or vm_states.allow_resource_removal(
109+
vm_state=vm_state, task_state=task_state):
109110
self._decrement("num_instances")
110111
self.states.pop(uuid)
111112
else:

nova/compute/vm_states.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
See http://wiki.openstack.org/VMState
2828
"""
2929

30+
from nova.compute import task_states
3031
from nova.objects import fields
3132

3233

@@ -74,5 +75,11 @@
7475
# states we allow to trigger crash dump
7576
ALLOW_TRIGGER_CRASH_DUMP = [ACTIVE, PAUSED, RESCUED, RESIZED, ERROR]
7677

77-
# states we allow resources to be freed in
78-
ALLOW_RESOURCE_REMOVAL = [DELETED, SHELVED_OFFLOADED]
78+
79+
def allow_resource_removal(vm_state, task_state=None):
80+
"""(vm_state, task_state) combinations we allow resources to be freed in"""
81+
82+
return (
83+
vm_state == DELETED or
84+
vm_state == SHELVED_OFFLOADED and task_state != task_states.SPAWNING
85+
)

nova/tests/functional/regressions/test_bug_2025480.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,5 @@ def fake_spawn(*args, **kwargs):
7777

7878
node = compute_node.ComputeNode.get_by_nodename(
7979
context.get_admin_context(), 'compute1')
80-
# This is the bug, the instance should have resources claimed
81-
# self.assertEqual(1, node.vcpus_used)
82-
self.assertEqual(0, node.vcpus_used)
80+
# After the fix, the instance should have resources claimed
81+
self.assertEqual(1, node.vcpus_used)

nova/tests/unit/compute/test_stats.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,22 @@ def test_update_stats_for_instance_offloaded(self):
208208
self.assertEqual(0, self.stats.num_os_type("Linux"))
209209
self.assertEqual(0, self.stats["num_vm_" + vm_states.BUILDING])
210210

211+
def test_update_stats_for_instance_being_unshelved(self):
212+
instance = self._create_instance()
213+
self.stats.update_stats_for_instance(instance)
214+
self.assertEqual(1, self.stats.num_instances_for_project("1234"))
215+
216+
instance["vm_state"] = vm_states.SHELVED_OFFLOADED
217+
instance["task_state"] = task_states.SPAWNING
218+
self.stats.update_stats_for_instance(instance)
219+
220+
self.assertEqual(1, self.stats.num_instances)
221+
self.assertEqual(1, self.stats.num_instances_for_project(1234))
222+
self.assertEqual(1, self.stats["num_os_type_Linux"])
223+
self.assertEqual(1, self.stats["num_vm_%s" %
224+
vm_states.SHELVED_OFFLOADED])
225+
self.assertEqual(1, self.stats["num_task_%s" % task_states.SPAWNING])
226+
211227
def test_io_workload(self):
212228
vms = [vm_states.ACTIVE, vm_states.BUILDING, vm_states.PAUSED]
213229
tasks = [task_states.RESIZE_MIGRATING, task_states.REBUILDING,

0 commit comments

Comments
 (0)