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

fix(kuma-cp): Stop adding outbounds to dp for vips #2421

Merged
merged 3 commits into from
Jul 30, 2021

Conversation

lahabana
Copy link
Contributor

The mesh hash contains the vips which now ensures that the watchdog
will regenerate the xds config when needed.

This enables us to remove this extra outbounds in the dataplane resource
and simply generate the outbounds and the dns config in the dataplane_proxy_builder

Backwards compatibility

  • This change is significant enough to not be back-ported.

@lahabana lahabana requested a review from a team as a code owner July 23, 2021 13:37
@lahabana lahabana requested a review from lobkovilya July 23, 2021 13:38
@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2021

Codecov Report

Merging #2421 (eaf130a) into master (2bc0a3f) will decrease coverage by 0.00%.
The diff coverage is 50.98%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2421      +/-   ##
==========================================
- Coverage   52.55%   52.54%   -0.01%     
==========================================
  Files         878      877       -1     
  Lines       47904    47787     -117     
==========================================
- Hits        25177    25111      -66     
+ Misses      20680    20644      -36     
+ Partials     2047     2032      -15     
Impacted Files Coverage Δ
pkg/core/xds/types.go 89.65% <ø> (ø)
...gins/runtime/k8s/controllers/outbound_converter.go 67.16% <ø> (+7.16%) ⬆️
.../plugins/runtime/k8s/controllers/pod_controller.go 42.02% <0.00%> (+0.29%) ⬆️
pkg/plugins/runtime/universal/plugin.go 66.66% <ø> (ø)
pkg/xds/sync/dataplane_proxy_builder.go 0.00% <0.00%> (ø)
pkg/xds/sync/dataplane_watchdog.go 0.00% <0.00%> (ø)
pkg/xds/topology/dns.go 84.37% <71.42%> (ø)
...g/plugins/runtime/k8s/controllers/pod_converter.go 65.71% <100.00%> (ø)
pkg/xds/envoy/listeners/configurers.go 96.66% <100.00%> (ø)
pkg/xds/envoy/listeners/v3/dns_configurer.go 96.92% <100.00%> (-0.10%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2bc0a3f...eaf130a. Read the comment docs.

@lahabana
Copy link
Contributor Author

lahabana commented Jul 23, 2021

I think I'm doing this the wrong way. No need to review this :)

@lahabana lahabana force-pushed the fix/vipoutbound branch 2 times, most recently from 6dacf20 to eaf130a Compare July 27, 2021 12:29
The mesh hash contains the vips which now ensures that the watchdog
will regenerate the xds config when needed.

This enables us to remove this extra outbounds in the dataplane resource
and simply generate the outbounds and the dns config in the dataplane_proxy_builder

Signed-off-by: Charly Molter <charly.molter@konghq.com>
@lahabana
Copy link
Contributor Author

@lobkovilya now it's ready to review :)

Copy link
Contributor

@lobkovilya lobkovilya left a comment

Choose a reason for hiding this comment

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

Looks great, I like you got rid of plenty of code :) Just some minor comments

@@ -105,6 +108,26 @@ func (p *DataplaneProxyBuilder) resolveRouting(
return nil, nil, err
}

var domains []xds.VipDomains
outbounds := dataplane.Spec.Networking.Outbound
if dataplane.Spec.Networking.GetTransparentProxying() != nil && !dataplane.Spec.IsIngress() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this code won't run for Ingresses, so probably the check could be dropped

// resolve all the domains
domains, outbounds = xds_topology.VIPOutbounds(core_model.MetaToResourceKey(dataplane.Meta), meshContext.Dataplanes.Items, zoneIngresses.Items, dnsResolver.GetVIPs(), dnsResolver.GetDomain(), matchedExternalServices)

// Update the outbound of the dataplane with the vips
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really have to preserve the old VIPs? I think output we have from xds_topology.VIPOutbounds is sufficient so we can always do dataplane.Spec.Networking.Outbound = outbounds

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 believe this is preserving the non vip outbounds (In case a user defined outbounds in their dataplane resource).
What we do though is making sure we're not duplicating the outbounds in case there are still the generated ones in the resource.
WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh right, I forgot about non-vip outbounds on k8s :)

@@ -126,9 +126,15 @@ type Proxy struct {
Policies MatchedPolicies
}

type VipDomains struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we already have VIPOutbounds function, so probably better to name it VIPDomains?

}
}
func (g DNSGenerator) computeVIPs(proxy *core_xds.Proxy) map[string][]string {
meshedVips := map[string][]string{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why it became string -> []string instead of string -> string mapping? It seems like it always has an array with single element as a value:

meshedVips[domain] = []string{dnsOutbound.Address}

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'm actually squeezing a change here for supporting both ipv4 and ipv6 in the future (I can make that a different PR if you want).

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've actually removed the change. I'll do it when I need it

}
}
}
func (g DNSGenerator) computeVIPs(proxy *core_xds.Proxy) map[string][]string {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not really compute anymore, method became much simpler, it's just a conversion from []VipDomains to []map[domain]address, so maybe just toVIPs or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got rid of the method I think it's just more readable inline

Signed-off-by: Charly Molter <charly.molter@konghq.com>
@lahabana
Copy link
Contributor Author

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Jul 29, 2021

Command update: success

Branch has been successfully updated

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ lahabana
❌ mergify[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@lahabana lahabana requested a review from lobkovilya July 29, 2021 12:58
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

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

nice!

@lahabana lahabana merged commit d506d1d into kumahq:master Jul 30, 2021
@lahabana lahabana deleted the fix/vipoutbound branch March 29, 2024 12:26
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.

None yet

5 participants