Skip to content

Commit

Permalink
Wait for MinIO to be ready before proceeding with any further tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
cniackz committed Jun 21, 2024
1 parent fd7ede7 commit 436141f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ examples/**/obj/
public.crt
go_build_operator_
operator.iml
.run/
17 changes: 16 additions & 1 deletion pkg/controller/main-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ const (
MessageResourceExists = "Resource %q already exists and is not managed by MinIO Operator"
)

// Standard Events for Tenant
const (
UsersCreatedFailedReason = "UsersCreatedFailed"
WaitingMinIOIsHealthyReason = "WaitingMinIOIsHealthy"
)

// Standard Status messages for Tenant
const (
StatusInitialized = "Initialized"
Expand All @@ -98,6 +104,7 @@ const (
StatusProvisioningConsoleService = "Provisioning Console Service"
StatusProvisioningKESStatefulSet = "Provisioning KES StatefulSet"
StatusProvisioningInitialUsers = "Provisioning initial users"
StatusWaitingMinIOIsHealthy = "Waiting for Tenant to be healthy"
StatusProvisioningDefaultBuckets = "Provisioning default buckets"
StatusWaitingMinIOCert = "Waiting for MinIO TLS Certificate"
StatusWaitingMinIOClientCert = "Waiting for MinIO TLS Client Certificate"
Expand Down Expand Up @@ -1314,11 +1321,19 @@ func (c *Controller) syncHandler(key string) (Result, error) {
}
}

// Stay in this state until minio is ready
if tenant.Status.HealthStatus != miniov2.HealthStatusGreen {
c.updateTenantStatus(ctx, tenant, StatusWaitingMinIOIsHealthy, 0)
c.recorder.Event(tenant, corev1.EventTypeWarning, WaitingMinIOIsHealthyReason, fmt.Sprintf("Waiting for MinIO to be ready prior any minio task: %s", err))
// retry after 5sec
return WrapResult(Result{RequeueAfter: time.Second * 5}, nil)
}

// Ensure we are only provisioning users one time
if !tenant.Status.ProvisionedUsers && len(tenant.Spec.Users) > 0 {
if err := c.createUsers(ctx, tenant, tenantConfiguration); err != nil {
klog.V(2).Infof("Unable to create MinIO users: %v", err)
c.recorder.Event(tenant, corev1.EventTypeWarning, "UsersCreatedFailed", fmt.Sprintf("Users creation failed: %s", err))
c.recorder.Event(tenant, corev1.EventTypeWarning, UsersCreatedFailedReason, fmt.Sprintf("Users creation failed: %s", err))
// retry after 5sec
return WrapResult(Result{RequeueAfter: time.Second * 5}, nil)
}
Expand Down

0 comments on commit 436141f

Please sign in to comment.