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

Failing to identify leader when connecting to Azure EventHubs #1364

Closed
justinmchase opened this issue Feb 3, 2023 · 5 comments
Closed

Failing to identify leader when connecting to Azure EventHubs #1364

justinmchase opened this issue Feb 3, 2023 · 5 comments
Labels
backend Need a backend update enhancement New feature or request good first issue Good for newcomers

Comments

@justinmchase
Copy link
Contributor

Azure EventHubs has a "kafka projection" mode. It looks a lot like kafka but has some subtle differences I think.

When attempting to connect to eventhubs akhq has an error:

2023-02-03 22:53:57,298 [1 31mERROR[0 39m [35mr-thread-5[0 39m [36mi.m.h.server.RouteExecutor[0 39m Unexpected error occurred: Error encoding object [org.akhq.utils.ResultPagedList@691ab908] to JSON: Leader not found (through reference chain: org.akhq.utils.ResultPagedList["results"]->org.akhq.utils.PagedList[0]->org.akhq.models.Topic["partitions"]->java.util.ArrayList[0]->org.akhq.models.Partition["leader"])

Here is my configuration:

application.yaml

akhq:
  connections:
    kafka:
      properties:
        bootstrap.servers: "recovery-{{ .Values.global.envName }}.servicebus.windows.net:9093"
        security.protocol: SASL_SSL
        sasl.mechanism: PLAIN
        sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{{ .Values.global.AZURE_EVENT_HUBS_ENDPOINT }}";

https://github.com/tchiotludo/akhq/blob/dev/src/main/java/org/akhq/models/Partition.java#L40-L46

I believe this is the problem code, I belive that EventHubs is reporting that there are no replicas therefore the code to identify the leader is failing.

    public Node.Partition getLeader() {
        return nodes
            .stream()
            .filter(Node.Partition::isLeader)
            .findFirst()
            .orElseThrow(() -> new NoSuchElementException("Leader not found"));
    }

Since there are no replicas, the .findFirst() finds nothing. I'm assuming the fix will be to either add the partition itself to the nodes list in the case where there are no replicas, or to return this.id in the getLeader() function instead of throwing an exception.

@tchiotludo tchiotludo added enhancement New feature or request backend Need a backend update labels Feb 13, 2023
@tchiotludo tchiotludo added the good first issue Good for newcomers label Feb 13, 2023
@tchiotludo
Copy link
Owner

Event hub support can be cool, but I think it will break on other edge case, PR are welcome, closing due to duplicate of #657

@justinmchase
Copy link
Contributor Author

Can you elaborate on what other edge cases you're worried about? It seems like the fix to make it work with event hubs would be pretty simple and I can test it against local single-instance and also GCP cluster. But if you were to elaborate on edge cases I could probably try to take that into consideration.

@tchiotludo
Copy link
Owner

mostly I think on every specific feature like topic config / node config / compaction / etc ... that could not be implemented on event hub

@justinmchase
Copy link
Contributor Author

Ok as in, if this were fixed it may still experience more issues with EventHubs? You're not necessarily worried about this fix breaking non-EH systems?

@tchiotludo
Copy link
Owner

maybe you will see other issues with EH, but I'm not worried at all for all non EH broker, exactly

@justinmchase justinmchase changed the title Failing to identifier leader when connecting to Azure EventHubs Failing to identify leader when connecting to Azure EventHubs Feb 24, 2023
@tchiotludo tchiotludo moved this to Done in Backlog Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Need a backend update enhancement New feature or request good first issue Good for newcomers
Projects
Status: Done
Development

No branches or pull requests

2 participants