Skip to content

Retries succeed after getting an HTTP 401 error #145

@lindhe

Description

@lindhe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions