)]}'
{"nova/objects/instance_mapping.py":[{"author":{"_account_id":21813,"name":"Andrey Volkov","email":"m@amadev.ru","username":"avolkov"},"change_message_id":"c06b77d8bb4506b1b1b6ef67750a3e2b60441ea0","unresolved":false,"context_lines":[{"line_number":212,"context_line":"@db_api.api_context_manager.reader"},{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5f7c97a3_726a8381","line":215,"updated":"2018-05-28 09:26:02.000000000","message":"This var is for eliminating instances that are in progress of creating, right?\n\nCould it be time \u003d now() - (max(time_of_instance_create)) - some_safety_gap?","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"124f6cca1fad138250557ef0eabca33f39f572d6","unresolved":false,"context_lines":[{"line_number":212,"context_line":"@db_api.api_context_manager.reader"},{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5f7c97a3_b56d2a04","line":215,"in_reply_to":"5f7c97a3_726a8381","updated":"2018-05-31 12:54:56.000000000","message":"\u003e This var is for eliminating instances that are in progress of\n \u003e creating, right?\n\nYes\n\n \u003e \n \u003e Could it be time \u003d now() - (max(time_of_instance_create)) -\n \u003e some_safety_gap?\n\n\nsafety_gap will have to be hardcoded, however let\u0027s say now() - time of the last created instance in the cell (assuming this is what you mean by (max(time_of_instance_create))) is a couple of seconds like 5secs, not sure how I can compare that with the created_at ? You mean now() - instance.created_at \u003e\u003d now() - (max(time_of_instance_create)) - some_safety_gap?","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"240c1fb313184d7ffe72d0a68df9bf7d940d510c","unresolved":false,"context_lines":[{"line_number":212,"context_line":"@db_api.api_context_manager.reader"},{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5f7c97a3_c9bcb8bc","line":215,"in_reply_to":"5f7c97a3_90dee90e","updated":"2018-06-01 13:51:38.000000000","message":"sure, but isn\u0027t it better to remove as many as we can and get it cleared up, and since this would be done in Queens/Rocky and for instances (which would be old) archived before the patch here https://review.openstack.org/#/c/515034/ I guess it doesn\u0027t matter whether its now() or now()-10 unless I am missing something.","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":21813,"name":"Andrey Volkov","email":"m@amadev.ru","username":"avolkov"},"change_message_id":"489f0d63033f6060e404fd79c4fc9b4971d9a7e2","unresolved":false,"context_lines":[{"line_number":212,"context_line":"@db_api.api_context_manager.reader"},{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"}],"source_content_type":"text/x-python","patch_set":2,"id":"5f7c97a3_90dee90e","line":215,"in_reply_to":"5f7c97a3_b56d2a04","updated":"2018-06-01 13:39:14.000000000","message":"Probably, I didn\u0027t make it clear.\nThis is a minor thing and could be hardcoded as 10 minutes for example.\n\ntime \u003d timeutils.utcnow() - datetime.timedelta(minutes\u003d10)","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":21813,"name":"Andrey Volkov","email":"m@amadev.ru","username":"avolkov"},"change_message_id":"c06b77d8bb4506b1b1b6ef67750a3e2b60441ea0","unresolved":false,"context_lines":[{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"},{"line_number":219,"context_line":"        inst_uuids \u003d [instance.uuid for instance in instances]"}],"source_content_type":"text/x-python","patch_set":2,"id":"5f7c97a3_523d078d","line":216,"updated":"2018-05-28 09:26:02.000000000","message":"Taking into account we could have a lot of instances,\nI believe it should be split by chunks.","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"7bc7ec965969c14abaffb68f4ead83a170ef38e2","unresolved":false,"context_lines":[{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"},{"line_number":219,"context_line":"        inst_uuids \u003d [instance.uuid for instance in instances]"}],"source_content_type":"text/x-python","patch_set":2,"id":"5f7c97a3_dede94d9","line":216,"in_reply_to":"5f7c97a3_29a44ca5","updated":"2018-06-04 08:37:00.000000000","message":"\u003e \u003e I see the following approach:\n \u003e \u003e\n \u003e \u003e 1) get a bunch of InstanceMappings from current cell\n \u003e \u003e 2) get a bunch of Instances corresponding those InstanceMappings\n \u003e \u003e 3) determine what InstanceMappings don\u0027t have corresponding\n \u003e \u003e Instances.\n \u003e \u003e 4) delete them\n \u003e \u003e rinse and repeat\n \u003e \n \u003e \n \u003e Since this is basically a one time operation for operators to clean\n \u003e up orphaned records, I would rather it be done in a single blow for\n \u003e each cell.\n\nSince there are concerns regarding the massive query size of all instances in the cell, I will see if this could be done in batches with a marker so that its exact 50 that we collect and terminate on one go.","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"240c1fb313184d7ffe72d0a68df9bf7d940d510c","unresolved":false,"context_lines":[{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"},{"line_number":219,"context_line":"        inst_uuids \u003d [instance.uuid for instance in instances]"}],"source_content_type":"text/x-python","patch_set":2,"id":"5f7c97a3_29a44ca5","line":216,"in_reply_to":"5f7c97a3_29fa0cbc","updated":"2018-06-01 13:51:38.000000000","message":"\u003e I see the following approach:\n \u003e \n \u003e 1) get a bunch of InstanceMappings from current cell\n \u003e 2) get a bunch of Instances corresponding those InstanceMappings\n \u003e 3) determine what InstanceMappings don\u0027t have corresponding\n \u003e Instances.\n \u003e 4) delete them\n \u003e rinse and repeat\n\n\nSince this is basically a one time operation for operators to clean up orphaned records, I would rather it be done in a single blow for each cell.\n\n \u003e \n \u003e same for BuildRequests\n\ns/BuildRequests/RequestSpecs.","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"124f6cca1fad138250557ef0eabca33f39f572d6","unresolved":false,"context_lines":[{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"},{"line_number":219,"context_line":"        inst_uuids \u003d [instance.uuid for instance in instances]"}],"source_content_type":"text/x-python","patch_set":2,"id":"5f7c97a3_cfb933cc","line":216,"in_reply_to":"5f7c97a3_523d078d","updated":"2018-05-31 12:54:56.000000000","message":"\u003e Taking into account we could have a lot of instances,\n \u003e I believe it should be split by chunks.\n\nWe already have a max_count on the amount to be removed. Since we have to do this command per cell it needs to adopt the logic of (all inst_mappings in the cell - inst_mappings of existing instance records) which is the reason behind me not splitting it by chunks because we may/maynot have archived instances in the chunks and we just keep doing the same query in a splitted fashion upto the last chunk to get \"max_count/50\" number of records.,  but I get the point behind this query being heavy if there are a lot of instances in the cell, could you elaborate on what sized-chunks you would prefer this to be in and how you want this size to be decided because this would have to be hard-coded if I understand your point correctly?","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":21813,"name":"Andrey Volkov","email":"m@amadev.ru","username":"avolkov"},"change_message_id":"489f0d63033f6060e404fd79c4fc9b4971d9a7e2","unresolved":false,"context_lines":[{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"},{"line_number":219,"context_line":"        inst_uuids \u003d [instance.uuid for instance in instances]"}],"source_content_type":"text/x-python","patch_set":2,"id":"5f7c97a3_29fa0cbc","line":216,"in_reply_to":"5f7c97a3_cfb933cc","updated":"2018-06-01 13:39:14.000000000","message":"I see the following approach:\n\n1) get a bunch of InstanceMappings from current cell\n2) get a bunch of Instances corresponding those InstanceMappings\n3) determine what InstanceMappings don\u0027t have corresponding Instances.\n4) delete them\n\nrinse and repeat\n\nsame for BuildRequests","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":23630,"name":"Tovin Seven","email":"tovin07@gmail.com","username":"tovin07"},"change_message_id":"b7ccb0672541a0bd4a19d7191c06290405d583f2","unresolved":false,"context_lines":[{"line_number":245,"context_line":"@db_api.api_context_manager.writer"},{"line_number":246,"context_line":"def _destroy_bulk_in_db(context, instance_uuids):"},{"line_number":247,"context_line":"    res1 \u003d context.session.query(api_models.RequestSpec).filter("},{"line_number":248,"context_line":"        api_models.RequestSpec.instance_uuid.in_(instance_uuids)).\\"},{"line_number":249,"context_line":"        delete(synchronize_session\u003dFalse)"},{"line_number":250,"context_line":"    res2 \u003d context.session.query(api_models.InstanceMapping).filter("},{"line_number":251,"context_line":"        api_models.InstanceMapping.instance_uuid.in_(instance_uuids)).\\"}],"source_content_type":"text/x-python","patch_set":2,"id":"9f6a8fd7_987aacb7","line":248,"range":{"start_line":248,"start_character":66,"end_line":248,"end_character":67},"updated":"2018-04-24 09:03:00.000000000","message":"oh, you should wrap this with parentheses","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"00b625cdc3826f23d0bbd3edd73eb9308aaf071d","unresolved":false,"context_lines":[{"line_number":245,"context_line":"@db_api.api_context_manager.writer"},{"line_number":246,"context_line":"def _destroy_bulk_in_db(context, instance_uuids):"},{"line_number":247,"context_line":"    res1 \u003d context.session.query(api_models.RequestSpec).filter("},{"line_number":248,"context_line":"        api_models.RequestSpec.instance_uuid.in_(instance_uuids)).\\"},{"line_number":249,"context_line":"        delete(synchronize_session\u003dFalse)"},{"line_number":250,"context_line":"    res2 \u003d context.session.query(api_models.InstanceMapping).filter("},{"line_number":251,"context_line":"        api_models.InstanceMapping.instance_uuid.in_(instance_uuids)).\\"}],"source_content_type":"text/x-python","patch_set":2,"id":"9f6a8fd7_c797e147","line":248,"range":{"start_line":248,"start_character":66,"end_line":248,"end_character":67},"in_reply_to":"9f6a8fd7_987aacb7","updated":"2018-04-24 12:24:12.000000000","message":"ack","commit_id":"d4dd29e9203fdf74b387ffdd6273c83d33091892"},{"author":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"change_message_id":"52048d126b6886bf060471b36c20bc446b53a7fe","unresolved":false,"context_lines":[{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"},{"line_number":219,"context_line":"        inst_uuids \u003d [instance.uuid for instance in instances]"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f7c97a3_3f247e0c","line":216,"updated":"2018-06-01 15:28:19.000000000","message":"This is likely to be really huge, no? You\u0027d want to at least pass max_count here, but then you need some way to pick up where you left off last time.","commit_id":"e86a902c3276fb2d3e6ab9610b10e7dbaa31ae6b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"641197483bf8323fad6f16741e0bb24806aa30a2","unresolved":false,"context_lines":[{"line_number":213,"context_line":"def _get_uuids_of_orphaned_records(context, max_count):"},{"line_number":214,"context_line":"    \"\"\"Returns up to max_count orphaned archived instance uuids\"\"\""},{"line_number":215,"context_line":"    time \u003d timeutils.utcnow()"},{"line_number":216,"context_line":"    instances \u003d _get_all_instances_from_this_cell(context, time)"},{"line_number":217,"context_line":"    uuids_for_deletion \u003d []"},{"line_number":218,"context_line":"    if instances:"},{"line_number":219,"context_line":"        inst_uuids \u003d [instance.uuid for instance in instances]"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f7c97a3_2b16204b","line":216,"in_reply_to":"5f7c97a3_3f247e0c","updated":"2018-06-06 18:55:49.000000000","message":"Correct. The way Matt handles this in the heal_allocations work is to always use a sort key and pass a marker and limit. You can see how he\u0027s doing this here:\n\nhttps://review.openstack.org/#/c/565886/10/nova/cmd/manage.py\n\nNote on line 1770 he\u0027s passing in a limit for the InstanceList.get_by_filters() and then on line 1829-1832 he\u0027s passing in a marker value, which allows him to page through the instances in batches, which avoids the issue Dan is talking about here.","commit_id":"e86a902c3276fb2d3e6ab9610b10e7dbaa31ae6b"},{"author":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"change_message_id":"52048d126b6886bf060471b36c20bc446b53a7fe","unresolved":false,"context_lines":[{"line_number":219,"context_line":"        inst_uuids \u003d [instance.uuid for instance in instances]"},{"line_number":220,"context_line":"        inst_mapp \u003d (context.session.query(api_models.InstanceMapping)"},{"line_number":221,"context_line":"            .options(joinedload(\u0027cell_mapping\u0027))"},{"line_number":222,"context_line":"            .filter(api_models.InstanceMapping.instance_uuid.in_(inst_uuids))"},{"line_number":223,"context_line":"            .all())"},{"line_number":224,"context_line":"        cell_id \u003d inst_mapp[0].cell_mapping.id"},{"line_number":225,"context_line":"        inst_mapp_all \u003d (context.session.query(api_models.InstanceMapping)"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f7c97a3_bf7deee7","line":222,"updated":"2018-06-01 15:28:19.000000000","message":"I could be wrong, but I would think a single query that lists every instance uuid in the system would be very large and, while maybe not super complex, might run over some limits.","commit_id":"e86a902c3276fb2d3e6ab9610b10e7dbaa31ae6b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"641197483bf8323fad6f16741e0bb24806aa30a2","unresolved":false,"context_lines":[{"line_number":219,"context_line":"        inst_uuids \u003d [instance.uuid for instance in instances]"},{"line_number":220,"context_line":"        inst_mapp \u003d (context.session.query(api_models.InstanceMapping)"},{"line_number":221,"context_line":"            .options(joinedload(\u0027cell_mapping\u0027))"},{"line_number":222,"context_line":"            .filter(api_models.InstanceMapping.instance_uuid.in_(inst_uuids))"},{"line_number":223,"context_line":"            .all())"},{"line_number":224,"context_line":"        cell_id \u003d inst_mapp[0].cell_mapping.id"},{"line_number":225,"context_line":"        inst_mapp_all \u003d (context.session.query(api_models.InstanceMapping)"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f7c97a3_6b63b8de","line":222,"in_reply_to":"5f7c97a3_bf7deee7","updated":"2018-06-06 18:55:49.000000000","message":"Yeah, see above comment for how to handle this with a marker/limit paging/batching approach like Matt does in the heal_allocations work.","commit_id":"e86a902c3276fb2d3e6ab9610b10e7dbaa31ae6b"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"a3f916506989a768a591cc265baa76fa90ec6819","unresolved":false,"context_lines":[{"line_number":230,"context_line":"        uuids_for_deletion \u003d [mapp.instance_uuid for mapp in instance_mappings]"},{"line_number":231,"context_line":"        uuids_for_deletion \u003d uuids_for_deletion[:max_count]"},{"line_number":232,"context_line":"    else:"},{"line_number":233,"context_line":"        # if there are no instances the cell info is taken from config file."},{"line_number":234,"context_line":"        cell \u003d (context.session.query(api_models.CellMapping)"},{"line_number":235,"context_line":"            .filter_by(database_connection\u003dCONF.database.connection)).first()"},{"line_number":236,"context_line":"        inst_mapp_all \u003d (context.session.query(api_models.InstanceMapping)"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f7c97a3_b393ef4e","line":233,"updated":"2018-06-01 12:00:05.000000000","message":"or should I always just take the cell info from the config file since we have --config-file option ?","commit_id":"e86a902c3276fb2d3e6ab9610b10e7dbaa31ae6b"},{"author":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"change_message_id":"52048d126b6886bf060471b36c20bc446b53a7fe","unresolved":false,"context_lines":[{"line_number":230,"context_line":"        uuids_for_deletion \u003d [mapp.instance_uuid for mapp in instance_mappings]"},{"line_number":231,"context_line":"        uuids_for_deletion \u003d uuids_for_deletion[:max_count]"},{"line_number":232,"context_line":"    else:"},{"line_number":233,"context_line":"        # if there are no instances the cell info is taken from config file."},{"line_number":234,"context_line":"        cell \u003d (context.session.query(api_models.CellMapping)"},{"line_number":235,"context_line":"            .filter_by(database_connection\u003dCONF.database.connection)).first()"},{"line_number":236,"context_line":"        inst_mapp_all \u003d (context.session.query(api_models.InstanceMapping)"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f7c97a3_bf664e50","line":233,"in_reply_to":"5f7c97a3_b393ef4e","updated":"2018-06-01 15:28:19.000000000","message":"This would be weird.. I\u0027d just always take it from the config file.","commit_id":"e86a902c3276fb2d3e6ab9610b10e7dbaa31ae6b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"641197483bf8323fad6f16741e0bb24806aa30a2","unresolved":false,"context_lines":[{"line_number":230,"context_line":"        uuids_for_deletion \u003d [mapp.instance_uuid for mapp in instance_mappings]"},{"line_number":231,"context_line":"        uuids_for_deletion \u003d uuids_for_deletion[:max_count]"},{"line_number":232,"context_line":"    else:"},{"line_number":233,"context_line":"        # if there are no instances the cell info is taken from config file."},{"line_number":234,"context_line":"        cell \u003d (context.session.query(api_models.CellMapping)"},{"line_number":235,"context_line":"            .filter_by(database_connection\u003dCONF.database.connection)).first()"},{"line_number":236,"context_line":"        inst_mapp_all \u003d (context.session.query(api_models.InstanceMapping)"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f7c97a3_6ba898d8","line":233,"in_reply_to":"5f7c97a3_bf664e50","updated":"2018-06-06 18:55:49.000000000","message":"++","commit_id":"e86a902c3276fb2d3e6ab9610b10e7dbaa31ae6b"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"a0229930d986b4fd5a02be8ff8c08b8c035431c1","unresolved":false,"context_lines":[{"line_number":230,"context_line":"        uuids_for_deletion \u003d [mapp.instance_uuid for mapp in instance_mappings]"},{"line_number":231,"context_line":"        uuids_for_deletion \u003d uuids_for_deletion[:max_count]"},{"line_number":232,"context_line":"    else:"},{"line_number":233,"context_line":"        # if there are no instances the cell info is taken from config file."},{"line_number":234,"context_line":"        cell \u003d (context.session.query(api_models.CellMapping)"},{"line_number":235,"context_line":"            .filter_by(database_connection\u003dCONF.database.connection)).first()"},{"line_number":236,"context_line":"        inst_mapp_all \u003d (context.session.query(api_models.InstanceMapping)"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f7c97a3_7e92e0fe","line":233,"in_reply_to":"5f7c97a3_bf664e50","updated":"2018-06-04 08:40:45.000000000","message":"ack, will change this.","commit_id":"e86a902c3276fb2d3e6ab9610b10e7dbaa31ae6b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"ffd704724456aed6107ae5d5d0430a2781230ce3","unresolved":false,"context_lines":[{"line_number":295,"context_line":"    context.session.query(api_models.InstanceMapping).filter_by("},{"line_number":296,"context_line":"        project_id\u003dspecial_id).delete()"},{"line_number":297,"context_line":"    if im is not None:"},{"line_number":298,"context_line":"        db_mapping \u003d api_models.InstanceMapping()"},{"line_number":299,"context_line":"        db_mapping.update("},{"line_number":300,"context_line":"            {\u0027instance_uuid\u0027: im.cell_mapping.uuid,"},{"line_number":301,"context_line":"             \u0027project_id\u0027: special_id,"},{"line_number":302,"context_line":"             \u0027cell_id\u0027: im.cell_mapping.id,"},{"line_number":303,"context_line":"             \u0027user_id\u0027: im.id,"},{"line_number":304,"context_line":"             \u0027queued_for_delete\u0027: True,"},{"line_number":305,"context_line":"            })"},{"line_number":306,"context_line":"        db_mapping.save(context.session)"},{"line_number":307,"context_line":""},{"line_number":308,"context_line":""},{"line_number":309,"context_line":"@db_api.api_context_manager.reader"}],"source_content_type":"text/x-python","patch_set":5,"id":"5fc1f717_e8528167","line":306,"range":{"start_line":298,"start_character":0,"end_line":306,"end_character":40},"updated":"2019-03-07 14:24:54.000000000","message":"this doesn\u0027t make sense to me. This is going to create a new InstanceMapping record containing the user_id column set to the instance mapping\u0027s autoinc ID that you just deleted. I don\u0027t understand why that is being done?","commit_id":"041ceaf80166ce1772dcb96b0667135cf5ec7a48"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"624a7ee00e010d515994a76760615c4698b054a1","unresolved":false,"context_lines":[{"line_number":295,"context_line":"    context.session.query(api_models.InstanceMapping).filter_by("},{"line_number":296,"context_line":"        project_id\u003dspecial_id).delete()"},{"line_number":297,"context_line":"    if im is not None:"},{"line_number":298,"context_line":"        db_mapping \u003d api_models.InstanceMapping()"},{"line_number":299,"context_line":"        db_mapping.update("},{"line_number":300,"context_line":"            {\u0027instance_uuid\u0027: im.cell_mapping.uuid,"},{"line_number":301,"context_line":"             \u0027project_id\u0027: special_id,"},{"line_number":302,"context_line":"             \u0027cell_id\u0027: im.cell_mapping.id,"},{"line_number":303,"context_line":"             \u0027user_id\u0027: im.id,"},{"line_number":304,"context_line":"             \u0027queued_for_delete\u0027: True,"},{"line_number":305,"context_line":"            })"},{"line_number":306,"context_line":"        db_mapping.save(context.session)"},{"line_number":307,"context_line":""},{"line_number":308,"context_line":""},{"line_number":309,"context_line":"@db_api.api_context_manager.reader"}],"source_content_type":"text/x-python","patch_set":5,"id":"5fc1f717_2e74fe67","line":306,"range":{"start_line":298,"start_character":0,"end_line":306,"end_character":40},"in_reply_to":"5fc1f717_e8528167","updated":"2019-03-08 09:02:36.000000000","message":"\u003e this doesn\u0027t make sense to me. This is going to create a new\n \u003e InstanceMapping record containing the user_id column set to the\n \u003e instance mapping\u0027s autoinc ID that you just deleted.\n\nno no, this is going to create a new instance_mapping record with the user_id column set to the instance mapping\u0027s autoinc ID that was pulled last in L344 which is what is passed as the parameter im here.\n\n \u003e I don\u0027t\n \u003e understand why that is being done?\n\nI will add more comments to make it more clear.","commit_id":"041ceaf80166ce1772dcb96b0667135cf5ec7a48"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"ffd704724456aed6107ae5d5d0430a2781230ce3","unresolved":false,"context_lines":[{"line_number":332,"context_line":"            del cell_dict[key]"},{"line_number":333,"context_line":"    for cell in cell_dict.values():"},{"line_number":334,"context_line":"        query \u003d ("},{"line_number":335,"context_line":"            context.session.query(api_models.InstanceMapping)"},{"line_number":336,"context_line":"            .filter(api_models.InstanceMapping.cell_id \u003d\u003d cell.id))"},{"line_number":337,"context_line":"        if marker:"},{"line_number":338,"context_line":"            query \u003d ("}],"source_content_type":"text/x-python","patch_set":5,"id":"5fc1f717_88c97d79","line":335,"updated":"2019-03-07 14:24:54.000000000","message":"you\u0027re grabbing the entire instance_mappings record here, but only returning the uuid column. This would be more efficient to do:\n\n context.session.query(api_models.InstanceMapping.uuid)\n\nso you only return the single column you end up using below on line 345.","commit_id":"041ceaf80166ce1772dcb96b0667135cf5ec7a48"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"624a7ee00e010d515994a76760615c4698b054a1","unresolved":false,"context_lines":[{"line_number":332,"context_line":"            del cell_dict[key]"},{"line_number":333,"context_line":"    for cell in cell_dict.values():"},{"line_number":334,"context_line":"        query \u003d ("},{"line_number":335,"context_line":"            context.session.query(api_models.InstanceMapping)"},{"line_number":336,"context_line":"            .filter(api_models.InstanceMapping.cell_id \u003d\u003d cell.id))"},{"line_number":337,"context_line":"        if marker:"},{"line_number":338,"context_line":"            query \u003d ("}],"source_content_type":"text/x-python","patch_set":5,"id":"5fc1f717_8e5ad227","line":335,"in_reply_to":"5fc1f717_88c97d79","updated":"2019-03-08 09:02:36.000000000","message":"\u003e you\u0027re grabbing the entire instance_mappings record here, but only\n \u003e returning the uuid column. This would be more efficient to do:\n \u003e \n \u003e context.session.query(api_models.InstanceMapping.uuid)\n \u003e \n \u003e so you only return the single column you end up using below on line\n \u003e 345.\n\nah yea this is because I am using the information on the last InstanceMapping in the set like its cell_mapping and id info to make the marker that I fetch the whole thing. But you are right, I should only fetch the uuids of all the mappings and then I can just do the single query for the last uuid in the list to get the info needed for the marker.","commit_id":"041ceaf80166ce1772dcb96b0667135cf5ec7a48"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"ffd704724456aed6107ae5d5d0430a2781230ce3","unresolved":false,"context_lines":[{"line_number":336,"context_line":"            .filter(api_models.InstanceMapping.cell_id \u003d\u003d cell.id))"},{"line_number":337,"context_line":"        if marker:"},{"line_number":338,"context_line":"            query \u003d ("},{"line_number":339,"context_line":"                query.filter(api_models.InstanceMapping.id \u003e marker.user_id)"},{"line_number":340,"context_line":"                .filter(api_models.InstanceMapping.project_id !\u003d special_id))"},{"line_number":341,"context_line":"        query \u003d ("},{"line_number":342,"context_line":"            query.order_by(asc(api_models.InstanceMapping.id))"}],"source_content_type":"text/x-python","patch_set":5,"id":"5fc1f717_e87a8122","line":339,"range":{"start_line":339,"start_character":56,"end_line":339,"end_character":76},"updated":"2019-03-07 14:24:54.000000000","message":"this is incorrect, AFAICT. You need to be comparing to marker.id, not marker.user_id","commit_id":"041ceaf80166ce1772dcb96b0667135cf5ec7a48"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"624a7ee00e010d515994a76760615c4698b054a1","unresolved":false,"context_lines":[{"line_number":336,"context_line":"            .filter(api_models.InstanceMapping.cell_id \u003d\u003d cell.id))"},{"line_number":337,"context_line":"        if marker:"},{"line_number":338,"context_line":"            query \u003d ("},{"line_number":339,"context_line":"                query.filter(api_models.InstanceMapping.id \u003e marker.user_id)"},{"line_number":340,"context_line":"                .filter(api_models.InstanceMapping.project_id !\u003d special_id))"},{"line_number":341,"context_line":"        query \u003d ("},{"line_number":342,"context_line":"            query.order_by(asc(api_models.InstanceMapping.id))"}],"source_content_type":"text/x-python","patch_set":5,"id":"5fc1f717_6e2206a7","line":339,"range":{"start_line":339,"start_character":56,"end_line":339,"end_character":76},"in_reply_to":"5fc1f717_e87a8122","updated":"2019-03-08 09:02:36.000000000","message":"\u003e this is incorrect, AFAICT. You need to be comparing to marker.id,\n \u003e not marker.user_id\n\nThis is because I am feeding the id of the lasted visited instance_mapping to the user_id of the marker to pick it up. So I need to make the comparison with the user_id.","commit_id":"041ceaf80166ce1772dcb96b0667135cf5ec7a48"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"ffd704724456aed6107ae5d5d0430a2781230ce3","unresolved":false,"context_lines":[{"line_number":343,"context_line":"            .limit(max_count))"},{"line_number":344,"context_line":"        ims \u003d query.all()"},{"line_number":345,"context_line":"        ims_uuids \u003d [im.instance_uuid for im in ims]"},{"line_number":346,"context_line":"        if not ims and cell.id !\u003d cell_dict.values()[-1].id:"},{"line_number":347,"context_line":"            marker.update({\u0027user_id\u0027: 0})"},{"line_number":348,"context_line":"            marker.save(context.session)"},{"line_number":349,"context_line":"            continue"}],"source_content_type":"text/x-python","patch_set":5,"id":"5fc1f717_88dadd14","line":346,"updated":"2019-03-07 14:24:54.000000000","message":"a comment above this conditional would be useful.","commit_id":"041ceaf80166ce1772dcb96b0667135cf5ec7a48"},{"author":{"_account_id":26936,"name":"Surya Seetharaman","email":"suryaseetharaman.9@gmail.com","username":"tssurya"},"change_message_id":"624a7ee00e010d515994a76760615c4698b054a1","unresolved":false,"context_lines":[{"line_number":343,"context_line":"            .limit(max_count))"},{"line_number":344,"context_line":"        ims \u003d query.all()"},{"line_number":345,"context_line":"        ims_uuids \u003d [im.instance_uuid for im in ims]"},{"line_number":346,"context_line":"        if not ims and cell.id !\u003d cell_dict.values()[-1].id:"},{"line_number":347,"context_line":"            marker.update({\u0027user_id\u0027: 0})"},{"line_number":348,"context_line":"            marker.save(context.session)"},{"line_number":349,"context_line":"            continue"}],"source_content_type":"text/x-python","patch_set":5,"id":"5fc1f717_ee3596db","line":346,"in_reply_to":"5fc1f717_88dadd14","updated":"2019-03-08 09:02:36.000000000","message":"yea, sorry will add a comment to this.","commit_id":"041ceaf80166ce1772dcb96b0667135cf5ec7a48"}]}
