)]}'
{"cinder/volume/api.py":[{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"fca483ef67fd9e87127e52e77c711eedb86bffef","unresolved":false,"context_lines":[{"line_number":132,"context_line":"                           % locals())"},{"line_number":133,"context_line":"                raise exception.VolumeLimitExceeded(allowed\u003dquotas[\u0027volumes\u0027])"},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"        if image_id:"},{"line_number":136,"context_line":"            # check image existence"},{"line_number":137,"context_line":"            image_meta \u003d self.image_service.show(context, image_id)"},{"line_number":138,"context_line":"            image_size_in_gb \u003d (int(image_meta[\u0027size\u0027]) + GB - 1) / GB"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAALn%2F%2F%2B2Q%3D","side":"PARENT","line":135,"updated":"2012-10-23 16:15:38.000000000","message":"So this is the obvious part that can raise, why not just do it above the QUOTA.reserve closer to the other InvalidInput exception?\n\nI think there\u0027s a larger problem of missing a rollback on general exceptions, but a) that\u0027s not really addressed in this patch (decorator?  reservation_id\u0027s attached to the request object and passed up to a higher level request error handler?) and b) the whole reserve/commit pattern is supposed to support a rollback missed here and there, can we tweak the timeout on uncommitted reservations?  How often do we reserve in the api and commit on the other side of a manager action?","commit_id":"c24a82a54e1a4be6d1e6f333763f15b435561573"},{"author":{"_account_id":2759,"name":"Huang Zhiteng","email":"winston.d@gmail.com","username":"zhiteng-huang"},"change_message_id":"be7aa6cff705fb9b5b2c9e03c5a988598eac06bc","unresolved":false,"context_lines":[{"line_number":132,"context_line":"                           % locals())"},{"line_number":133,"context_line":"                raise exception.VolumeLimitExceeded(allowed\u003dquotas[\u0027volumes\u0027])"},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"        if image_id:"},{"line_number":136,"context_line":"            # check image existence"},{"line_number":137,"context_line":"            image_meta \u003d self.image_service.show(context, image_id)"},{"line_number":138,"context_line":"            image_size_in_gb \u003d (int(image_meta[\u0027size\u0027]) + GB - 1) / GB"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAALn%2F%2F%2BDU%3D","side":"PARENT","line":135,"in_reply_to":"AAAALn%2F%2F%2B2Q%3D","updated":"2012-10-24 05:43:04.000000000","message":"I agree with clayg, validate if vol_size \u003e\u003d image_size should be done before QUOTA.reserve to check for invalid input.","commit_id":"c24a82a54e1a4be6d1e6f333763f15b435561573"},{"author":{"_account_id":2481,"name":"Rongze Zhu","email":"zrzhit@gmail.com","username":"zrzhit"},"change_message_id":"80a7840cd64799ce3982969d67abc4b2eae5260c","unresolved":false,"context_lines":[{"line_number":132,"context_line":"                           % locals())"},{"line_number":133,"context_line":"                raise exception.VolumeLimitExceeded(allowed\u003dquotas[\u0027volumes\u0027])"},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"        if image_id:"},{"line_number":136,"context_line":"            # check image existence"},{"line_number":137,"context_line":"            image_meta \u003d self.image_service.show(context, image_id)"},{"line_number":138,"context_line":"            image_size_in_gb \u003d (int(image_meta[\u0027size\u0027]) + GB - 1) / GB"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAALn%2F%2F91c%3D","side":"PARENT","line":135,"in_reply_to":"AAAALn%2F%2F%2B2Q%3D","updated":"2012-10-24 14:06:12.000000000","message":"There is not one action that we reserve in the api and commit on the other side of a manager in cinder. After I read reserve/commit code in cinder, I think if we use a) or b),  the problem can be made more complex by the introduction of new issues.... I agree that  we should strive for the pattern of calling reserve and commit as close together as possible.","commit_id":"c24a82a54e1a4be6d1e6f333763f15b435561573"},{"author":{"_account_id":2759,"name":"Huang Zhiteng","email":"winston.d@gmail.com","username":"zhiteng-huang"},"change_message_id":"be7aa6cff705fb9b5b2c9e03c5a988598eac06bc","unresolved":false,"context_lines":[{"line_number":144,"context_line":"                if image_size_in_gb \u003e size:"},{"line_number":145,"context_line":"                    msg \u003d _(\u0027Size of specified image is larger than \u0027"},{"line_number":146,"context_line":"                            \u0027volume size.\u0027)"},{"line_number":147,"context_line":"                    raise exception.InvalidInput(reason\u003dmsg)"},{"line_number":148,"context_line":""},{"line_number":149,"context_line":"            if availability_zone is None:"},{"line_number":150,"context_line":"                availability_zone \u003d FLAGS.storage_availability_zone"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAALn%2F%2F%2BDQ%3D","line":147,"updated":"2012-10-24 05:43:04.000000000","message":"Even reserving quota has been done before checking image size, I think it\u0027d better catch exception here rather than a big loop in \u0027try\u0027.","commit_id":"dba2b3b18901fbf9a162de8b9c22c146ba7553e0"},{"author":{"_account_id":67,"name":"Vish Ishaya","email":"vishvananda@gmail.com","username":"vishvananda"},"change_message_id":"9835815984e3c215819430c5558558bc2abb009c","unresolved":false,"context_lines":[{"line_number":172,"context_line":"            completed \u003d True"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"         # If we didn\u0027t complete the creation, roll back."},{"line_number":175,"context_line":"        finally:"},{"line_number":176,"context_line":"            if completed \u003d\u003d False:"},{"line_number":177,"context_line":"                QUOTAS.rollback(context, reservations)"},{"line_number":178,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAALn%2F%2F%2BsA%3D","line":175,"updated":"2012-10-23 17:29:45.000000000","message":"why not forget the boolean flag and use:\nexcept Exception:\n  with excutils.save_and_reraise_exception():\n    QUOTAS.rollback(context, reservations)","commit_id":"dba2b3b18901fbf9a162de8b9c22c146ba7553e0"},{"author":{"_account_id":2759,"name":"Huang Zhiteng","email":"winston.d@gmail.com","username":"zhiteng-huang"},"change_message_id":"afeef601b048e7d88cf1d6c971fe808065a0e31a","unresolved":false,"context_lines":[{"line_number":168,"context_line":"        try:"},{"line_number":169,"context_line":"            volume \u003d self.db.volume_create(context, options)"},{"line_number":170,"context_line":"            QUOTAS.commit(context, reservations)"},{"line_number":171,"context_line":"        except Exception:"},{"line_number":172,"context_line":"            with excutils.save_and_reraise_exception():"},{"line_number":173,"context_line":"                QUOTAS.rollback(context, reservations)"},{"line_number":174,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAALn%2F%2F8%2FU%3D","line":171,"updated":"2012-10-25 01:14:48.000000000","message":"If exception raised after db.volume_create is done (which means QUOTAS.commit failed), you have to clean up db record as well if QUOTAS.rollback is what you want to do.  \nOr, if QUOTAS.commit failed, try commit again?  otherwise, volume db record is there, which means end user can see it and act on it. if end user tried to delete that volume, one QUOTAS.commit(-1) will happen to reclaim allocated quota, which unfortunately wasn\u0027t allocated successfully.  So my suggestion is:\n\ntry:\n    vol \u003d db.create_volume()\nexcept Exception:\n    QUOTAS.rollback()\n    raise db-create-record-failure\n\nif vol is not None:\n    QUOTAS.commit()","commit_id":"46b3a950bd7a5c356132f6f19a662d956e7aa384"},{"author":{"_account_id":2481,"name":"Rongze Zhu","email":"zrzhit@gmail.com","username":"zrzhit"},"change_message_id":"27f09303a066d2ea3f120d1cb3694fa963ced8ff","unresolved":false,"context_lines":[{"line_number":168,"context_line":"        try:"},{"line_number":169,"context_line":"            volume \u003d self.db.volume_create(context, options)"},{"line_number":170,"context_line":"            QUOTAS.commit(context, reservations)"},{"line_number":171,"context_line":"        except Exception:"},{"line_number":172,"context_line":"            with excutils.save_and_reraise_exception():"},{"line_number":173,"context_line":"                QUOTAS.rollback(context, reservations)"},{"line_number":174,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAALn%2F%2F81s%3D","line":171,"in_reply_to":"AAAALn%2F%2F8%2FU%3D","updated":"2012-10-25 08:10:14.000000000","message":"Hi Zhiteng, thanks your help, but I think there is a issuse in your suggestion.\nif QUOTAS.commit() failed in your suggestion, it also lead to quota leaks...\nI think above code will address it:\n\ntry:\n\tvol \u003d db.create_volume()\n\tQUOTAS.commit()\nexcept Exception:\n\twith excutils.save_and_reraise_exception():\n\t\ttry:\n\t\t\tself.db.volume_destroy(context, vol[\u0027id\u0027])\n\t\tfinally:\n\t\t\tQUOTAS.rollback()","commit_id":"46b3a950bd7a5c356132f6f19a662d956e7aa384"},{"author":{"_account_id":2759,"name":"Huang Zhiteng","email":"winston.d@gmail.com","username":"zhiteng-huang"},"change_message_id":"120300e286d2824cb9ff69c5af5191bff9a46bbd","unresolved":false,"context_lines":[{"line_number":171,"context_line":"        except Exception:"},{"line_number":172,"context_line":"            with excutils.save_and_reraise_exception():"},{"line_number":173,"context_line":"                QUOTAS.rollback(context, reservations)"},{"line_number":174,"context_line":""},{"line_number":175,"context_line":"        self._cast_create_volume(context, volume[\u0027id\u0027], snapshot_id,"},{"line_number":176,"context_line":"                                 image_id)"},{"line_number":177,"context_line":"        return volume"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAALn%2F%2F9lk%3D","line":174,"updated":"2012-10-24 17:49:10.000000000","message":"Is this try/except really necessary here? db.volume_create isn\u0027t going to throw exception, nor does QUOTAS.commit.","commit_id":"46b3a950bd7a5c356132f6f19a662d956e7aa384"},{"author":{"_account_id":170,"name":"Mike Perez","email":"thingee@gmail.com","username":"thingee"},"change_message_id":"6f336298087e5814d1e025e67de78f02607a704a","unresolved":false,"context_lines":[{"line_number":171,"context_line":"        except Exception:"},{"line_number":172,"context_line":"            with excutils.save_and_reraise_exception():"},{"line_number":173,"context_line":"                QUOTAS.rollback(context, reservations)"},{"line_number":174,"context_line":""},{"line_number":175,"context_line":"        self._cast_create_volume(context, volume[\u0027id\u0027], snapshot_id,"},{"line_number":176,"context_line":"                                 image_id)"},{"line_number":177,"context_line":"        return volume"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAALn%2F%2F9i4%3D","line":174,"in_reply_to":"AAAALn%2F%2F9lk%3D","updated":"2012-10-24 18:05:09.000000000","message":"To help with this, it might be good to have some unit tests for this behavior with volume create now.","commit_id":"46b3a950bd7a5c356132f6f19a662d956e7aa384"}]}
