{"action":"created","issue":{"url":"https://api.github.com/repos/habitat-sh/habitat/issues/1446","repository_url":"https://api.github.com/repos/habitat-sh/habitat","labels_url":"https://api.github.com/repos/habitat-sh/habitat/issues/1446/labels{/name}","comments_url":"https://api.github.com/repos/habitat-sh/habitat/issues/1446/comments","events_url":"https://api.github.com/repos/habitat-sh/habitat/issues/1446/events","html_url":"https://github.com/habitat-sh/habitat/pull/1446","id":186945391,"number":1446,"title":"Retry network operations if they fail","user":{"login":"raskchanky","id":947,"avatar_url":"https://avatars.githubusercontent.com/u/947?v=3","gravatar_id":"","url":"https://api.github.com/users/raskchanky","html_url":"https://github.com/raskchanky","followers_url":"https://api.github.com/users/raskchanky/followers","following_url":"https://api.github.com/users/raskchanky/following{/other_user}","gists_url":"https://api.github.com/users/raskchanky/gists{/gist_id}","starred_url":"https://api.github.com/users/raskchanky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raskchanky/subscriptions","organizations_url":"https://api.github.com/users/raskchanky/orgs","repos_url":"https://api.github.com/users/raskchanky/repos","events_url":"https://api.github.com/users/raskchanky/events{/privacy}","received_events_url":"https://api.github.com/users/raskchanky/received_events","type":"User","site_admin":false},"labels":[{"id":390274553,"url":"https://api.github.com/repos/habitat-sh/habitat/labels/Feature","name":"Feature","color":"1d76db","default":false},{"id":397549797,"url":"https://api.github.com/repos/habitat-sh/habitat/labels/In%20Progress","name":"In Progress","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-02T23:18:34Z","updated_at":"2016-11-14T21:29:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/habitat-sh/habitat/pulls/1446","html_url":"https://github.com/habitat-sh/habitat/pull/1446","diff_url":"https://github.com/habitat-sh/habitat/pull/1446.diff","patch_url":"https://github.com/habitat-sh/habitat/pull/1446.patch"},"body":"This sets a read/write timeout on the HTTP client that hab uses and then leverages the retry crate to retry network operations 5 times, waiting 3 seconds between each try.  I tried my best to encapsulate enough logic in the retryable closure that the user could tell from the UI that hab was retrying things.\r\n\r\nIt's worth noting that I initially tried to make this change in the HTTP client itself, thinking that since all of the hab network operations ended up in that place, it made sense to implement the retry logic there, rather than have it spread throughout the codebase in all the various commands.  That didn't work out because by the time the actual transferring of bytes over the network happened, hyper had already returned a response and was out of the picture.  From hyper's point of view, everything succeeded, regardless of whether the network connection was interrupted in mid upload/download.\r\n\r\nAlso note that in the most recent version of hyper, you cannot control the connection timeout.  This means that the current flow of things looks like this:\r\n\r\n* `hab pkg download core/foo`\r\n* <Download begins and is interrupted a second later>\r\n* <5 second read timeout expires>\r\n* <hab tries to establish a new connection to download the package again>\r\n* <a long wait happens here as hyper's connection timeout is not configurable>\r\n\r\nI notice that the connection timeout _is_ configurable in the hyper master branch but not in the latest stable release.\r\n\r\nThese changes work, but on the whole, it feels less elegant than I would've liked, so I'm definitely open to suggestions on better ways to do this.\r\n\r\n![gif-keyboard-14918230011999129624](https://cloud.githubusercontent.com/assets/947/19950909/ded2c11e-a117-11e6-99ce-5caba8fb23e0.gif)\r\n"},"comment":{"url":"https://api.github.com/repos/habitat-sh/habitat/issues/comments/260468536","html_url":"https://github.com/habitat-sh/habitat/pull/1446#issuecomment-260468536","issue_url":"https://api.github.com/repos/habitat-sh/habitat/issues/1446","id":260468536,"user":{"login":"reset","id":54036,"avatar_url":"https://avatars.githubusercontent.com/u/54036?v=3","gravatar_id":"","url":"https://api.github.com/users/reset","html_url":"https://github.com/reset","followers_url":"https://api.github.com/users/reset/followers","following_url":"https://api.github.com/users/reset/following{/other_user}","gists_url":"https://api.github.com/users/reset/gists{/gist_id}","starred_url":"https://api.github.com/users/reset/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reset/subscriptions","organizations_url":"https://api.github.com/users/reset/orgs","repos_url":"https://api.github.com/users/reset/repos","events_url":"https://api.github.com/users/reset/events{/privacy}","received_events_url":"https://api.github.com/users/reset/received_events","type":"User","site_admin":false},"created_at":"2016-11-14T21:29:33Z","updated_at":"2016-11-14T21:29:33Z","body":"@raskchanky I think this is perfectly fine but the formatting makes things pretty difficult to read. A lot of the code in the command modules is already in a spot like this so let's just merge this in and get things refactored later on, good work!\r\n\r\n@thesentinels approve"}}
{"actor":{"display_login":"reset"}}