-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fill fault from all nova cells in GET servers/detail #125
base: stable/queens-m3
Are you sure you want to change the base?
Fill fault from all nova cells in GET servers/detail #125
Conversation
nova/objects/instance.py
Outdated
faults_by_uuid = {} | ||
for fault in faults: | ||
faults_by_uuid[fault.instance_uuid] = fault | ||
for cm_inst in inst_cell_mappings.values(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _key(x):
return getattr(x, 'id', None) if x else None
inst_mappings = sorted(inst_mappings, key=_key)
for im, uuids in itertools.groupby(inst_mappings, key=_key):
Is that the same? If yes, please change it as it's much shorter and still more expressive in what it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not the same but I'll rework the code to look in a similar fashion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
mock_get_inst_map_list.return_value = [ | ||
mock.Mock(cell_mapping=None, | ||
instance_uuid=uuids.db_fault_1), | ||
mock.Mock(cell_mapping=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both your instances have the same cell here. If we want to upstream this - and we should - we need a proper test-case. Best thing is to have a test-case that can be run without your changes, but fails, so we can convince upstream that there's a bug. It should then work with your changes obviously ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Improved test to cover different cells.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's the right way to adjust the test. I ran your test on the old code and it's complaining about not seeing calls with all contexts made. I think it would be better, if we would add another test_fill_faults_multicell
instead of changing test_fill_faults
. This test should contain multiple instances in multiple cells, some without cell_mapping. At least one fault per cell. The test is basically the same and you can keep the assert_has_calls
if you like, but that's an implementation detail I wouldn't check.Instead, the earlier check for faults should show that not all faults for the uuids were collected (without applying your patch).
Sorry, forgot to add: the code-changes otherwise look fine. |
Done. |
If I run the tests,
|
2b257ad
to
53e9bf4
Compare
nova/objects/instance.py
Outdated
for cell_id, ims in _group_inst_mappings_by_cell_id(inst_mappings): | ||
cm, inst_uuids = None, [] | ||
for im in ims: | ||
inst_uuids.append(im.instance_uuid) | ||
cm = im.cell_mapping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand this correctly: cell_id
can be None
and im.cell_mapping
can be None
, too? Should we have an if cell_id is None: continue
in the for-loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. PR updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing a test for this. You updated the tests, so the cell-mapping is there, but nothing failed before, so we're missing a test.
No description provided.