From ee7b527ef036fccb9e4e4815af15c30606dd8b8f Mon Sep 17 00:00:00 2001 From: "lukasz.widera@vshn.ch" Date: Wed, 2 Oct 2024 11:44:18 +0200 Subject: [PATCH] switching how we handle broken userID fetch --- pkg/cloudscale/objectstorage.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/cloudscale/objectstorage.go b/pkg/cloudscale/objectstorage.go index cb5d60b..6d5c536 100644 --- a/pkg/cloudscale/objectstorage.go +++ b/pkg/cloudscale/objectstorage.go @@ -81,14 +81,16 @@ func (o *ObjectStorage) GetMetrics(ctx context.Context, billingDate time.Time) ( // Since our buckets are always created in the convention $namespace.$bucketname, we can extract the namespace from the bucket name by splitting it. // However, we need to fetch the user details to get the actual namespace. - for _, bucket := range bucketMap { + for key, bucket := range bucketMap { // fetch bucket user by id logger.Info("fetching user details", "userID", bucket.Subject.ObjectsUserID) userDetails, err := o.client.ObjectsUsers.Get(ctx, bucket.Subject.ObjectsUserID) if err != nil { o.providerMetrics["providerFailed"].Inc() - logger.Error(err, "unknown userID, something broke here fatally") - return nil, err + logger.Error(err, "unknown userID, something broke here fatally", "userID", bucket.Subject.ObjectsUserID, "bucket", bucket) + // deleting this bucket as it's unsuable + delete(bucketMap, key) + continue } bucket.BucketDetail.Namespace = strings.Split(userDetails.DisplayName, ".")[0] }