Skip to content

Commit f79342f

Browse files
authored
Merge pull request #41 from stackhpc/upstream/master-2025-04-14
Synchronise master with upstream
2 parents b29a2ce + 1b6d6de commit f79342f

31 files changed

+306
-238
lines changed

HACKING.rst

-7
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,12 @@ As such, we tend to follow Neutron conventions regarding coding style.
1010

1111
Octavia Specific Commandments
1212
-----------------------------
13-
- [O316] Change assertTrue(isinstance(A, B)) by optimal assert like
14-
assertIsInstance(A, B).
15-
- [O318] Change assert(Not)Equal(A, None) or assert(Not)Equal(None, A)
16-
by optimal assert like assertIs(Not)None(A).
1713
- [O319] Validate that debug level logs are not translated.
1814
- [O321] Validate that jsonutils module is used instead of json
1915
- [O322] Don't use author tags
2016
- [O323] Change assertEqual(True, A) or assertEqual(False, A) to the more
2117
specific assertTrue(A) or assertFalse(A)
2218
- [O324] Method's default argument shouldn't be mutable
23-
- [O338] Change assertEqual(A in B, True), assertEqual(True, A in B),
24-
assertEqual(A in B, False) or assertEqual(False, A in B) to the more
25-
specific assertIn/NotIn(A, B)
2619
- [O339] LOG.warn() is not allowed. Use LOG.warning()
2720
- [O340] Don't use xrange()
2821
- [O341] Don't translate logs.

api-ref/source/v2/examples/availabilityzoneprofile-create-request.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
{
44
"name": "some_az",
55
"provider_name": "amphora",
6-
"availability_zone_data": "{\"compute_zone\": \"az1\"}"
6+
"availability_zone_data": "{\"compute_zone\": \"az1\", \"volume_zone\": \"az1\"}"
77
}
88
}

api-ref/source/v2/examples/availabilityzoneprofile-create-response.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"id": "5712097e-0092-45dc-bff0-ab68b61ad51a",
55
"name": "some_az",
66
"provider_name": "amphora",
7-
"availability_zone_data": "{\"compute_zone\": \"az1\"}"
7+
"availability_zone_data": "{\"compute_zone\": \"az1\", \"volume_zone\": \"az1\"}"
88
}
99
}

api-ref/source/v2/examples/availabilityzoneprofile-list-response.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"id": "5712097e-0092-45dc-bff0-ab68b61ad51a",
55
"name": "some_az",
66
"provider_name": "amphora",
7-
"availability_zone_data": "{\"compute_zone\": \"az1\"}"
7+
"availability_zone_data": "{\"compute_zone\": \"az1\", \"volume_zone\": \"az2\"}"
88
}
99
]
1010
}

api-ref/source/v2/examples/availabilityzoneprofile-show-response.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"id": "5712097e-0092-45dc-bff0-ab68b61ad51a",
55
"name": "some_az",
66
"provider_name": "amphora",
7-
"availability_zone_data": "{\"compute_zone\": \"az1\"}"
7+
"availability_zone_data": "{\"compute_zone\": \"az1\", \"volume_zone\": \"az1\"}"
88
}
99
}

api-ref/source/v2/examples/availabilityzoneprofile-update-request.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
{
44
"name": "other_az",
55
"provider_name": "amphora",
6-
"availability_zone_data": "{\"compute_zone\": \"az2\"}"
6+
"availability_zone_data": "{\"compute_zone\": \"az2\", \"volume_zone\": \"az2\"}"
77
}
88
}

api-ref/source/v2/examples/availabilityzoneprofile-update-response.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"id": "5712097e-0092-45dc-bff0-ab68b61ad51a",
55
"name": "other_az",
66
"provider_name": "amphora",
7-
"availability_zone_data": "{\"compute_zone\": \"az2\"}"
7+
"availability_zone_data": "{\"compute_zone\": \"az2\", \"volume_zone\": \"az2\"}"
88
}
99
}

