From a788373c0f21de3802d91abbb8eaccbdc309d59d Mon Sep 17 00:00:00 2001 From: pb Date: Fri, 1 Aug 2025 16:23:41 +0200 Subject: [PATCH] corrected the way we create buckets --- controllers/minio.go | 8 ++++---- infrastructure/minio.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controllers/minio.go b/controllers/minio.go index 0214f28..059be3c 100644 --- a/controllers/minio.go +++ b/controllers/minio.go @@ -17,9 +17,9 @@ type MinioController struct { // @Title CreateServiceAccounnt // @Description Add a new ServiceAccount to a Minio server using its ID and an execution ID and store the secret holding the login in the appropriate namespace // @Success 200 -// @Param executions path string true "The executionsID of the execution" -// @Param minioId path string true "The ID of the Minio you want to reach" -// @Param retrieve body map[string]string true "Tell the route if the login should be returned in the body" +// @Param executions path string true "The executionsID of the execution" +// @Param minioId path string true "The ID of the Minio you want to reach" +// @Param retrieve body map[string]string false "Should be empty or contain "'retrieve': true" // @router /serviceaccount/:minioId/:executions [post] func (m *MinioController) CreateServiceAccount() { _, peerID, _ := oclib.ExtractTokenInfo(*m.Ctx.Request) @@ -127,7 +127,7 @@ func (m *MinioController) createServiceAccount(minioId string, peerID string, ex err = service.CreateBucket(executionsId) if err != nil { m.Ctx.Output.SetStatus(500) - m.Data["json"] = map[string]interface{}{"error": "could not create the service account for " + minioId + " : " + err.Error()} + m.Data["json"] = map[string]interface{}{"error": "error while creating the service account for " + minioId + " : " + err.Error()} m.ServeJSON() return "", "", false } diff --git a/infrastructure/minio.go b/infrastructure/minio.go index e5f8aba..878c816 100644 --- a/infrastructure/minio.go +++ b/infrastructure/minio.go @@ -115,8 +115,8 @@ func (m *MinioService) CreateBucket(executionId string) error { return err } - err = client.MakeBucket(context.Background(), executionId, minio.MakeBucketOptions{}) - if err != nil { + err = client.MakeBucket(context.Background(), executionId, minio.MakeBucketOptions{ForceCreate: false}) + if err != nil && err.(minio.ErrorResponse).Code != "BucketAlreadyOwnedByYou" { l.Error().Msg("Error when creating the bucket for namespace " + executionId) return err }