Hi guys,
Am testing the latest and greatest Rancher and am hiving certain issues with its API. Since I am utilizing API a lot it happens that I am not getting response every time.
I am using terraform to spin up Azure VMs. One of the instance is meant for Rancher server and once I run Rancher docker image I am waiting on it to come up and become responsive. Once it’s up I start to interact with API via simple curl calls. Unfortunately curl doesn’t always return values I am looking for but null
instead. If I ssh
into the Azure Vm and try the exact same curl command, it works. I’ve tried playing around with timers and setting sleep
in different places, giving it time to set everything internally and only then to start interacting with API and that did change things to the better, but not always as I am still not getting values while provisioning the instance.
There seems to be a similar issue for an previous version Rancher API timeout but there was no response.
Thank you in advance for any suggestion and guidelines!
Cheers!
For example a request like this:
curl --silent "http://${rancher_server_private_ip}:${port}/v2-beta/projectTemplate?name=kubernetes" | jq '.data[0].id'
returns 1pt2
(or whatever the templateID is) or null
when provisioned via bash script (that is being executed directly on the Rancher server instance), but it always returns the correct templateID when manually run directly from Azure instance where Rancher server is running.
That post (not getting a response from the server) and yours (getting a response but you don’t necessarily like what it said) do not sound related…
Presumably you’re getting back an empty collection, the response to an API call should never be literally null
. Project templates are loaded from the catalog and won’t be there immediately at the time the server starts listening. But you’re throwing away all evidence of it with --silent
and directly piping to jq
. A jq selector on a field that doesn’t exist (e.g. if there is no 0th item in data
) will give you back null
.
I’m completely aware of the fact that null
is a result of curl --silent
and jq
working together but then again, it sometimes succeeds and sometimes it fails to retrieve the information - in the same time frame so to speak - which is an indication that API is not always ready at the same time after the server boot. Ok, that explains a lot then and it’s enough information for me to work with and to come up with an workaround.
Thanks a lot, this was helpful!