api-ref/source/v2/examples/provider-availability-zone-capability-show-response.json

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
{
44
"name": "compute_zone",
55
"description": "The compute availability zone."
6+
},
7+
{
8+
"name": "volume_zone",
9+
"description": "The volume availability zone."
610
}
711
]
812
}

doc/source/contributor/guides/providers.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,7 @@ description. For example:
17821782
.. code-block:: python
17831783
17841784
{"compute_zone": "The compute availability zone to use for this loadbalancer.",
1785+
"volume_zone": "The volume availability zone to use for this loadbalancer.",
17851786
"management_network": "The management network ID for the loadbalancer.",
17861787
"valid_vip_networks": "List of network IDs that are allowed for VIP use. This overrides/replaces the list of allowed networks configured in `octavia.conf`."}
17871788

octavia/api/drivers/amphora_driver/availability_zone_schema.py

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
"type": "string",
4040
"description": "The compute availability zone."
4141
},
42+
consts.VOLUME_ZONE: {
43+
"type": "string",
44+
"description": "The volume availability zone."
45+
},
4246
consts.MANAGEMENT_NETWORK: {
4347
"type": "string",
4448
"description": "The management network ID for the amphora."

octavia/api/drivers/amphora_driver/v2/driver.py

+12
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,18 @@ def validate_availability_zone(self, availability_zone_dict):
582582
# when the octavia-lib supports it.
583583
compute_driver.validate_availability_zone(compute_zone)
584584

585+
volume_zone = availability_zone_dict.get(consts.VOLUME_ZONE, None)
586+
if volume_zone:
587+
volume_driver = stevedore_driver.DriverManager(
588+
namespace='octavia.volume.drivers',
589+
name=CONF.controller_worker.volume_driver,
590+
invoke_on_load=True
591+
).driver
592+
593+
# TODO(johnsom) Fix this to raise a NotFound error
594+
# when the octavia-lib supports it.
595+
volume_driver.validate_availability_zone(volume_zone)
596+
585597
check_nets = availability_zone_dict.get(
586598
consts.VALID_VIP_NETWORKS, [])
587599
management_net = availability_zone_dict.get(

octavia/api/drivers/noop_driver/driver.py

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ def get_supported_availability_zone_metadata(self):
260260
self.__class__.__name__)
261261

262262
return {"compute_zone": "The compute availability zone to use for "
263+
"this loadbalancer.",
264+
"volume_zone": "The volume availability zone to use for "
263265
"this loadbalancer."}
264266

265267
def validate_availability_zone(self, availability_zone_metadata):

octavia/common/constants.py

+1
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@
332332
COMPUTE_ID = 'compute_id'
333333
COMPUTE_OBJ = 'compute_obj'
334334
COMPUTE_ZONE = 'compute_zone'
335+
VOLUME_ZONE = 'volume_zone'
335336
CONN_MAX_RETRIES = 'conn_max_retries'
336337
CONN_RETRY_INTERVAL = 'conn_retry_interval'
337338
CREATED_AT = 'created_at'

octavia/compute/compute_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def build(self, name="amphora_name", amphora_flavor=None,
4242
well or a string
4343
:param server_group_id: Optional server group id(uuid) which is used
4444
for anti_affinity feature
45-
:param availability_zone: Name of the compute availability zone.
45+
:param availability_zone: Availability zone data dict
4646
4747
:raises ComputeBuildException: if compute failed to build amphora
4848
:returns: UUID of amphora

octavia/compute/drivers/nova_driver.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ def build(self, name="amphora_name", amphora_flavor=None,
9090
well or a string
9191
:param server_group_id: Optional server group id(uuid) which is used
9292
for anti_affinity feature
93-
:param availability_zone: Name of the compute availability zone.
94-
93+
:param availability_zone: Availability zone data dict
9594
:raises ComputeBuildException: if nova failed to build virtual machine
9695
:returns: UUID of amphora
9796
@@ -109,7 +108,12 @@ def build(self, name="amphora_name", amphora_flavor=None,
109108

110109
server_group = None if server_group_id is None else {
111110
"group": server_group_id}
112-
az_name = availability_zone or CONF.nova.availability_zone
111+
112+
if availability_zone:
113+
az_name = availability_zone.get(constants.COMPUTE_ZONE,
114+
CONF.nova.availability_zone)
115+
else:
116+
az_name = CONF.nova.availability_zone
113117

114118
image_id = self.image_driver.get_image_id_by_tag(
115119
image_tag, image_owner)
@@ -127,7 +131,7 @@ def build(self, name="amphora_name", amphora_flavor=None,
127131
LOG.debug('Creating volume for amphora from image %s',
128132
image_id)
129133
volume_id = self.volume_driver.create_volume_from_image(
130-
image_id)
134+
image_id, availability_zone)
131135
LOG.debug('Created boot volume %s for amphora', volume_id)
132136
# If use volume based, does not require image ID anymore
133137
image_id = None

octavia/controller/worker/v2/tasks/compute_tasks.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,9 @@ def execute(self, amphora_id, server_group_id, config_drive_files=None,
107107
amp_image_tag = CONF.controller_worker.amp_image_tag
108108

109109
if availability_zone:
110-
amp_availability_zone = availability_zone.get(
111-
constants.COMPUTE_ZONE)
112110
amp_network = availability_zone.get(constants.MANAGEMENT_NETWORK)
113111
if amp_network:
114112
network_ids = [amp_network]
115-
else:
116-
amp_availability_zone = None
117113
try:
118114
if CONF.haproxy_amphora.build_rate_limit != -1:
119115
self.rate_limit.add_to_build_request_queue(
@@ -146,7 +142,7 @@ def execute(self, amphora_id, server_group_id, config_drive_files=None,
146142
config_drive_files=config_drive_files,
147143
user_data=user_data,
148144
server_group_id=server_group_id,
149-
availability_zone=amp_availability_zone)
145+
availability_zone=availability_zone)
150146

151147
LOG.info("Server created with id: %s for amphora id: %s",
152148
compute_id, amphora_id)

octavia/hacking/checks.py

-58
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,11 @@
4242
hints='|'.join(_all_hints),
4343
))
4444

45-
assert_trueinst_re = re.compile(
46-
r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, "
47-
r"(\w|\.|\'|\"|\[|\])+\)\)")
48-
assert_equal_in_end_with_true_or_false_re = re.compile(
49-
r"assertEqual\((\w|[][.'\"])+ in (\w|[][.'\", ])+, (True|False)\)")
50-
assert_equal_in_start_with_true_or_false_re = re.compile(
51-
r"assertEqual\((True|False), (\w|[][.'\"])+ in (\w|[][.'\", ])+\)")
5245
assert_equal_with_true_re = re.compile(
5346
r"assertEqual\(True,")
5447
assert_equal_with_false_re = re.compile(
5548
r"assertEqual\(False,")
5649
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
57-
assert_equal_end_with_none_re = re.compile(r"(.)*assertEqual\(.+, None\)")
58-
assert_equal_start_with_none_re = re.compile(r".*assertEqual\(None, .+\)")
59-
assert_not_equal_end_with_none_re = re.compile(
60-
r"(.)*assertNotEqual\(.+, None\)")
61-
assert_not_equal_start_with_none_re = re.compile(
62-
r"(.)*assertNotEqual\(None, .+\)")
6350
revert_must_have_kwargs_re = re.compile(
6451
r'[ ]*def revert\(.+,[ ](?!\*\*kwargs)\w+\):')
6552
untranslated_exception_re = re.compile(r"raise (?:\w*)\((.*)\)")
@@ -73,35 +60,6 @@ def _translation_checks_not_enforced(filename):
7360
return any(pat in filename for pat in ["/tests/", "rally-jobs/plugins/"])
7461

7562

76-
@core.flake8ext
77-
def assert_true_instance(logical_line):
78-
"""Check for assertTrue(isinstance(a, b)) sentences
79-
80-
O316
81-
"""
82-
if assert_trueinst_re.match(logical_line):
83-
yield (0, "O316: assertTrue(isinstance(a, b)) sentences not allowed. "
84-
"Use assertIsInstance instead.")
85-
86-
87-
@core.flake8ext
88-
def assert_equal_or_not_none(logical_line):
89-
"""Check for assertEqual(A, None) or assertEqual(None, A) sentences,
90-
91-
assertNotEqual(A, None) or assertNotEqual(None, A) sentences
92-
93-
O318
94-
"""
95-
msg = ("O318: assertEqual/assertNotEqual(A, None) or "
96-
"assertEqual/assertNotEqual(None, A) sentences not allowed")
97-
res = (assert_equal_start_with_none_re.match(logical_line) or
98-
assert_equal_end_with_none_re.match(logical_line) or
99-
assert_not_equal_start_with_none_re.match(logical_line) or
100-
assert_not_equal_end_with_none_re.match(logical_line))
101-
if res:
102-
yield (0, msg)
103-
104-
10563
@core.flake8ext
10664
def assert_equal_true_or_false(logical_line):
10765
"""Check for assertEqual(True, A) or assertEqual(False, A) sentences
@@ -122,22 +80,6 @@ def no_mutable_default_args(logical_line):
12280
yield (0, msg)
12381

12482

125-
@core.flake8ext
126-
def assert_equal_in(logical_line):
127-
"""Check for assertEqual(A in B, True), assertEqual(True, A in B),
128-
129-
assertEqual(A in B, False) or assertEqual(False, A in B) sentences
130-
131-
O338
132-
"""
133-
res = (assert_equal_in_start_with_true_or_false_re.search(logical_line) or
134-
assert_equal_in_end_with_true_or_false_re.search(logical_line))
135-
if res:
136-
yield (0, "O338: Use assertIn/NotIn(A, B) rather than "
137-
"assertEqual(A in B, True/False) when checking collection "
138-
"contents.")
139-
140-
14183
@core.flake8ext
14284
def no_log_warn(logical_line):
14385
"""Disallow 'LOG.warn('

octavia/tests/functional/api/v2/test_provider.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,14 @@ def test_nonexistent_provider(self):
186186
provider='bogus'), status=400)
187187

188188
def test_noop_provider(self):
189-
ref_capabilities = [{'description': 'The compute availability zone to '
190-
'use for this loadbalancer.',
191-
'name': constants.COMPUTE_ZONE}]
189+
ref_capabilities = [
190+
{'description': 'The compute availability zone to '
191+
'use for this loadbalancer.',
192+
'name': constants.COMPUTE_ZONE},
193+
{'description': 'The volume availability zone to '
194+
'use for this loadbalancer.',
195+
'name': constants.VOLUME_ZONE},
196+
]
192197

193198
result = self.get(
194199
self.AVAILABILITY_ZONE_CAPABILITIES_PATH.format(
@@ -220,9 +225,14 @@ def test_not_implemented(self, mock_get_metadata):
220225
provider='noop_driver'), status=501)
221226

222227
def test_authorized(self):
223-
ref_capabilities = [{'description': 'The compute availability zone to '
224-
'use for this loadbalancer.',
225-
'name': constants.COMPUTE_ZONE}]
228+
ref_capabilities = [
229+
{'description': 'The compute availability zone to '
230+
'use for this loadbalancer.',
231+
'name': constants.COMPUTE_ZONE},
232+
{'description': 'The volume availability zone to '
233+
'use for this loadbalancer.',
234+
'name': constants.VOLUME_ZONE},
235+
]
226236
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
227237
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
228238
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)

0 commit comments

Comments
 (0)