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

JetStream scaler should query the stream consumer leader when clustered #3860

Closed
rayjanoka opened this issue Nov 15, 2022 · 2 comments · Fixed by #3564
Closed

JetStream scaler should query the stream consumer leader when clustered #3860

rayjanoka opened this issue Nov 15, 2022 · 2 comments · Fixed by #3564
Assignees
Labels
bug Something isn't working

Comments

@rayjanoka
Copy link
Contributor

rayjanoka commented Nov 15, 2022

Report

I found that when running a cluster of nats pods, only the stream consumer's leader pod reports the accurate number of messages in the queue.

Expected Behavior

The scaler needs to identify the nats jetstream pod that is the selected stream's consumer leader to get the accurate metric.

Actual Behavior

The scaler is designed to connect to the general k8s svc endpoint so it will connect to a random nats server.

Steps to Reproduce the Problem

  1. Add messages to a jetstream queue, consume some of them, then add more
  2. Get the leader pod - nats consumer info test-stream durable
  3. Query each pod directly via the headless svc to get the number of pending messages
# Consumer Leader (accurate)
➜ curl -s "http://nats-1.nats.nats.svc.cluster.local:8222/jsz?consumers=true" | grep num_pending
              "num_pending": 0,

# Replicas (counting up only)
➜ curl -s "http://nats-0.nats.nats.svc.cluster.local:8222/jsz?consumers=true" | grep num_pending
              "num_pending": 6,
➜ curl -s "http://nats-2.nats.nats.svc.cluster.local:8222/jsz?consumers=true" | grep num_pending
              "num_pending": 6,

Logs from KEDA operator

No response

KEDA Version

2.8.1

Kubernetes Version

1.23

Platform

Any

Scaler Details

JetStream

Anything else?

No response

@rayjanoka rayjanoka added the bug Something isn't working label Nov 15, 2022
@tomkerkhove tomkerkhove moved this to Proposed in Roadmap - KEDA Core Nov 15, 2022
@rayjanoka
Copy link
Contributor Author

PR: #3564

@rayjanoka rayjanoka changed the title JetStream scaler metrics are only accurate from the stream's consumer leader JetStream scaler should query the stream consumer leader when clustered Nov 15, 2022
@rayjanoka
Copy link
Contributor Author

Includes a new e2e test to validate a 3-node nats jetstream cluster with stream configurations of 1, 2, and 3 stream replicas.

Repository owner moved this from Proposed to Ready To Ship in Roadmap - KEDA Core Dec 5, 2022
@JorTurFer JorTurFer moved this from Ready To Ship to Done in Roadmap - KEDA Core Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant