Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for MinIO to be ready before proceeding with any further tasks. #2172

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
pjuarezd marked this conversation as resolved.
Show resolved Hide resolved
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 (
UsersCreationFailedReason = "UsersCreationFailed"
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 @@ -1315,11 +1322,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: %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, UsersCreationFailedReason, fmt.Sprintf("Users creation failed: %s", err))
// retry after 5sec
return WrapResult(Result{RequeueAfter: time.Second * 5}, nil)
}
Expand Down
Loading