Warn if group_policy is missing from flavor

If there are more than one numbered request group in an allocation
candidate query then the group_policy paramtere is mandatory. Numbered
request groups can come from the flavor extra_spec as well as from
neutron port having resource request. This patch adds a warning if the
group_policy is missing to help the troubleshooting. Nova cannot default
the policy in this case as both isolat and None could be a valid policy
for SRIOV ports. Isolate would mean PF anti affinity for SRIOV ports
while None would allow colocation of the VFs.

blueprint bandwidth-resource-provider

Change-Id: I32d9704fe19bc85e06a613b6dffb99f00003315e
This commit is contained in:
Balazs Gibizer 2019-03-06 11:01:22 +01:00 committed by Eric Fried
parent 6304bcf781
commit 9e31f769fc
2 changed files with 33 additions and 0 deletions

View File

@ -296,12 +296,31 @@ class ResourceRequest(object):
qparams = []
if self._group_policy is not None:
qparams.append(('group_policy', self._group_policy))
nr_of_numbered_groups = 0
for ident, rg in self._rg_by_id.items():
# [('resourcesN', 'rclass:amount,rclass:amount,...'),
# ('requiredN', 'trait_name,!trait_name,...'),
# ('member_ofN', 'in:uuid,uuid,...'),
# ('member_ofN', 'in:uuid,uuid,...')]
qparams.extend(to_queryparams(rg, ident or ''))
if ident:
nr_of_numbered_groups += 1
if nr_of_numbered_groups >= 2 and not self._group_policy:
# we know this will fail in placement so help the troubleshooting
LOG.warning(
"There is more than one numbered request group in the "
"allocation candidate query but the flavor did not specify "
"any group policy. This query will fail in placement due to "
"the missing group policy. If you specified more than one "
"numbered request group in the flavor extra_spec or booted "
"with more than one neutron port that has resource request "
"(i.e. the port has a QoS minimum bandwidth policy rule "
"attached) then you have to specify the group policy in the "
"flavor extra_spec. If it is OK to let these groups be "
"satisfied by overlapping resource providers then use "
"'group_policy': 'None'. If you want each group to be "
"satisfied from a separate resource provider then use "
"'group_policy': 'isolate'.")
return parse.urlencode(sorted(qparams))

View File

@ -623,6 +623,20 @@ class TestUtils(test.NoDBTestCase):
)
self.assertEqual(expected_querystring, rr.to_querystring())
def test_more_than_one_resource_request_without_group_policy_warns(self):
extra_specs = {
'resources:VCPU': '2',
'resources1:CUSTOM_FOO': '1'
}
rr = utils.ResourceRequest.from_extra_specs(extra_specs)
rr.add_request_group(objects.RequestGroup(resources={'CUSTOM_BAR': 5}))
rr.to_querystring()
self.assertIn(
"There is more than one numbered request group in the allocation "
"candidate query but the flavor did not specify any group policy.",
self.stdlog.logger.output)
def test_resource_request_from_extra_specs_append_request(self):
extra_specs = {
'resources:VCPU': '2',