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

Retries succeed after getting an HTTP 401 error #145

Open
lindhe opened this issue Nov 7, 2023 · 0 comments
Open

Retries succeed after getting an HTTP 401 error #145

lindhe opened this issue Nov 7, 2023 · 0 comments

Comments

@lindhe
Copy link

lindhe commented Nov 7, 2023

I'm getting the following output when registering nodes in Rancher:

$ curl -fL https://rancher.example.com/system-agent-install.sh | sudo  sh -s - --server https://rancher.example.com --label 'cattle.io/os=linux' --token f00barf00barf00barf00barf00barf00barf00barf00barf00bar --etcd --controlplane
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 30796    0 30796    0     0   252k      0 --:--:-- --:--:-- --:--:--  252k
[INFO]  Label: cattle.io/os=linux
[INFO]  Role requested: etcd
[INFO]  Role requested: controlplane
[INFO]  Using default agent configuration directory /etc/rancher/agent
[INFO]  Using default agent var directory /var/lib/rancher/agent
[INFO]  Successfully tested Rancher connection
[INFO]  Downloading rancher-system-agent binary from https://rancher.example.com/assets/rancher-system-agent-amd64
[INFO]  Successfully downloaded the rancher-system-agent binary.
[INFO]  Downloading rancher-system-agent-uninstall.sh script from https://rancher.example.com/assets/system-agent-uninstall.sh
[INFO]  Successfully downloaded the rancher-system-agent-uninstall.sh script.
[INFO]  Generating Cattle ID
[ERROR]  401 received while downloading Rancher connection information. Sleeping for 5 seconds and trying again
[ERROR]  401 received while downloading Rancher connection information. Sleeping for 5 seconds and trying again
[INFO]  Successfully downloaded Rancher connection information
[INFO]  systemd: Creating service file
[INFO]  Creating environment file /etc/systemd/system/rancher-system-agent.env
[INFO]  Enabling rancher-system-agent.service
Created symlink /etc/systemd/system/multi-user.target.wants/rancher-system-agent.service  /etc/systemd/system/rancher-system-agent.service.
[INFO]  Starting/restarting rancher-system-agent.service

The notable part is this:

[ERROR]  401 received while downloading Rancher connection information. Sleeping for 5 seconds and trying again
[ERROR]  401 received while downloading Rancher connection information. Sleeping for 5 seconds and trying again
[INFO]  Successfully downloaded Rancher connection information

It makes no sense to retry when getting a 4xx error, since that means that "the request contains bad syntax or cannot be fulfilled". This is what MDN writes about it:

The HyperText Transfer Protocol (HTTP) 401 Unauthorized response status code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource.

So we know that we use the wrong credentials. Unless there is a reason to believe that the credentials suddenly will become valid, there is no real point in retrying a request that get this error. Yet, we see that it does indeed succeed after a few retries! So something is up here, not sure what.

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

No branches or pull requests

1 participant