)]}'
{"nova/compute/api.py":[{"author":{"_account_id":9555,"name":"Matthew Booth","email":"mbooth@redhat.com","username":"MatthewBooth"},"change_message_id":"764e3f57e1ca1d08a3f7c0a5d285d4447c7389ad","unresolved":false,"context_lines":[{"line_number":4033,"context_line":"                continue"},{"line_number":4034,"context_line":"            with nova_context.target_cell(context, cell):"},{"line_number":4035,"context_line":"                migrations.extend(objects.MigrationList.get_by_filters("},{"line_number":4036,"context_line":"                    context, filters).objects)"},{"line_number":4037,"context_line":"        return objects.MigrationList(objects\u003dmigrations)"},{"line_number":4038,"context_line":""},{"line_number":4039,"context_line":"    def get_migrations_in_progress_by_instance(self, context, instance_uuid,"}],"source_content_type":"text/x-python","patch_set":9,"id":"9a30ddce_b508d52e","line":4036,"updated":"2017-03-09 10:48:29.000000000","message":"I\u0027ve seen this pattern in a couple of places now. I think we need to be careful mutating the context object like this with versioned objects. I don\u0027t think it\u0027s an issue here in practice, but we need to remember that the context object we pass to get_by_filters is passed by reference, and stored in the resulting objects. This means that when we mutate it on exit from the contextmanager, we\u0027re corrupting the context objects in our list.\n\nAs I say, I don\u0027t think it\u0027s an issue in practice here. I think it would only be an issue if os-migrations tried to lazy load something, which is generally undesirable anyway. However, I still think it\u0027s a bad pattern we should probably kill early.\n\nNote that get_admin_context() avoids this problem by returning a new context, not a mutated context. I think we should kill context.target_cell() and context.set_target_cell(), and create a new get_cell_context(context, cell_mapping) which returns a new context object. A call to set_target_cell() would be replaced with:\n\n  context \u003d nova_context.get_cell_context(context, cell_mapping)\n\nThis would also have the benefit of not having side-effects outside the current scope, which is easier to reason about.\n\nUse of target_cell would be replaced with the same call, except you\u0027d store it in a new local variable rather than replacing context.","commit_id":"91c1a36a262159f522caa5cae821b36e0a0054ce"}],"nova/tests/unit/compute/test_compute.py":[{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"87369ac59f254f47c7a70ba80a61462a2e5288fd","unresolved":false,"context_lines":[{"line_number":10429,"context_line":"        filters \u003d {\u0027host\u0027: \u0027host1\u0027}"},{"line_number":10430,"context_line":""},{"line_number":10431,"context_line":"        def fake_migrations(context, filters):"},{"line_number":10432,"context_line":"            self.assertIsNotNone(context.db_connection)"},{"line_number":10433,"context_line":"            return objects.MigrationList("},{"line_number":10434,"context_line":"                objects\u003d[objects.Migration(**migration)])"},{"line_number":10435,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9a30ddce_1e6e3095","line":10432,"updated":"2017-03-09 00:23:45.000000000","message":"Good. Validating that the cell target context has been set appropriately.","commit_id":"a0b1e3b28949a402e50d3269ad042c36f49bd021"}]}
