Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
nowinkeyy committed Nov 9, 2023
1 parent aa9c99a commit f43ecba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 6 additions & 1 deletion controllers/minio/controllers/bucket_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"fmt"
"strings"
"time"

Expand Down Expand Up @@ -198,9 +199,13 @@ func (r *BucketReconciler) SetupWithManager(mgr ctrl.Manager) error {
minioBucketDetectionCycleSecond := env.GetInt64EnvWithDefault(MinioBucketDetectionCycleEnv, 600)
r.MinioBucketDetectionCycle = time.Duration(minioBucketDetectionCycleSecond) * time.Second

minioInternalEndpoint := env.GetEnvWithDefault(MinioInternalEndpointEnv, "minio.minio-system.svc.cluster.local")
minioInternalEndpoint := env.GetEnvWithDefault(MinioInternalEndpointEnv, "")
r.MinioInternalEndpoint = minioInternalEndpoint

if minioInternalEndpoint == "" {
return fmt.Errorf("failed to get the minio endpoint env")
}

return ctrl.NewControllerManagedBy(mgr).
For(&miniov1.Bucket{}).
Complete(r)
Expand Down
13 changes: 8 additions & 5 deletions controllers/minio/controllers/miniouser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"fmt"
"strings"
"time"

Expand Down Expand Up @@ -136,8 +137,6 @@ func (r *MinioUserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
r.Logger.Error(err, "failed to new minio user", "name", accessKey)
return ctrl.Result{}, err
}
// if the minio user is newly created, just return
return ctrl.Result{Requeue: true, RequeueAfter: r.MinioUserDetectionCycle}, nil
}

// check whether the space used exceeds the quota
Expand Down Expand Up @@ -291,7 +290,7 @@ func (r *MinioUserReconciler) initMinioUser(minioUser *miniov1.MinioUser, userna
}

if minioUser.Status.SecretKey == "" {
minioUser.Status.SecretKey = rand.Generator(32)
minioUser.Status.SecretKey = rand.Generator(16)
updated = true
}

Expand All @@ -316,12 +315,16 @@ func (r *MinioUserReconciler) SetupWithManager(mgr ctrl.Manager) error {
minioUserDetectionCycleSecond := env.GetInt64EnvWithDefault(MinioUserDetectionCycleEnv, 180)
r.MinioUserDetectionCycle = time.Duration(minioUserDetectionCycleSecond) * time.Second

minioInternalEndpoint := env.GetEnvWithDefault(MinioInternalEndpointEnv, "minio.minio-system.svc.cluster.local")
minioInternalEndpoint := env.GetEnvWithDefault(MinioInternalEndpointEnv, "")
r.MinioInternalEndpoint = minioInternalEndpoint

minioExternalEndpoint := env.GetEnvWithDefault(MinioExternalEndpointEnv, "minioapi.dev.sealos.top")
minioExternalEndpoint := env.GetEnvWithDefault(MinioExternalEndpointEnv, "")
r.MinioExternalEndpoint = minioExternalEndpoint

if minioInternalEndpoint == "" || minioExternalEndpoint == "" {
return fmt.Errorf("failed to get the minio endpoint env")
}

return ctrl.NewControllerManagedBy(mgr).
For(&miniov1.MinioUser{}).
Complete(r)
Expand Down

0 comments on commit f43ecba

Please sign in to comment.