G-Research / consuldotnet

Consul.NET is a .NET client library for the Consul HTTP API
https://consuldot.net/
Apache License 2.0
322 stars 85 forks source link

List services gateway #321

Closed JocelynVelarde closed 2 months ago

JocelynVelarde commented 5 months ago

Changes made

  1. Added GET /v1/catalog/gateway-services/+gateway into Catalog.cs
  2. Included new endpoint into ICatalogEndpoint.cs
  3. Added possible test CatalogTest.cs (currently as a comment)

Issue ticket number and link

JocelynVelarde commented 5 months ago

Hello greetings! ☀️ I adapted the commented test, basing myself on the already implemented one from the Consul codebase. Still, I can see that I have to create a TerminatingGatewayConfigEntry struct. Is this necessary? Also, I was wondering what is the difference between Gateaway_ingress and Gateaway_terminating

marcin-krystianc commented 5 months ago

Gateaway_terminating

Hi,

I'm unsure, but perhaps there's no need to create a separate TerminatingGatewayConfigEntry. It might be possible to utilize the AgentService struct and assign the relevant ServiceKind value accordingly. As for the difference between ingress and terminating gateways, please refer to the documentation (https://developer.hashicorp.com/consul/docs/connect/gateways).

For our testing purposes, registering any ingress and terminating gateway and then querying it should suffice.

JocelynVelarde commented 4 months ago

Gateaway_terminating

Hi,

I'm unsure, but perhaps there's no need to create a separate TerminatingGatewayConfigEntry. It might be possible to utilize the AgentService struct and assign the relevant ServiceKind value accordingly. As for the difference between ingress and terminating gateways, please refer to the documentation (https://developer.hashicorp.com/consul/docs/connect/gateways).

For our testing purposes, registering any ingress and terminating gateway and then querying it should suffice.

OH great, would it look something like this?

 var terminatingGatewayService = new AgentService
    {
        ID = svcID + "-terminating",
        Service = svcID,
        Tags = new[] { "gateway", "terminating" },
        Port = 9090,
        Kind = ServiceKind.TerminatingGateway, 
    };
marcin-krystianc commented 4 months ago

I guess it might work, worth giving it a try.

JocelynVelarde commented 4 months ago

@marcin-krystianc I believe it is working now!

2 failing, 222 successful, and 3 skipped checks → on GitHub CLI

IvanKolchanov commented 3 months ago

@marcin-krystianc Hi, Marcin! I have picked up this issue for now and I just wanted to check up with you on what the state of the issue last was. I have been trying the code and for now it seems to me that during the test the gateaways fail to register completely or fail to register in time for when we check them. That is because when I run the tests the Catalog.Register requests return OK as well as /catalog/gateaway-services/..., however, the GateawayServices Response is Empty.

marcin-krystianc commented 2 months ago

@marcin-krystianc Hi, Marcin! I have picked up this issue for now and I just wanted to check up with you on what the state of the issue last was. I have been trying the code and for now it seems to me that during the test the gateaways fail to register completely or fail to register in time for when we check them. That is because when I run the tests the Catalog.Register requests return OK as well as /catalog/gateaway-services/..., however, the GateawayServices Response is Empty.

Yeah, as far I remember we couldn't figure out why the test procedure fails. It seems the registration is successful, i.e. the request returns Ok and in the Web UI (http://localhost:8500/) we could see it. But still the response is empty and the test fails. I think it is necessary to reach the consul community for some help.. Another option would be maybe trying to go's tests and seeing how they work.

IvanKolchanov commented 2 months ago

Yeah, as far I remember we couldn't figure out why the test procedure fails. It seems the registration is successful, i.e. the request returns Ok and in the Web UI (http://localhost:8500/) we could see it. But still the response is empty and the test fails. I think it is necessary to reach the consul community for some help.. Another option would be maybe trying to go's tests and seeing how they work.

Hmm, makes sense. How would we go about reaching out to the community? And I am not really sure if I understand the last part corrently. Do you mean trying to work out what we have different from the tests in the Golang client?

marcin-krystianc commented 2 months ago

Hmm, makes sense. How would we go about reaching out to the community? And I am not really sure if I understand the last part corrently. Do you mean trying to work out what we have different from the tests in the Golang client?

Regarding the community: I think Jocelyn already started a conversation in the consul project https://discuss.hashicorp.com/t/null-response-when-making-get-request-to-list-services-associated-with-a-gateway/67115/3.

Regarding the go tests, I mean that we can compare our tests with go client's tests and look for differences.

marcin-krystianc commented 2 months ago

Replaced with https://github.com/G-Research/consuldotnet/pull/347