Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch_configlet: retry if curl request fails #424

Merged
merged 3 commits into from
Mar 12, 2020
Merged

fetch_configlet: retry if curl request fails #424

merged 3 commits into from
Mar 12, 2020

Conversation

glennj
Copy link
Contributor

@glennj glennj commented Feb 26, 2020

@glennj glennj requested review from guygastineau and kotp February 26, 2020 17:06
Copy link
Member

@kotp kotp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change for readability.

Sight reviewed, and approvable, but not tested.

Comment on lines 38 to 39
for i in {0..4}; do
sleep $i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for i in {0..4}; do
sleep $i
for delay in {0..4}; do
sleep $delay

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...with variable expansions quoted, of course.

Copy link
Contributor Author

@glennj glennj Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an integer, and IFS has not been altered. But I'll add some quotes.

Comment on lines 38 to 39
for i in {0..4}; do
sleep $i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...with variable expansions quoted, of course.

sleep $i
curl -s --location "$URL" -o "$localfile"
if file "$localfile" 2>&1 | grep -q "$file_info"; then
# fetched successfully
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this just rely on curl's exit status?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errexit is on, so the script will die on non-zero.
Anyway the problem is that a small text file is fetched, not the (g)zip content we're expecting.

@glennj
Copy link
Contributor Author

glennj commented Feb 26, 2020

Sight reviewed, and approvable, but not tested.

It was (kind of) field tested: https://travis-ci.org/exercism/bash/builds/655446128?utm_source=github_status&utm_medium=notification

Copy link
Contributor

@guygastineau guygastineau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Do we need to restart travis? I thought everything was supposed to switch to Github actions.

@glennj
Copy link
Contributor Author

glennj commented Mar 11, 2020

@kotp @IsaacG @guygastineau I found the fix on another track: while querying the latest version, the curl --head results returned the header field names in lower case. I'll keep the retrying code for good measure, but the last commit updates the awk command for case insensitivity.

@glennj glennj requested review from kotp and guygastineau March 11, 2020 13:24
@glennj
Copy link
Contributor Author

glennj commented Mar 11, 2020

@IsaacG I'm not excluding you, but the UI won't let me re-request your review.

@kotp kotp merged commit 537d6e3 into exercism:master Mar 12, 2020
@glennj glennj deleted the fetch_configlet-should-retry branch March 12, 2020 00:48
workingjubilee added a commit to workingjubilee/c that referenced this pull request Mar 19, 2020
Riffing off of @glennj's fix exercism/bash#424

This fixes the problem by adding retries to the curl attempt, combined
with the case-sensitivity fix. Also some of the logic has been reflowed.
Most notably, we now dynamically check for what archive extension to use.
ryanplusplus pushed a commit to exercism/c that referenced this pull request Mar 19, 2020
* Fix fetch-configlet script

Shamelessly dupes @coriolinus' fix: exercism/rust#929

"Looks like Github has recently started returning non-uppercased
HTTP headers, at least some of the time. This broke the script,
which looked for a case-sensitive 'Location' header to find the
newest version. We can see this problem in spurious build failures like this."

"This fixes the script such that it no longer cares whether the initial
L is capital or not, and if it breaks again in the future, it will
give a more informative error."

* Add retry to fetch-configlet

Riffing off of @glennj's fix exercism/bash#424

This fixes the problem by adding retries to the curl attempt, combined
with the case-sensitivity fix. Also some of the logic has been reflowed.
Most notably, we now dynamically check for what archive extension to use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants