Skip to content

Commit

Permalink
Improving the status message when it is stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
cniackz committed Jun 21, 2024
1 parent fd7ede7 commit 831f841
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
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/
23 changes: 19 additions & 4 deletions 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 @@ -1316,13 +1323,21 @@ func (c *Controller) syncHandler(key string) (Result, error) {

// 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))
// Only create the user(s) until minio is ready
if tenant.Status.HealthStatus == "green" {
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, UsersCreatedFailedReason, fmt.Sprintf("Users creation failed: %s", err))
// retry after 5sec
return WrapResult(Result{RequeueAfter: time.Second * 5}, nil)
}
c.recorder.Event(tenant, corev1.EventTypeNormal, "UsersCreated", "Users created")
} else {
c.updateTenantStatus(ctx, tenant, StatusWaitingMinIOIsHealthy, 0)
c.recorder.Event(tenant, corev1.EventTypeWarning, WaitingMinIOIsHealthyReason, fmt.Sprintf("Waiting for MinIO to be ready prior creating any user: %s", err))
// retry after 5sec
return WrapResult(Result{RequeueAfter: time.Second * 5}, nil)
}
c.recorder.Event(tenant, corev1.EventTypeNormal, "UsersCreated", "Users created")
}

// Ensure we are only creating the bucket
Expand Down

0 comments on commit 831f841

Please sign in to comment.