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

Added list nodes for connect-capable service with endpoints #312

Conversation

JocelynVelarde
Copy link
Contributor

@JocelynVelarde JocelynVelarde commented Apr 5, 2024

Changes made

  1. Added GET /health/connect/:service into Health.cs
  2. Included new endpoints into IHealthEndpoint.cs

Issue ticket number and link

Refers to issue #311

Next tasks

  • Write corresponding tests

@JocelynVelarde JocelynVelarde changed the title Added list nodes for connect-capable service, included new endpoints Added list nodes for connect-capable service with endpoints Apr 5, 2024
@JocelynVelarde
Copy link
Contributor Author

Hello! I would appreciate some feedback/review regarding this new endpoint support. 🐝

Copy link
Contributor

@marcin-krystianc marcin-krystianc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JocelynVelarde,

Thank you for raising this PR. I've left a comment regarding the importance of maintaining backward compatibility and avoiding unnecessary logic in our library. Apart from that, could you please implement tests for the new API that is being introduced?

Consul/Health.cs Outdated
Comment on lines 307 to 316
switch (healthType)
{
case "connectHealth":
path = "/v1/health/connect/{0}";
break;
default:
path = "/v1/health/service/{0}";
break;
}
var req = _client.Get<ServiceEntry[]>(string.Format(path, service), q, filter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that the documentation mentions that the connect and service endpoints are nearly identical, but I don't think it's a good idea to rely on that. I would rather split this into two separate implementations, one for connect and one for service endpoints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okei noted, so instead of implementing the switch case, I should implement as a separate entity?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okei noted, so instead of implementing the switch case, I should implement as a separate entity?

yes, I think it is going to be better that way.

@@ -36,7 +36,9 @@ public interface IHealthEndpoint
Task<QueryResult<ServiceEntry[]>> Service(string service, string tag, CancellationToken ct = default);
Task<QueryResult<ServiceEntry[]>> Service(string service, string tag, bool passingOnly, CancellationToken ct = default);
Task<QueryResult<ServiceEntry[]>> Service(string service, string tag, bool passingOnly, QueryOptions q, CancellationToken ct = default);
Task<QueryResult<ServiceEntry[]>> Service(string service, string tag, bool passingOnly, QueryOptions q, Filter filter, CancellationToken ct = default);
Task<QueryResult<ServiceEntry[]>> Service(string service, string tag, bool passingOnly, QueryOptions q, Filter filter, string healthType, CancellationToken ct = default);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not ok, to change the public method signature in a way that makes it incompatible with previous versions.
If a new parameter is needed, then the new method overload needs to be added (without modifying the existing one).

Copy link
Contributor Author

@JocelynVelarde JocelynVelarde Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright so, leave the method signature as it was and just add a new one with the new parameter.

@JocelynVelarde
Copy link
Contributor Author

Hello! I was getting some errors with the BaseFixture.cs class, I was wondering if someone could explain why this is happening, greetings.

Copy link
Contributor

@marcin-krystianc marcin-krystianc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! I was getting some errors with the BaseFixture.cs class, I was wondering if someone could explain why this is happening, greetings.

Hi, I'm not sure which errors you mean exactly. I see that everything fails because the response is empty. I suggest have a look at Agent_Service_Register_With_Connect and see how to register service with a "connect" information.

@JocelynVelarde
Copy link
Contributor Author

Hello! I was getting some errors with the BaseFixture.cs class, I was wondering if someone could explain why this is happening, greetings.

Hi, I'm not sure which errors you mean exactly. I see that everything fails because the response is empty. I suggest have a look at Agent_Service_Register_With_Connect and see how to register service with a "connect" information.

From what I can see, Connect is equivalent to Service, except that Service will return the ones that are Connect-enabled. The new endpoint for Connect in Health.cs is correct? I just noticed that there is a Filter parameter that I was not using in the test request. Here
var checks = await _client.Health.Connect(svcID, "", false, QueryOptions.Default);
I'm not sure if this will fix the error.

@marcin-krystianc
Copy link
Contributor

Hello! I was getting some errors with the BaseFixture.cs class, I was wondering if someone could explain why this is happening, greetings.

Hi, I'm not sure which errors you mean exactly. I see that everything fails because the response is empty. I suggest have a look at Agent_Service_Register_With_Connect and see how to register service with a "connect" information.

From what I can see, Connect is equivalent to Service, except that Service will return the ones that are Connect-enabled. The new endpoint for Connect in Health.cs is correct? I just noticed that there is a Filter parameter that I was not using in the test request. Here var checks = await _client.Health.Connect(svcID, "", false, QueryOptions.Default); I'm not sure if this will fix the error.

I think, the key to properly test it is to create conenct-enabled service, e.g.:

            var destinationServiceRegistrationParameters = new AgentServiceRegistration
            {
                ID = destinationServiceID,
                Name = destinationServiceID,
                Port = 8000,
                Check = new AgentServiceCheck
                {
                    TTL = TimeSpan.FromSeconds(15)
                },
                Connect = new AgentServiceConnect
                {
                    SidecarService = new AgentServiceRegistration
                    {
                        Port = 8001
                    }
                }
            };

Copy link
Contributor

@marcin-krystianc marcin-krystianc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JocelynVelarde,

the changes look good now. and the tests are successful in the CI too. There is a small issue with GH reporting status to the RP though. Can you push another commit or two (e.g. add an empty line and remove it) maybe that will resolve the issue with tests statuses?

@marcin-krystianc
Copy link
Contributor

Hi @JocelynVelarde,

the changes look good now. and the tests are successful in the CI too. There is a small issue with GH reporting status to the RP though. Can you push another commit or two (e.g. add an empty line and remove it) maybe that will resolve the issue with tests statuses?

Nevermind, I closed and reopened the PR to trigger the workflow on the latest commit.

Comment on lines 160 to 163




Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ```suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the whitespaces on the last commit.

@marcin-krystianc
Copy link
Contributor

I think that the Catalog_GetNodesForMeshCapableService got flaky after adding the `Health_Connect' test.
We need to keep eye on it, if it is going to fail frequently, then we will need to investigate the root cause.

@marcin-krystianc marcin-krystianc merged commit 80c0fa8 into G-Research:master May 7, 2024
227 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants