Skip to content

Commit 1f20ff7

Browse files
author
cesnietor
committed
move requeueing to syncHealthCheckHandler function
1 parent 3281e38 commit 1f20ff7

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

pkg/controller/monitoring.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const (
3939
HealthReduceAvailabilityMessage = "Reduced Availability"
4040
)
4141

42-
func (c *Controller) updateHealthStatusForTenant(tenant *miniov2.Tenant) error {
42+
func (c *Controller) updateHealthStatusForTenant(tenant *miniov2.Tenant) (*miniov2.Tenant, error) {
4343
// don't get the tenant cluster health if it doesn't have at least 1 pool initialized
4444
oneInitialized := false
4545
for _, pool := range tenant.Status.Pools {
@@ -49,25 +49,25 @@ func (c *Controller) updateHealthStatusForTenant(tenant *miniov2.Tenant) error {
4949
}
5050
if !oneInitialized {
5151
klog.Infof("'%s/%s' no pool is initialized", tenant.Namespace, tenant.Name)
52-
return nil
52+
return tenant, nil
5353
}
5454

5555
tenantConfiguration, err := c.getTenantCredentials(context.Background(), tenant)
5656
if err != nil {
57-
return err
57+
return nil, err
5858
}
5959

6060
adminClnt, err := tenant.NewMinIOAdmin(tenantConfiguration, c.getTransport())
6161
if err != nil {
6262
klog.Errorf("Error instantiating adminClnt '%s/%s': %v", tenant.Namespace, tenant.Name, err)
63-
return err
63+
return nil, err
6464
}
6565

6666
aClnt, err := madmin.NewAnonymousClient(tenant.MinIOServerHostAddress(), tenant.TLS())
6767
if err != nil {
6868
// show the error and continue
6969
klog.Infof("'%s/%s': %v", tenant.Namespace, tenant.Name, err)
70-
return nil
70+
return tenant, nil
7171
}
7272
aClnt.SetCustomTransport(c.getTransport())
7373

@@ -79,7 +79,7 @@ func (c *Controller) updateHealthStatusForTenant(tenant *miniov2.Tenant) error {
7979
if err != nil {
8080
// show the error and continue
8181
klog.Infof("'%s/%s' Failed to get cluster health: %v", tenant.Namespace, tenant.Name, err)
82-
return nil
82+
return tenant, nil
8383
}
8484

8585
tenant.Status.DrivesHealing = int32(healthResult.HealingDrives)
@@ -98,7 +98,7 @@ func (c *Controller) updateHealthStatusForTenant(tenant *miniov2.Tenant) error {
9898
LabelSelector: fmt.Sprintf("%s=%s", miniov2.TenantLabel, tenant.Name),
9999
})
100100
if err != nil {
101-
return err
101+
return nil, err
102102
}
103103

104104
allPodsRunning := true
@@ -122,7 +122,7 @@ func (c *Controller) updateHealthStatusForTenant(tenant *miniov2.Tenant) error {
122122
if err != nil {
123123
// show the error and continue
124124
klog.Infof("'%s/%s' Failed to get storage info: %v", tenant.Namespace, tenant.Name, err)
125-
return nil
125+
return tenant, nil
126126
}
127127

128128
// Add back "Usable Capacity" & "Internal" values in Tenant Status and in the UI
@@ -205,13 +205,8 @@ func (c *Controller) updateHealthStatusForTenant(tenant *miniov2.Tenant) error {
205205
klog.Infof("'%s/%s' Can't update tenant status with tiers: %v", tenant.Namespace, tenant.Name, err)
206206
}
207207
}
208-
// Add tenant to the health check queue again until is green again
209-
if tenant.Status.HealthStatus != miniov2.HealthStatusGreen {
210-
key := fmt.Sprintf("%s/%s", tenant.GetNamespace(), tenant.Name)
211-
c.healthCheckQueue.Add(key)
212-
}
213208

214-
return nil
209+
return tenant, nil
215210
}
216211

217212
// HealthResult holds the results from cluster/health query into MinIO
@@ -244,10 +239,16 @@ func (c *Controller) syncHealthCheckHandler(key string) (Result, error) {
244239

245240
tenant.EnsureDefaults()
246241

247-
if err = c.updateHealthStatusForTenant(tenant); err != nil {
242+
tenant, err = c.updateHealthStatusForTenant(tenant)
243+
if err != nil {
248244
klog.Errorf("%v", err)
249245
return WrapResult(Result{}, err)
250246
}
251247

248+
// Add tenant to the health check queue again until is green again
249+
if tenant != nil && tenant.Status.HealthStatus != miniov2.HealthStatusGreen {
250+
c.healthCheckQueue.Add(key)
251+
}
252+
252253
return WrapResult(Result{}, nil)
253254
}

0 commit comments

Comments
 (0)