)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":14525,"name":"Vasyl Saienko","email":"vsaienko@mirantis.com","username":"vsaienko"},"change_message_id":"154117c4d86c869aedf72a2f892160ad404811ce","unresolved":false,"context_lines":[{"line_number":15,"context_line":"Wait for a non-503 HTTP response code and non-7 exit code"},{"line_number":16,"context_line":"(connection error) from curl"},{"line_number":17,"context_line":""},{"line_number":18,"context_line":"The \\EOF form is used so the heredoc isn\u0027t evaulated before"},{"line_number":19,"context_line":"the call is made. Otherwise it would be evaluated just once"},{"line_number":20,"context_line":"so the loop is not valuable."},{"line_number":21,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"9abb7d3a_05078bca","line":18,"range":{"start_line":18,"start_character":43,"end_line":18,"end_character":53},"updated":"2016-06-01 08:19:50.000000000","message":"s/evaulated/evaluated","commit_id":"bf6ba5dc6601bbd093f15221683e8f8ded21660a"},{"author":{"_account_id":14525,"name":"Vasyl Saienko","email":"vsaienko@mirantis.com","username":"vsaienko"},"change_message_id":"154117c4d86c869aedf72a2f892160ad404811ce","unresolved":false,"context_lines":[{"line_number":20,"context_line":"so the loop is not valuable."},{"line_number":21,"context_line":""},{"line_number":22,"context_line":"Variables needed to be exported in order to be available when"},{"line_number":23,"context_line":"thsi form is used."},{"line_number":24,"context_line":""},{"line_number":25,"context_line":"Change-Id: I059a12b1b920f703f28aca0e2f352714118dee97"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"9abb7d3a_a5fe7fab","line":23,"range":{"start_line":23,"start_character":0,"end_line":23,"end_character":4},"updated":"2016-06-01 08:19:50.000000000","message":"s/thsi/this","commit_id":"bf6ba5dc6601bbd093f15221683e8f8ded21660a"}],"functions":[{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"65915b6d9c5491c08a2111e3ad653cd58c084890","unresolved":false,"context_lines":[{"line_number":396,"context_line":"    rval\u003d1"},{"line_number":397,"context_line":"    while true ; do"},{"line_number":398,"context_line":"        # Calculate how much time is left"},{"line_number":399,"context_line":"        elapsed\u003d$(time_elapsed \"wait_for_service\")"},{"line_number":400,"context_line":"        timeleft\u003d$(($timeout - $elapsed))"},{"line_number":401,"context_line":"        output\u003d`timeout $timeleft sh -c \"$CURL_GET -s -kv --noproxy \u0027*\u0027 $url 2\u003e\u00261\" | grep \u0027^\u003c HTTP/1\u0027 | cut -d\u0027 \u0027 -f3`"},{"line_number":402,"context_line":"        # strip off trailing whitespace"}],"source_content_type":"application/x-shellscript","patch_set":1,"id":"bab6814e_7dcc60bb","line":399,"updated":"2016-05-26 00:46:48.000000000","message":"I would prefer to see this just done with a local value and \"date\" calls because we know that \"time_start\" is not re-entrant ... which for the most part is a minor annoyance because you might get bad results in the final table.\n\nBut here, if some plugin decides to nest these calls it would result in bad behaviour.  So I think it\u0027s better to be defensive in this regard.","commit_id":"0d939e0c4e60dd51749346333db7fd90e691eada"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"65915b6d9c5491c08a2111e3ad653cd58c084890","unresolved":false,"context_lines":[{"line_number":400,"context_line":"        timeleft\u003d$(($timeout - $elapsed))"},{"line_number":401,"context_line":"        output\u003d`timeout $timeleft sh -c \"$CURL_GET -s -kv --noproxy \u0027*\u0027 $url 2\u003e\u00261\" | grep \u0027^\u003c HTTP/1\u0027 | cut -d\u0027 \u0027 -f3`"},{"line_number":402,"context_line":"        # strip off trailing whitespace"},{"line_number":403,"context_line":"        output\u003d`echo $output | tr -d \u0027\\n\u0027`"},{"line_number":404,"context_line":"        if [ \"$output\" !\u003d \"503\" ]; then"},{"line_number":405,"context_line":"            rval\u003d0"},{"line_number":406,"context_line":"            break"}],"source_content_type":"application/x-shellscript","patch_set":1,"id":"bab6814e_1de55437","line":403,"updated":"2016-05-26 00:46:48.000000000","message":"I\u0027m just going from stackoverflow here, but the top-rated answer there looks much simpler (especially to read)\n\n curl -s -o /dev/null -w \"%{http_code}\" http://www.example.org/\n\nwhich should just print the return code?","commit_id":"0d939e0c4e60dd51749346333db7fd90e691eada"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"3e4bf9700c90355311a3c1758d72c8d2d2080f88","unresolved":false,"context_lines":[{"line_number":386,"context_line":"    local url\u003d$2"},{"line_number":387,"context_line":"    local ok_codes\u003d\"200 300 401\""},{"line_number":388,"context_line":"    time_start \"wait_for_service\""},{"line_number":389,"context_line":"    timeout $timeout sh -c \"while [[ $(${CURL_GET} -k --noproxy \u0027*\u0027 -s -o /dev/null -w \u0027%{http_code}\u0027 ${url}) \u003d~ $ok_codes ]]; do sleep 1; done\""},{"line_number":390,"context_line":"    time_stop \"wait_for_service\""},{"line_number":391,"context_line":"}"},{"line_number":392,"context_line":""}],"source_content_type":"application/x-shellscript","patch_set":2,"id":"bab6814e_4757d025","line":389,"updated":"2016-05-26 23:50:38.000000000","message":"don\u0027t you want a \"!\" in here?","commit_id":"abf6c54fb627c62394fb6a6e6bbe62d2e2b9a43a"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"dcddd1b498be3baccdf7e49ab5dc79d6643400e2","unresolved":false,"context_lines":[{"line_number":383,"context_line":"# wait_for_service timeout url"},{"line_number":384,"context_line":"function wait_for_service {"},{"line_number":385,"context_line":"    local timeout\u003d$1"},{"line_number":386,"context_line":"    export wait_for_url\u003d$2"},{"line_number":387,"context_line":"    export CURL_GET"},{"line_number":388,"context_line":"    local rval\u003d0"},{"line_number":389,"context_line":"    time_start \"wait_for_service\""}],"source_content_type":"application/x-shellscript","patch_set":3,"id":"9abb7d3a_47cc0d6a","line":386,"updated":"2016-05-31 19:58:47.000000000","message":"this should not be necessary because the heredoc string will have its vars expanded before it is run","commit_id":"1ba9ccfb14eeb75a2bb2ba76a028bc88fb8c179d"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"dcddd1b498be3baccdf7e49ab5dc79d6643400e2","unresolved":false,"context_lines":[{"line_number":387,"context_line":"    export CURL_GET"},{"line_number":388,"context_line":"    local rval\u003d0"},{"line_number":389,"context_line":"    time_start \"wait_for_service\""},{"line_number":390,"context_line":"    timeout $timeout bash -x \u003c\u003c\\EOF"},{"line_number":391,"context_line":"        while [[ $(${CURL_GET} -f -k --noproxy \u0027*\u0027 -s -o /dev/null -w \u0027%{http_code}\u0027 ${wait_for_url}) \u003d 503 || $? -eq 7 ]]; do sleep 1; done"},{"line_number":392,"context_line":"EOF"},{"line_number":393,"context_line":"    rval\u003d$?"}],"source_content_type":"application/x-shellscript","patch_set":3,"id":"9abb7d3a_47d36d04","line":390,"updated":"2016-05-31 19:58:47.000000000","message":"maybe this \\EOF (backslash) is getting in the way.  I\u0027m not familiar with that for syntax","commit_id":"1ba9ccfb14eeb75a2bb2ba76a028bc88fb8c179d"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"dcddd1b498be3baccdf7e49ab5dc79d6643400e2","unresolved":false,"context_lines":[{"line_number":388,"context_line":"    local rval\u003d0"},{"line_number":389,"context_line":"    time_start \"wait_for_service\""},{"line_number":390,"context_line":"    timeout $timeout bash -x \u003c\u003c\\EOF"},{"line_number":391,"context_line":"        while [[ $(${CURL_GET} -f -k --noproxy \u0027*\u0027 -s -o /dev/null -w \u0027%{http_code}\u0027 ${wait_for_url}) \u003d 503 || $? -eq 7 ]]; do sleep 1; done"},{"line_number":392,"context_line":"EOF"},{"line_number":393,"context_line":"    rval\u003d$?"},{"line_number":394,"context_line":"    time_stop \"wait_for_service\""}],"source_content_type":"application/x-shellscript","patch_set":3,"id":"9abb7d3a_07fcc570","line":391,"updated":"2016-05-31 19:58:47.000000000","message":"since it\u0027s free-form in the heredoc, might as well uses some lines and make it more readable","commit_id":"1ba9ccfb14eeb75a2bb2ba76a028bc88fb8c179d"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"4a747eb2e6bbecde2f2d636be32f48e1dc371d12","unresolved":false,"context_lines":[{"line_number":389,"context_line":"    time_start \"wait_for_service\""},{"line_number":390,"context_line":"    # The form \\EOF is used here otherwise the variables are expanded"},{"line_number":391,"context_line":"    # before running heredoc and it only gets executed once."},{"line_number":392,"context_line":"    # export is needed to pass in the variables we need."},{"line_number":393,"context_line":"    timeout $timeout bash -x \u003c\u003c\\EOF"},{"line_number":394,"context_line":"        while [[ $(${CURL_GET} -f -k --noproxy \u0027*\u0027 -s -o /dev/null -w \u0027%{http_code}\u0027 ${wait_for_url}) \u003d 503 || $? -eq 7 ]]"},{"line_number":395,"context_line":"        do"}],"source_content_type":"application/x-shellscript","patch_set":4,"id":"9abb7d3a_0d6a1fee","line":392,"updated":"2016-05-31 23:29:31.000000000","message":"I\u0027m not sure what you mean here by \"only gets executed once\"?\n\nI\u0027m used to seeing \u003c\u003c\u0027EOF\u0027 if you don\u0027t want the heredoc strings expanded.\n\nIt seems like you just want to put the values of CURL_GET/wait_for_url into the string","commit_id":"59c4cb0a92c18e5762c0cd8545cc9917d2996764"},{"author":{"_account_id":14525,"name":"Vasyl Saienko","email":"vsaienko@mirantis.com","username":"vsaienko"},"change_message_id":"154117c4d86c869aedf72a2f892160ad404811ce","unresolved":false,"context_lines":[{"line_number":383,"context_line":"# wait_for_service timeout url"},{"line_number":384,"context_line":"function wait_for_service {"},{"line_number":385,"context_line":"    local timeout\u003d$1"},{"line_number":386,"context_line":"    export wait_for_url\u003d$2"},{"line_number":387,"context_line":"    export CURL_GET"},{"line_number":388,"context_line":"    local rval\u003d0"},{"line_number":389,"context_line":"    time_start \"wait_for_service\""}],"source_content_type":"application/x-shellscript","patch_set":5,"id":"9abb7d3a_058aeb1a","line":386,"updated":"2016-06-01 08:19:50.000000000","message":"why this export is needed?","commit_id":"bf6ba5dc6601bbd093f15221683e8f8ded21660a"},{"author":{"_account_id":14525,"name":"Vasyl Saienko","email":"vsaienko@mirantis.com","username":"vsaienko"},"change_message_id":"154117c4d86c869aedf72a2f892160ad404811ce","unresolved":false,"context_lines":[{"line_number":384,"context_line":"function wait_for_service {"},{"line_number":385,"context_line":"    local timeout\u003d$1"},{"line_number":386,"context_line":"    export wait_for_url\u003d$2"},{"line_number":387,"context_line":"    export CURL_GET"},{"line_number":388,"context_line":"    local rval\u003d0"},{"line_number":389,"context_line":"    time_start \"wait_for_service\""},{"line_number":390,"context_line":"    # The form \\EOF is used here otherwise the variables are expanded"}],"source_content_type":"application/x-shellscript","patch_set":5,"id":"9abb7d3a_857edb16","line":387,"range":{"start_line":387,"start_character":10,"end_line":387,"end_character":11},"updated":"2016-06-01 08:19:50.000000000","message":"ditto","commit_id":"bf6ba5dc6601bbd093f15221683e8f8ded21660a"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"83c7bdc9ad3a20e80dc21f7c5c870a2fe0324be6","unresolved":false,"context_lines":[{"line_number":389,"context_line":"    time_start \"wait_for_service\""},{"line_number":390,"context_line":"    # The form \\EOF is used here otherwise the variables are expanded"},{"line_number":391,"context_line":"    # before running heredoc and it only gets executed once."},{"line_number":392,"context_line":"    # export is needed to pass in the variables we need."},{"line_number":393,"context_line":"    timeout $timeout bash -x \u003c\u003c\\EOF"},{"line_number":394,"context_line":"        while [[ $(${CURL_GET} -f -k --noproxy \u0027*\u0027 -s -o /dev/null -w \u0027%{http_code}\u0027 ${wait_for_url}) \u003d 503 || $? -eq 7 ]]; do"},{"line_number":395,"context_line":"            sleep 1"}],"source_content_type":"application/x-shellscript","patch_set":6,"id":"9abb7d3a_cbda8416","line":392,"updated":"2016-06-01 21:30:21.000000000","message":"ohh, sorry i see what you mean, i thought you were saying the loop didn\u0027t work or something.\n\nYou just need to quote the \\$ so it misses the first expansion and is left in the string.  there are other examples of this in devstack for reference","commit_id":"a25f5e9273459c94dea590a086a8324cd0ca8e25"},{"author":{"_account_id":14525,"name":"Vasyl Saienko","email":"vsaienko@mirantis.com","username":"vsaienko"},"change_message_id":"4067d0b0c8d9c4131bed1b480a50cf3b6b499146","unresolved":false,"context_lines":[{"line_number":391,"context_line":"    # before running heredoc and it only gets executed once."},{"line_number":392,"context_line":"    # export is needed to pass in the variables we need."},{"line_number":393,"context_line":"    timeout $timeout bash -x \u003c\u003c\\EOF"},{"line_number":394,"context_line":"        while [[ $(${CURL_GET} -f -k --noproxy \u0027*\u0027 -s -o /dev/null -w \u0027%{http_code}\u0027 ${wait_for_url}) \u003d 503 || $? -eq 7 ]]; do"},{"line_number":395,"context_line":"            sleep 1"},{"line_number":396,"context_line":"        done"},{"line_number":397,"context_line":"EOF"}],"source_content_type":"application/x-shellscript","patch_set":6,"id":"9abb7d3a_637e386b","line":394,"updated":"2016-06-01 14:39:49.000000000","message":"I would prefer bash -c \"\" instead of export. It looks ugly.","commit_id":"a25f5e9273459c94dea590a086a8324cd0ca8e25"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"83c7bdc9ad3a20e80dc21f7c5c870a2fe0324be6","unresolved":false,"context_lines":[{"line_number":391,"context_line":"    # before running heredoc and it only gets executed once."},{"line_number":392,"context_line":"    # export is needed to pass in the variables we need."},{"line_number":393,"context_line":"    timeout $timeout bash -x \u003c\u003c\\EOF"},{"line_number":394,"context_line":"        while [[ $(${CURL_GET} -f -k --noproxy \u0027*\u0027 -s -o /dev/null -w \u0027%{http_code}\u0027 ${wait_for_url}) \u003d 503 || $? -eq 7 ]]; do"},{"line_number":395,"context_line":"            sleep 1"},{"line_number":396,"context_line":"        done"},{"line_number":397,"context_line":"EOF"}],"source_content_type":"application/x-shellscript","patch_set":6,"id":"9abb7d3a_8b299ce8","line":394,"in_reply_to":"9abb7d3a_637e386b","updated":"2016-06-01 21:30:21.000000000","message":"can you also drop a comment about exit status 7 (\"can not connect to host\" I guess) so we don\u0027t have to refer to the man page if something goes wrong.","commit_id":"a25f5e9273459c94dea590a086a8324cd0ca8e25"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"b08db6e6b640c56116edfb6d8ac5f682e8ddbf48","unresolved":false,"context_lines":[{"line_number":397,"context_line":"    # before running heredoc and it only gets executed once."},{"line_number":398,"context_line":"    # export is needed to pass in the variables we need"},{"line_number":399,"context_line":"    timeout $timeout bash -x \u003c\u003c\\EOF"},{"line_number":400,"context_line":"        while [[ $(${CURL_GET} -k --noproxy \u0027*\u0027 -s -o /dev/null -w \u0027%{http_code}\u0027 ${wait_for_url}) \u003d 503 || $? -eq 7 ]]; do"},{"line_number":401,"context_line":"            sleep 1"},{"line_number":402,"context_line":"        done"},{"line_number":403,"context_line":"EOF"}],"source_content_type":"application/x-shellscript","patch_set":8,"id":"7aa08908_a89519e5","line":400,"updated":"2016-06-07 00:06:25.000000000","message":"You just want to escape those parts you want the sub-shell running under \"timeout\" to see.  So this should be\n\n while [[ \\$( ${CURL_GET} ... ${url} ) || \\$? -eq 7 ]]; do\n\ni.e. let CURL_GET \u0026 url be expanded in that first pass but leave the process substitution for the sub-shell\n\nalso, while we\u0027re there, use \u003d\u003d for clarity","commit_id":"4e263f58da910900d25a1143e2de163c8c5624e2"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"b08db6e6b640c56116edfb6d8ac5f682e8ddbf48","unresolved":false,"context_lines":[{"line_number":401,"context_line":"            sleep 1"},{"line_number":402,"context_line":"        done"},{"line_number":403,"context_line":"EOF"},{"line_number":404,"context_line":"    rval\u003d$?"},{"line_number":405,"context_line":"    time_stop \"wait_for_service\""},{"line_number":406,"context_line":"    return $rval"},{"line_number":407,"context_line":"}"}],"source_content_type":"application/x-shellscript","patch_set":8,"id":"7aa08908_282649ce","line":404,"updated":"2016-06-07 00:06:25.000000000","message":"this won\u0027t work running under \"set -e\" (as we do) if there is a failure; the timeout call will just error out the script.\n\nNeed to catch this with a \"|| rval\u003d$?\" I guess.\n\nIt really seems like we should have \"die()\"ed in here as an api choice, because every call just checks the ret and dies anyway.","commit_id":"4e263f58da910900d25a1143e2de163c8c5624e2"},{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"1fa1b0914bd8a0ecad237a5191beb0bf3739cf75","unresolved":false,"context_lines":[{"line_number":392,"context_line":"    local url\u003d$2"},{"line_number":393,"context_line":"    local rval\u003d0"},{"line_number":394,"context_line":"    time_start \"wait_for_service\""},{"line_number":395,"context_line":"    timeout $timeout bash -x \u003c\u003cEOF"},{"line_number":396,"context_line":"        while [[ \\$( ${CURL_GET} -k --noproxy \u0027*\u0027 -s -o /dev/null -w \u0027%{http_code}\u0027 ${url} ) \u003d\u003d 503 || \\$? -eq 7 ]]; do"},{"line_number":397,"context_line":"            sleep 1"},{"line_number":398,"context_line":"        done"}],"source_content_type":"application/x-shellscript","patch_set":10,"id":"7aa08908_e1c169e5","line":395,"updated":"2016-06-08 21:46:38.000000000","message":"LGTM!\n\nJust the one last thing about the return code ... this isn\u0027t \"errexit\" safe.  actually, it hasn\u0027t been errexit safe since I guess we introduced these \"time_*\" functions but we might as well fix it, since our API, such as it is, is to return the status of the curl\n\n timeout $timeout bash -x \u003c\u003cEOF || ret\u003d$?\n\nshould do it I think","commit_id":"df9aefa135577e56af7d401de46ef51b903d6e76"}]}
