corrected the way we create buckets

This commit is contained in:
pb 2025-08-01 16:23:41 +02:00
parent c45824d3f2
commit a788373c0f
2 changed files with 6 additions and 6 deletions

View File

@ -17,9 +17,9 @@ type MinioController struct {
// @Title CreateServiceAccounnt // @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 // @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 // @Success 200
// @Param executions path string true "The executionsID of the execution" // @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 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 retrieve body map[string]string false "Should be empty or contain "'retrieve': true"
// @router /serviceaccount/:minioId/:executions [post] // @router /serviceaccount/:minioId/:executions [post]
func (m *MinioController) CreateServiceAccount() { func (m *MinioController) CreateServiceAccount() {
_, peerID, _ := oclib.ExtractTokenInfo(*m.Ctx.Request) _, peerID, _ := oclib.ExtractTokenInfo(*m.Ctx.Request)
@ -127,7 +127,7 @@ func (m *MinioController) createServiceAccount(minioId string, peerID string, ex
err = service.CreateBucket(executionsId) err = service.CreateBucket(executionsId)
if err != nil { if err != nil {
m.Ctx.Output.SetStatus(500) 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() m.ServeJSON()
return "", "", false return "", "", false
} }

View File

@ -115,8 +115,8 @@ func (m *MinioService) CreateBucket(executionId string) error {
return err return err
} }
err = client.MakeBucket(context.Background(), executionId, minio.MakeBucketOptions{}) err = client.MakeBucket(context.Background(), executionId, minio.MakeBucketOptions{ForceCreate: false})
if err != nil { if err != nil && err.(minio.ErrorResponse).Code != "BucketAlreadyOwnedByYou" {
l.Error().Msg("Error when creating the bucket for namespace " + executionId) l.Error().Msg("Error when creating the bucket for namespace " + executionId)
return err return err
} }