fix: queue-operator dropped reconcile namespace and overflowed hash-range status

main.go called Reconcile(ctx, req.Name) without req.Namespace, so the
Get against the namespaced Queue CRD always 404'd and was silently
swallowed as success -- no shard topics or Redis state were ever created.

Separately, ShardStatus.HashRangeStart/End were uint32, but controller-gen
maps that to OpenAPI format:int32, whose max (2147483647) is smaller than
FullHashRangeEnd (0xFFFFFFFF), so the apiserver rejected every status
update with the (misleadingly empty-looking) "must be of type integer with
format int32" error. Widened to int64, regenerated the CRD, and synced the
chart's bundled copy.
This commit is contained in:
riotpiaole
2026-06-22 12:23:23 -07:00
parent 173a4935ab
commit 9fa5420b22
7 changed files with 40 additions and 31 deletions
+7 -7
View File
@@ -57,14 +57,14 @@ func (r *QueueReconciler) now() time.Time {
}
// Reconcile implements the controller-runtime reconcile loop.
func (r *QueueReconciler) Reconcile(ctx context.Context, name string) error {
func (r *QueueReconciler) Reconcile(ctx context.Context, namespace, name string) error {
var queue kmsvcv1.Queue
err := r.Client.Get(ctx, client.ObjectKey{Name: name}, &queue)
err := r.Client.Get(ctx, client.ObjectKey{Namespace: namespace, Name: name}, &queue)
if apierrors.IsNotFound(err) {
return nil
}
if err != nil {
return fmt.Errorf("get queue %s: %w", name, err)
return fmt.Errorf("get queue %s/%s: %w", namespace, name, err)
}
if !queue.DeletionTimestamp.IsZero() {
@@ -113,8 +113,8 @@ func (r *QueueReconciler) newShard(id, parentID string, start, end uint32, queue
return kmsvcv1.ShardStatus{
ID: id,
Topic: kafka.ShardTopicName(queue.Name, queue.Spec.FIFOQueue, id),
HashRangeStart: start,
HashRangeEnd: end,
HashRangeStart: int64(start),
HashRangeEnd: int64(end),
Phase: kmsvcv1.ShardPhaseActive,
ParentID: parentID,
CreatedAt: metav1.NewTime(r.now()),
@@ -168,8 +168,8 @@ func (r *QueueReconciler) publishRedisState(ctx context.Context, queue *kmsvcv1.
shards = append(shards, kafka.Shard{
ID: s.ID,
Topic: s.Topic,
HashRangeStart: s.HashRangeStart,
HashRangeEnd: s.HashRangeEnd,
HashRangeStart: uint32(s.HashRangeStart),
HashRangeEnd: uint32(s.HashRangeEnd),
Phase: string(s.Phase),
})
}