Skip to content

Consult http_code and download_error_msg only for failed downloads. #137

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

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

ujpandey
Copy link
Contributor

@ujpandey ujpandey commented Feb 5, 2021

Should fix #136

@dnfadmin
Copy link

dnfadmin commented Feb 5, 2021

CLA assistant check
All CLA requirements met.

@danmoseley
Copy link
Member

@bozturkMSFT could you please review?

Copy link
Member

@lewing lewing left a comment

Choose a reason for hiding this comment

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

Thanks @ujpandey

This fix looks fine to me but I'll wait for @bozturkMSFT to approve.

Looking over the original patch it might also make sense try wget if it is available but curl has failed.

Copy link
Member

@lewing lewing left a comment

Choose a reason for hiding this comment

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

Actually since this needs two


# if the download fails, download the legacy_download_link
if [ "$download_failed" = true ]; then
primary_path_http_code="$http_code"; primary_path_download_error_msg="$download_error_msg"
Copy link
Member

Choose a reason for hiding this comment

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

This will still be unbound if you don't have wget or curl - download will fail, but you won't have an error code. @bozturkMSFT does it make sense to say, just exit the script if neither was found?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds reasonable enough to me at least so I updated the PR to do exactly that.

Copy link
Member

Choose a reason for hiding this comment

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

Returning 1 from download() will sadly preserve this error behavior. Exiting directly from that function wont .

There's two options:

  • Just log the message there and exit. There's little that can be done at any other point in the script that's useful to the users. This also avoids doing retries if there's no curl or wget.
  • Change this to something like:
Suggested change
primary_path_http_code="$http_code"; primary_path_download_error_msg="$download_error_msg"
primary_path_http_code="${http_code:-toolError}"; primary_path_download_error_msg="$download_error_msg"

The messages will repeat and do retries, but it's pretty small of a fix.

Even with this contribution I'd be happy, as most error cases in the script will be "couldn't download", not "couldn't find something to download with", and this would fix issues that are pretty disruptive right now.

unset http_code
download_error_msg="Missing dependency: neither curl nor wget was found."
break
say_err "Missing dependency: neither curl nor wget was found."
Copy link
Member

Choose a reason for hiding this comment

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

I'd recommend that you return to the old logic here. There should be no http_code if there's no http request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean that I should be unsetting it? We are exiting the script when we hit this condition though, so that doesn't matter unless I am missing something? http_code is only a global and not an env var.

FWIW it appears that the script was already exiting if neither curl or wget were present thanks to check_min_reqs().

Copy link
Member

Choose a reason for hiding this comment

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

Ah, then maybe this is defensive. return 1 wouldn't exit here, but if check_min_reqs does it, then your original fix was better. Just means that the no-wget-or-curl branch of this was dead all along. Thanks for explaining.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I missed that about returning 1 from inside the function not actually exiting, thank you for catching that. I think it makes sense to be defensive also even if the branch is dead, and I think it's better to just exit with the message logged so I updated the PR to that fwiw.

Copy link

@idle-code idle-code left a comment

Choose a reason for hiding this comment

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

LGTM + this fixes our pipeline

Copy link
Member

@vlada-shubina vlada-shubina left a comment

Choose a reason for hiding this comment

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

nit: it would be good to avoid whitespace changes when possible

@dave-yotta
Copy link

Just to reiterate this has stopped all our deployments and a lot of development work, we rely on roslyn in production, please can the fix be merged ASAP or the latest install scripts be rolled back to yesterday.

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.

Unbound variable error from the latest version of dotnet-install.sh
10 participants