)]}'
{"cinder/volume/targets/tgt.py":[{"author":{"_account_id":2243,"name":"John Griffith","email":"john.griffith8@gmail.com","username":"john-griffith"},"change_message_id":"7bd3989b912d476d9f5ce7e51007edbe69f7846d","unresolved":false,"context_lines":[{"line_number":195,"context_line":"        if os.path.exists(volume_path):"},{"line_number":196,"context_line":"            LOG.warning(_LW(\u0027Persistence file already exists for volume, \u0027"},{"line_number":197,"context_line":"                            \u0027found file at: %s\u0027), volume_path)"},{"line_number":198,"context_line":""},{"line_number":199,"context_line":"        dirfd \u003d None"},{"line_number":200,"context_line":"        try:"},{"line_number":201,"context_line":"            dirfd \u003d os.open(volumes_dir, os.O_DIRECTORY)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a1a9d01_3af92781","line":198,"updated":"2015-09-25 16:49:38.000000000","message":"Hey Chris,\n\nThanks for working on this, I\u0027m curious about the need for a tempfile and the directory ops here.  Is it not sufficient to just do:\n    f \u003d os.open(volume_path, os.O_RDWR|os.O_CREAT)\n    os.write(f, volume_conf)\n    os.fsync(f)\n    os.close(f)","commit_id":"0bca2756ef4cdc09ba835938b93bad4bbe495c6a"},{"author":{"_account_id":8768,"name":"Chris Friesen","email":"chris.friesen@windriver.com","username":"cbf123"},"change_message_id":"5dad1f10900792c816eeb5f9a5f815f765a7cd71","unresolved":false,"context_lines":[{"line_number":195,"context_line":"        if os.path.exists(volume_path):"},{"line_number":196,"context_line":"            LOG.warning(_LW(\u0027Persistence file already exists for volume, \u0027"},{"line_number":197,"context_line":"                            \u0027found file at: %s\u0027), volume_path)"},{"line_number":198,"context_line":""},{"line_number":199,"context_line":"        dirfd \u003d None"},{"line_number":200,"context_line":"        try:"},{"line_number":201,"context_line":"            dirfd \u003d os.open(volumes_dir, os.O_DIRECTORY)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a1a9d01_4e3d402a","line":198,"in_reply_to":"9a1a9d01_3af92781","updated":"2015-09-25 17:17:09.000000000","message":"There are a few problems with that.  If the process dies or the system loses power you could end up with any of the following depending on details of timing and filesystem and underlying storage.\n 1) No file.\n 2) An empty file of size zero.\n 3) A a file of the expected size containing gibberish.\n 4) A well-formed file.\n\nSo, the code below takes as many precautions as possible:\n 1) Write to a temp file to avoid partial writes to the \"real\" file.\n 2) Flush the python buffers to ensure the OS sees all the data.\n 3) Call os.fdatasync() to force the temp file data to persistent storage.\n 4) Call os.fsync() on the directory to ensure that the existence of the temp file gets to persistent storage.\n 5) Call os.rename() (which is atomic but not necessarily persistent).\n 6) Call os.fsync() on the directory again to ensure that the rename operation gets to persistent storage.","commit_id":"0bca2756ef4cdc09ba835938b93bad4bbe495c6a"},{"author":{"_account_id":2243,"name":"John Griffith","email":"john.griffith8@gmail.com","username":"john-griffith"},"change_message_id":"bf64a2f4750100655a58a11de391e392e4df98f2","unresolved":false,"context_lines":[{"line_number":196,"context_line":"            LOG.warning(_LW(\u0027Persistence file already exists for volume, \u0027"},{"line_number":197,"context_line":"                            \u0027found file at: %s\u0027), volume_path)"},{"line_number":198,"context_line":""},{"line_number":199,"context_line":"        dirfd \u003d None"},{"line_number":200,"context_line":"        try:"},{"line_number":201,"context_line":"            dirfd \u003d os.open(volumes_dir, os.O_DIRECTORY)"},{"line_number":202,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"9a1a9d01_d1525113","line":199,"updated":"2015-09-25 17:18:30.000000000","message":"thanks for the explanation, I think it\u0027s overkill but I\u0027ll let others weigh in here.  If there is a power hit or something at the split second that we\u0027re trying to flush and close the file, the fact is you can always detach/reattach.  Besides, you\u0027re likely to have bigger problems if that happens :(","commit_id":"c04e4a3c5264f8f1bec9be209dea762645fc96f6"},{"author":{"_account_id":8768,"name":"Chris Friesen","email":"chris.friesen@windriver.com","username":"cbf123"},"change_message_id":"d35e1d68227a9c7122c71168bae8ebfa61688452","unresolved":false,"context_lines":[{"line_number":196,"context_line":"            LOG.warning(_LW(\u0027Persistence file already exists for volume, \u0027"},{"line_number":197,"context_line":"                            \u0027found file at: %s\u0027), volume_path)"},{"line_number":198,"context_line":""},{"line_number":199,"context_line":"        dirfd \u003d None"},{"line_number":200,"context_line":"        try:"},{"line_number":201,"context_line":"            dirfd \u003d os.open(volumes_dir, os.O_DIRECTORY)"},{"line_number":202,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"9a1a9d01_31270d14","line":199,"in_reply_to":"9a1a9d01_d1525113","updated":"2015-09-25 17:33:14.000000000","message":"We ran into this problem originally due to cinder-volume receiving a SIGTERM right after doing the open() call, which resulted in an empty file.  In that case the current codebase will rebuild the file but the rebuilt file will have no CHAP information in it.\n\nDetach/reattach is an issue when you\u0027ve got a running boot-from-volume instance. I think you\u0027d end up having to destroy the instance.\n\nI think either we should try to ensure that we never have an empty file, or else we should fix the issue around including CHAP information in the rebuilt file.  (Or both.)","commit_id":"c04e4a3c5264f8f1bec9be209dea762645fc96f6"},{"author":{"_account_id":10115,"name":"Mitsuhiro Tanino","email":"mitsuhiro.tanino@lycorp.co.jp","username":"mtanino"},"change_message_id":"0883aa92483e8c8ea2a0759279cf89dcc5ecc1b3","unresolved":false,"context_lines":[{"line_number":224,"context_line":"        finally:"},{"line_number":225,"context_line":"            if dirfd:"},{"line_number":226,"context_line":"                os.close(dirfd)"},{"line_number":227,"context_line":""},{"line_number":228,"context_line":"        LOG.debug((\u0027Created volume path %(vp)s,\\n\u0027"},{"line_number":229,"context_line":"                   \u0027content: %(vc)s\u0027),"},{"line_number":230,"context_line":"                  {\u0027vp\u0027: volume_path, \u0027vc\u0027: volume_conf})"}],"source_content_type":"text/x-python","patch_set":3,"id":"9a1a9d01_5d83b0cc","line":227,"updated":"2015-09-25 19:27:37.000000000","message":"I think iet and cxt also might be met same problem.\n\nI recommend this function is implemented as an common function which iet and cxt can be used in the future.","commit_id":"3ace3d0e72bd5c17cb83ec360faf4debac3cffa7"},{"author":{"_account_id":17405,"name":"Jacob Gregor","email":"jgregor@us.ibm.com","username":"jgregor"},"change_message_id":"cdff26a18cef90cbee252debacbd4fdf8400306c","unresolved":false,"context_lines":[{"line_number":198,"context_line":""},{"line_number":199,"context_line":"        tempname \u003d None"},{"line_number":200,"context_line":"        dirfd \u003d None"},{"line_number":201,"context_line":"        try:"},{"line_number":202,"context_line":"            dirfd \u003d os.open(volumes_dir, os.O_DIRECTORY)"},{"line_number":203,"context_line":""},{"line_number":204,"context_line":"            # write data to temporary file"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a1a9d01_bf78bf2c","line":201,"updated":"2015-09-25 21:03:58.000000000","message":"We will need unit tests here to test out the new branches.","commit_id":"7cf8e31f9d177d8b4d7e68a3769709bf6986a9fa"},{"author":{"_account_id":8912,"name":"Ryan McNair","email":"rdmcnair@us.ibm.com","username":"rdmcnair"},"change_message_id":"d5bd1231a74728a4f26b4c5a72108ff0e0f49bbe","unresolved":false,"context_lines":[{"line_number":200,"context_line":"        dirfd \u003d None"},{"line_number":201,"context_line":"        try:"},{"line_number":202,"context_line":"            dirfd \u003d os.open(volumes_dir, os.O_DIRECTORY)"},{"line_number":203,"context_line":""},{"line_number":204,"context_line":"            # write data to temporary file"},{"line_number":205,"context_line":"            with tempfile.NamedTemporaryFile(prefix\u003dvol_id,"},{"line_number":206,"context_line":"                                             dir\u003dvolumes_dir,"}],"source_content_type":"text/x-python","patch_set":4,"id":"3a29b11f_10be8eff","line":203,"updated":"2015-10-26 14:49:33.000000000","message":"Any reason Mitsuhiro comments haven\u0027t been addressed here?  They suggest making this function common so it can be used by other code areas in the future, which seems like a good idea.","commit_id":"7cf8e31f9d177d8b4d7e68a3769709bf6986a9fa"},{"author":{"_account_id":8768,"name":"Chris Friesen","email":"chris.friesen@windriver.com","username":"cbf123"},"change_message_id":"95760e188abed25aff23203002fa301d52fd7021","unresolved":false,"context_lines":[{"line_number":200,"context_line":"        dirfd \u003d None"},{"line_number":201,"context_line":"        try:"},{"line_number":202,"context_line":"            dirfd \u003d os.open(volumes_dir, os.O_DIRECTORY)"},{"line_number":203,"context_line":""},{"line_number":204,"context_line":"            # write data to temporary file"},{"line_number":205,"context_line":"            with tempfile.NamedTemporaryFile(prefix\u003dvol_id,"},{"line_number":206,"context_line":"                                             dir\u003dvolumes_dir,"}],"source_content_type":"text/x-python","patch_set":4,"id":"3a29b11f_7e11d35c","line":203,"in_reply_to":"3a29b11f_10be8eff","updated":"2015-10-26 16:09:36.000000000","message":"Lack of time, basically.  If anyone wants to take this and run with it, please do so.  I think the recovery from the buggy situation is much better now, so this has dropped on my priority list.","commit_id":"7cf8e31f9d177d8b4d7e68a3769709bf6986a9fa"}]}
