-
Notifications
You must be signed in to change notification settings - Fork 40
Increasing timeout from 0.8 to 2 #195
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
Conversation
credentials_gce() function was failing since default timeout was too low. Increasing it from 0.8 to 2 fixed the issue.
|
To confirm: did you run into the timeout on a GCE instance running the usual metadata server? In particular, there's a tension here: you want a long timeout when you're on GCE, but you want a short timeout when you're not on GCE and you're stuck waiting for this request to timeout. (Whether the request will immediately fail or timeout depends on your networking config, sometimes including factors outside your control.) |
|
@craigcitro Yup, I was simply running credentials_gce() function in RStudio installed in Google Compute Engine to auth into BQ using default compute engine account & found that the below line was failing It is the default metadata server request I believe. On increasing timeout from 0.8 to 2, it started working. The particular GET request doesn't seem to work outside of GCP, it's specific to the VM. |
|
We use the same request to detect that we're on GCE (eg Lines 129 to 132 in 4732f8c
I suspect raising the timeout is worthwhile, but it's worth noting that a large timeout may lead to user-visible slowness for some users when checking whether or not they're on GCE. |
|
We could make this timeout configurable via an env var, with the default short, suitable for people who are not on GCE (the vast majority of gargle usage, I suspect). But GCE users could set it to something much longer. |
|
@craigcitro I understand your point, as @jennybc has said, it would be great if we can make it configurable with the default value being the same as it is now so that it doesn't affect existing users. Given the current state, it is too low such that it is timing out before the metadata server can return a legitimate request and since I'm running this on Google Compute Engine, it's a server to server connection so I don't think network speed should be the problem. I believe it would be worthwhile to make it configurable. |
|
👍 on configurability. Actually, as a related tweak: in |
|
I feel like there is some risk of going in circles here. Early on, we call I understand that we might increase the timeout once we know we're on GCE. But it feels like the only way to know we're on GCE also involves a metadata request. So for that first call, only a timeout-increase-via-config would really help. Do I have this right? |
|
Oh maybe this is what I was missing:
|
|
So I think I'm on board with this suggestion from @craigcitro now:
|
Great idea!!! Yes, that would solve this problem without any additional configuration, such that I can discard any separate code/configuration for auth in all my scripts. |
|
We can replace the line
with
Added it via a commit |
Modifying the code such that higher timeout is set if metadata token request is coming from GCP
| } | ||
| url <- paste0(root_url, "computeMetadata/v1/", path) | ||
| timeout <- getOption("gargle.gce.timeout", default = 2) | ||
| timeout <- getOption("gargle.gce.timeout", default = ifelse(!detect_gce(), 0.8, 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would seem to create a recursive call to gce_metadata_request().
Now that we seem to be converging on the right solution, I plan to make a PR that implements it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jennybc Alright, thanks :)
credentials_gce() function was failing since default timeout was too low. Increasing it from 0.8 to 2 fixed the issue.