Skip to content

Commit 50f1f79

Browse files
author
don
committed
fix: Return nil robot client when credentials are empty
When robot credentials file exists but contains empty username/password (common in cloud-only CAPI clusters), the code would create a Robot client with empty credentials. This client would fail with 'Unauthorized' errors when LoadBalancer tried to attach targets. This fix adds a check after reading credentials from file to ensure they are not empty before creating the Robot client, matching the behavior when reading from environment variables. Fixes LoadBalancer target attachment failures in cloud-only clusters.
1 parent 62eaaca commit 50f1f79

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/robot/client/cache/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ func NewCachedRobotClient(rootDir string, httpClient *http.Client, baseURL strin
7272
if err != nil {
7373
return nil, fmt.Errorf("%s: %w", op, err)
7474
}
75+
if robotUser == "" || robotPassword == "" {
76+
klog.Infof("Hetzner robot is not supported because of insufficient credentials: credentials file exists but username or password is empty")
77+
return nil, nil
78+
}
7579
}
7680
c := hrobot.NewBasicAuthClientWithCustomHttpClient(robotUser, robotPassword, httpClient)
7781
if baseURL != "" {

0 commit comments

Comments
 (0)