mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 20:23:39 +09:00
fix(workloadmonitor): keep a bucket not ready until its claim is provisioned
A bucket WorkloadMonitor has no pods and minReplicas 0, so it stayed operational, and the Bucket app stayed Ready, while its BucketClaim was never provisioned. A tenant whose nearest S3 ancestor runs no SeaweedFS gets a claim for a bucket class that does not exist, and the dashboard showed a ready bucket that was never created. Assisted-by: LLM Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
This commit is contained in:
1 parent
94ada11eef
commit
9d33037566
3 files changed
+168
-3
No files matched your search
@@ -374,6 +374,25 @@ func (r *WorkloadMonitorReconciler) isBucketClaimReady(bc *cosiv1alpha1.BucketCl
|
||||
return bc.Status.BucketReady
|
||||
}
|
||||
|
||||
// bucketClaimsMessage names every BucketClaim that has not been provisioned,
|
||||
// with its bucket class, and is empty when there is none.
|
||||
func (r *WorkloadMonitorReconciler) bucketClaimsMessage(claims []cosiv1alpha1.BucketClaim) string {
|
||||
var pending []string
|
||||
for i := range claims {
|
||||
bc := &claims[i]
|
||||
if r.isBucketClaimReady(bc) {
|
||||
continue
|
||||
}
|
||||
entry := fmt.Sprintf("BucketClaim %s is not provisioned", bc.Name)
|
||||
if bc.Spec.BucketClassName != "" {
|
||||
entry = fmt.Sprintf("BucketClaim %s of bucket class %s is not provisioned", bc.Name, bc.Spec.BucketClassName)
|
||||
}
|
||||
pending = append(pending, entry)
|
||||
}
|
||||
sort.Strings(pending)
|
||||
return strings.Join(pending, "; ")
|
||||
}
|
||||
|
||||
// isServiceReady checks if the service has an external IP bound
|
||||
func (r *WorkloadMonitorReconciler) isServiceReady(svc *corev1.Service) bool {
|
||||
return len(svc.Status.LoadBalancer.Ingress) > 0
|
||||
@@ -1157,6 +1176,8 @@ func (r *WorkloadMonitorReconciler) Reconcile(ctx context.Context, req ctrl.Requ
|
||||
}
|
||||
}
|
||||
|
||||
bucketsMessage := r.bucketClaimsMessage(bucketClaimList.Items)
|
||||
|
||||
// Update WorkloadMonitor status based on observed pods
|
||||
monitor.Status.ObservedReplicas = observedReplicas
|
||||
monitor.Status.AvailableReplicas = availableReplicas
|
||||
@@ -1178,15 +1199,23 @@ func (r *WorkloadMonitorReconciler) Reconcile(ctx context.Context, req ctrl.Requ
|
||||
if fresh.Spec.MinReplicas != nil && availableReplicas < *fresh.Spec.MinReplicas {
|
||||
fresh.Status.Operational = pointer.Bool(false)
|
||||
}
|
||||
// Only the DataVolume check writes Message and Reason, so the stored ones
|
||||
// are the last DataVolume verdict: kept while no reader is installed yet, so a
|
||||
// controller restart does not report a stuck disk as ready.
|
||||
// A stored DataVolume verdict is the last one: kept while no reader is
|
||||
// installed yet, so a controller restart does not report a stuck disk as
|
||||
// ready. BucketClaims are listed on every pass, so their verdict is
|
||||
// recomputed and only fills fields no DataVolume verdict holds.
|
||||
if dataVolumesRead {
|
||||
fresh.Status.Message = dataVolumesMessage
|
||||
fresh.Status.Reason = ""
|
||||
if dataVolumesMessage != "" {
|
||||
fresh.Status.Reason = cozyv1alpha1.WorkloadMonitorReasonDataVolumeNotReady
|
||||
}
|
||||
} else if fresh.Status.Reason == cozyv1alpha1.WorkloadMonitorReasonBucketClaimNotReady {
|
||||
fresh.Status.Message = ""
|
||||
fresh.Status.Reason = ""
|
||||
}
|
||||
if fresh.Status.Message == "" && bucketsMessage != "" {
|
||||
fresh.Status.Message = bucketsMessage
|
||||
fresh.Status.Reason = cozyv1alpha1.WorkloadMonitorReasonBucketClaimNotReady
|
||||
}
|
||||
if fresh.Status.Message != "" {
|
||||
fresh.Status.Operational = pointer.Bool(false)
|
||||
|
||||
Reference in new issue
Block a user