Handle context cancellation in ListAccounts and add corresponding test

Signed-off-by: Steven4Hooisma <112615049+Steven4Hooisma@users.noreply.github.com>
This commit is contained in:
Steven4Hooisma
2026-07-23 16:06:44 +02:00
committed by Aurélien Sibiril
parent 9cdc77ba8e
commit dbc49748f9
2 changed files with 49 additions and 0 deletions

View File

@@ -126,6 +126,10 @@ func (d *UpCloudDriver) ListAccounts(ctx context.Context) ([]AccountRecord, erro
details, err := d.fetchAccountDetails(ctx, username)
if err != nil {
if ctx.Err() != nil {
return nil, fmt.Errorf("cannot list upcloud accounts: %w", ctx.Err())
}
d.logger.WarnCtx(ctx, "cannot fetch upcloud account details, using list fields only", log.Error(err))
} else {
if name := strings.TrimSpace(details.FirstName + " " + details.LastName); name != "" {