Skip to content

Fix topology view when displaying mixed connect-native/normal services.#13023

Merged
kisunji merged 3 commits intohashicorp:mainfrom
apollo13:mixed-service-topology
Jul 31, 2023
Merged

Fix topology view when displaying mixed connect-native/normal services.#13023
kisunji merged 3 commits intohashicorp:mainfrom
apollo13:mixed-service-topology

Conversation

@apollo13
Copy link
Copy Markdown
Contributor

Description

If a service is registered twice, once with connect-native and once
without, the topology views would prune the existing intentions. This
change brings the code more in line with the transparent proxy behavior.

PR Checklist

  • updated test coverage
  • external facing docs updated
  • not a security concern
  • checklist folder consulted

@apollo13 apollo13 force-pushed the mixed-service-topology branch from 377860f to 94f1d38 Compare May 11, 2022 15:36
@apollo13 apollo13 marked this pull request as ready for review May 11, 2022 15:39
@apollo13
Copy link
Copy Markdown
Contributor Author

@kisunji This is a follow up to #12098 -- would be great if you could give that a review

@Amier3
Copy link
Copy Markdown
Contributor

Amier3 commented Jun 14, 2022

Hey @apollo13

Hope you're doing well! Apologies for the delayed review on this, looks like it slipped through the cracks. We'll get this triaged shortly! 😄

@apollo13
Copy link
Copy Markdown
Contributor Author

@Amier3 Friendly ping :) any chance of a review?

@apollo13
Copy link
Copy Markdown
Contributor Author

apollo13 commented Oct 7, 2022

Hi @Amier3, @kisunji. Any chance of a review? I realize that this is a small fix in the grand scheme of things, but nevertheless would improve traefik integration quite a bit.

@kisunji
Copy link
Copy Markdown
Contributor

kisunji commented Oct 11, 2022

Hi @apollo13, I don't have the bandwidth to review at this time. If you could describe what the bug is that you are trying to fix (maybe replication steps if it is simple enough) it might help future reviewers understand what behavioral change you are making here.

@apollo13
Copy link
Copy Markdown
Contributor Author

Ok, here is a reproducer:
cfg.zip
Start with: consul agent -dev -config-dir=cfg

With the current main branch one will get the following result:
Screenshot 2022-10-12 at 12-40-35 crm - Consul

with my patch it properly shows the connection as allowed via intentions:
Screenshot 2022-10-12 at 12-41-15 crm - Consul

@apollo13
Copy link
Copy Markdown
Contributor Author

@Amier3 Any chance to get someone to review this?

@apollo13 apollo13 force-pushed the mixed-service-topology branch from c53330a to 4e3320e Compare February 27, 2023 21:02
@dod-ia
Copy link
Copy Markdown

dod-ia commented Jun 28, 2023

I'm interested by seeing this commit validated to fix #14795

@apollo13 apollo13 force-pushed the mixed-service-topology branch from 4e3320e to bf3f5ff Compare July 20, 2023 08:50
@apollo13
Copy link
Copy Markdown
Contributor Author

@kisunji I have rebased the code. Any chance you or someone else could spare the time to review this?

@apollo13 apollo13 force-pushed the mixed-service-topology branch from bf3f5ff to c564e8c Compare July 28, 2023 15:26
@apollo13 apollo13 force-pushed the mixed-service-topology branch from 4b83eb6 to c772b45 Compare July 28, 2023 17:16
@kisunji kisunji added the backport/1.16 This release series is no longer active on CE. Use backport/ent/1.16. label Jul 28, 2023
@kisunji kisunji force-pushed the mixed-service-topology branch from c772b45 to abbea8f Compare July 28, 2023 20:00
@kisunji kisunji changed the title Fix topoloy intention with mixed connect-native/normal services. Fix topology view when displaying mixed connect-native/normal services. Jul 28, 2023
Copy link
Copy Markdown
Contributor

@kisunji kisunji left a comment

Choose a reason for hiding this comment

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

Looks good 👍 Please consider my feedback on the changelog and perhaps test locally to ensure things still look as expected.

If a service is registered twice, once with connect-native and once
without, the topology views would prune the existing intentions. This
change brings the code more in line with the transparent proxy behavior.
@apollo13 apollo13 force-pushed the mixed-service-topology branch from 2bbb1a3 to efa5a6b Compare July 28, 2023 20:06
@apollo13
Copy link
Copy Markdown
Contributor Author

Thank you for your help! I have squashed the commits to reduce the noise (the later commits where just small fixes anyways) and will test if it works correctly (aside from the tests) over the weekend.

ServiceSummary: ServiceSummary{
Name: "cproxy",
Datacenter: "dc1",
Tags: []string{"http", "https"},
Copy link
Copy Markdown
Contributor Author

@apollo13 apollo13 Jul 29, 2023

Choose a reason for hiding this comment

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

@kisunji I found a possible bug here. http and it's service-id cproxy-http is not connect enabled. Should this tag show up here then or not? Only cproxy-https with the tag https is connect enabled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

And I guess Nodes below could get deduped as well like it is done for the tags:

for _, tag := range svc.Tags {
?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I pushed a commit to dedupe the nodes in this branch as well: bf3865f

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Regarding my first comment in this thread: For transparent proxies it is checked if all instances are in the same "state" (

consul/agent/ui_endpoint.go

Lines 586 to 588 in 449e050

// Only consider the target service to be transparent when all its proxy instances are in that mode.
// This is done because the flag is used to display warnings about proxies needing to enable
// transparent proxy mode. If ANY instance isn't in the right mode then the warming applies.
). I guess it would make sense to apply a similar code connect-native services -- I will add code towards that end in another commit. If we think this should not be the case we revert / remove it easily again.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually I am leaning towards a service to be considered connect native if any of it's instances are. Connect native is not exactly the same as transparent proxies and allows for even more flexibility (like taking to only a subset of instances of a service which are connect enabled etc…). Will push a commit towards that goal.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep, I agree with your decision. Thanks for being thorough with the changes!

@apollo13
Copy link
Copy Markdown
Contributor Author

I have addressed the issues I ran over and successfully tested the changes in our cluster, jay :)

@kisunji kisunji merged commit 6ada2e0 into hashicorp:main Jul 31, 2023
@hc-github-team-consul-core
Copy link
Copy Markdown
Collaborator

1 similar comment
@hc-github-team-consul-core
Copy link
Copy Markdown
Collaborator

kisunji pushed a commit that referenced this pull request Jul 31, 2023
…s. (#13023)

* Fix topoloy intention with mixed connect-native/normal services.

If a service is registered twice, once with connect-native and once
without, the topology views would prune the existing intentions. This
change brings the code more in line with the transparent proxy behavior.

* Dedupe nodes in the ServiceTopology ui endpoint (like done with tags).

* Consider a service connect-native as soon as one instance is.
kisunji pushed a commit that referenced this pull request Jul 31, 2023
…l services. (#18330)

Fix topology view when displaying mixed connect-native/normal services. (#13023)

* Fix topoloy intention with mixed connect-native/normal services.

If a service is registered twice, once with connect-native and once
without, the topology views would prune the existing intentions. This
change brings the code more in line with the transparent proxy behavior.

* Dedupe nodes in the ServiceTopology ui endpoint (like done with tags).

* Consider a service connect-native as soon as one instance is.

Co-authored-by: Florian Apolloner <[email protected]>
@apollo13
Copy link
Copy Markdown
Contributor Author

apollo13 commented Jul 31, 2023 via email

@apollo13 apollo13 deleted the mixed-service-topology branch September 1, 2023 16:41
asheshvidyut added a commit that referenced this pull request Sep 4, 2023