Cannot re-register agent: `Failed to load registration env`

After upgrading from Rancher 1.2.0 to 1.2.2 yesterday.

Today, I discovered that Rancher shows the host as ‘Disconnected’. I couldn’t figure out why this was happening, so I tried to re-register the host with a new Rancher Agent. However, the Rancher Agent is showing some sort of problem when trying to re-register itself. What could cause this problem?

I start the Rancher Agent, and it exits fairly quickly. I see that the rancher-agent bootstrap container doesn’t fire off any new containers from the rancher/agent image:

[root@docker01 ~]# docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.1.2 https://rancher01.example.org/v1/scripts/blahblah1:12345blah:blahblah

[root@rancher01 ~]# docker ps -a |grep agent
2a9688d0073a        rancher/agent:v1.1.2                           "/run.sh https://ranc"   3 seconds ago       Up 2 seconds                                    gloomy_swirles

The logs make it seem that the container could connect to the Rancher Server at https://rancher01.example.org , but then fail due to a missing URL?

[root@rancher01 ~]# docker logs --tail -f  2a9688d0073a
Updating certificates in /etc/ssl/certs...
WARNING: rancherAddedCA.pem does not contain a certificate or CRL: skipping
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.

INFO: Running Agent Registration Process, CATTLE_URL=https://rancher01.example.org/v1
INFO: Attempting to connect to: https://rancher01.example.org/v1
INFO: https://rancher01.example.org/v1 is accessible
Traceback (most recent call last):
  File "./resolve_url.py", line 9, in <module>
    r = requests.get(url)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 497, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: unknown error (_ssl.c:2831)
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information

ERROR: returned
ERROR: --- START ---
ERROR: --- END ---
ERROR: Failed to load registration env from CATTLE_URL=https://rancher01.example.org/v1 ENV_URL=    ERROR: Please ensure the proper value for the Host Registration URL is set

And yes, the host can reach the Rancher Server:

[root@docker01 ~]# curl https://rancher01.example.org/v1
{"id":"5519214c-a18b-433d-968f-128015d9bee9","type":"error","links":{},"actions":{},"status":401,"code":"Unauthorized","message":"Unauthorized","detail":null,"baseType":"error"}[root@docker01 ~]#

I have exactly the same problem today with rancher rancher/agent v1.2.9 when trying to register a host:

INFO: Running Agent Registration Process, CATTLE_URL=https://rancher.wongsrus.net.au/v1
INFO: Attempting to connect to: https://rancher.wongsrus.net.au/v1
INFO: https://rancher.wongsrus.net.au/v1 is accessible
Traceback (most recent call last):
File “./resolve_url.py”, line 9, in
r = requests.get(url)
File “/usr/local/lib/python2.7/dist-packages/requests/api.py”, line 70, in get
return request(‘get’, url, params=params, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/api.py”, line 56, in request
return session.request(method=method, url=url, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/sessions.py”, line 488, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/sessions.py”, line 609, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/adapters.py”, line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: unknown error (_ssl.c:2831)
curl: no URL specified!
curl: try ‘curl --help’ or ‘curl --manual’ for more information
ERROR: returned
ERROR: — START —
ERROR: — END —

ERROR: Failed to load registration env from CATTLE_URL=MYRANCHER_URL/v1 ENV_URL=
ERROR: Please ensure the proper value for the Host Registration URL is set

Did you manage to fix your issue?

Steven

Steve,

I did fix my issue. However, this post is from a year ago and I don’t remember how I fixed it. I suspect I deleted the Rancher Agent and all Rancher Infrastructure Containers on the host, using something like this:

docker container rm $(docker ps -a | grep rancher/ |cut -f1 -d" ")

That’s a command that I’ve used several times to help clear mysterious issues with Rancher Agent & the Infrastructure Containers. A few times I’ve even tried removing the image for the Rancher Agent.

-= Stefan

Thanks Stefan, I think the error i am getting is different as I got different error now: from python : requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
after some fiddling around. I am only working on a POC so will not solve this ssl problem for now. I am reverting to using http and all is good… for now.

1 Like