ctubbsii commented on a change in pull request #317: Correctly retry ASF mirror listing task URL: https://github.com/apache/fluo-muchos/pull/317#discussion_r373833382
########## File path: ansible/roles/accumulo/tasks/download.yml ########## @@ -19,10 +19,10 @@ shell: curl -sk https://apache.org/mirrors.cgi?as_json | grep preferred | cut -d \" -f 4 args: warn: no + register: apache_mirror retries: 10 delay: 10 - register: apache_mirror - failed_when: "'http' not in apache_mirror.stdout" + until: "'http' in apache_mirror.stdout" Review comment: The retrieval of the mirror list is a bit unreliable, since it is depending on the unstable json formatting that the server just happens to return. If we could ensure the machines had `jq` installed, we could easily parse the json instead. Something like: ```yaml shell: curl -sk https://apache.org/mirrors.cgi?as_json | jq -r .preferred ``` I'm not sure if it's possible to base the retry on the the command return codes, but if it is, you AND the return codes from both commands in the pipe with something like: ```yaml shell: curl -sk https://apache.org/mirrors.cgi?as_json | jq -r .preferred; [[ ${PIPESTATUS[0]} -eq 0 && ${PIPESTATUS[1]} ``` I don't know YAML/Ansible well enough to know how much bash could work there without getting crazy with the escaping, but if you could retry until the command is successful, that might be better than checking for 'http' in the output... which could also appear in an error message (and also 'preferred' could return ftp). At the very least, parsing using `jq` instead of `grep` could improve this retrieval / retry code a bit. (Or, if you don't want to install `jq`, you could do the same in python, but it's uglier: `| python3 -c "import sys, json; print(json.load(sys.stdin)['preferred'])"`). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
