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

chore(kuma-cp) migrate DiscoveryRequest/Response in KDS to V3 #2541

Merged
merged 4 commits into from
Aug 11, 2021

Conversation

jakubdyszkiewicz
Copy link
Contributor

Summary

KDS is a protocol to exchange Kuma entities between Global and Zone CP.
It is based on xDS (we use go-control-plane), but instead of Envoy resources we put Kuma resources.
Right now we use DiscoveryRequest/Response V2, but V2 protos were removed from Go Control Plane so we need to migrate in order to upgrade Go Control Plane in the future.

The logical xDS definition looks like this

service KumaDiscoveryService {
  rpc StreamKumaResources(stream envoy.service.discovery.v3.DiscoveryRequest)
      returns (stream envoy.service.discovery.v3.DiscoveryResponse);
}

But we in case of KDS, both Global and Zone CPs are logical servers and clients. That's why we created mux.proto on top of this

service MultiplexService {
  rpc StreamMessage(stream Message) returns (stream Message);
}

message Message {
  oneof value {
    envoy.api.v2.DiscoveryRequest request = 1;
    envoy.api.v2.DiscoveryResponse response = 2;
  }
}

so on the wire, the real gRPC service is MultiplexService. Global is a real server and Zone is a real client, but logically under the hood - both are servers and clients.

Because KumaDiscoveryService is a logical service, I just migrated this to V3 protos.
In the real service I added new fields

message Message {
  oneof value {
    envoy.api.v2.DiscoveryRequest request = 1;
    envoy.api.v2.DiscoveryResponse response = 2;
    envoy.service.discovery.v3.DiscoveryRequest requestV3 = 3; # <- new
    envoy.service.discovery.v3.DiscoveryResponse responseV3 = 4; # <- new
  }
}

so new CP supports both V2 and V3 DiscoveryRequest.

We decide whether to send V2 or V3 proto on the wire, by a new gRPC MD header that we are sending.
Under the hood we convert between V2 and V3.

This way we can provide smooth migration. In the next major release, we can just remove the old request/response.

Full changelog

  • Implement support V3 DiscoveryRequest and DiscoveryResponse while keeping the compatibility with V2

Issues resolved

No Github issue.

Documentation

  • No docs

Testing

  • Unit tests
  • E2E tests (added a test with upgrade of CP)
  • Manual testing on Universal
  • Manual testing on Kubernetes

Backwards compatibility

  • Add backport-to-stable label if the code is backwards compatible. Otherwise, list breaking changes.

Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
api/mesh/v1alpha1/mux.proto Outdated Show resolved Hide resolved
pkg/kds/client/sink_test.go Outdated Show resolved Hide resolved
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
@codecov-commenter
Copy link

Codecov Report

Merging #2541 (fa4c5a2) into master (38bd1e7) will decrease coverage by 0.32%.
The diff coverage is 27.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2541      +/-   ##
==========================================
- Coverage   52.29%   51.97%   -0.33%     
==========================================
  Files         865      867       +2     
  Lines       48098    48235     +137     
==========================================
- Hits        25154    25069      -85     
- Misses      20912    21137     +225     
+ Partials     2032     2029       -3     
Impacted Files Coverage Δ
api/mesh/v1alpha1/kds.pb.go 35.21% <0.00%> (+8.32%) ⬆️
pkg/kds/mux/client.go 0.00% <0.00%> (ø)
pkg/kds/server/kds.go 100.00% <ø> (+44.44%) ⬆️
pkg/kds/server/status_tracker.go 0.00% <0.00%> (ø)
...atibility/cp_compatibility_kubernetes_multizone.go 0.00% <0.00%> (ø)
test/framework/setup.go 0.00% <0.00%> (ø)
pkg/kds/mux/version.go 12.96% <12.96%> (ø)
api/mesh/v1alpha1/mux.pb.go 21.92% <14.28%> (-0.62%) ⬇️
pkg/kds/mux/session.go 54.38% <33.33%> (-4.11%) ⬇️
pkg/kds/mux/clientstream.go 48.27% <69.23%> (+13.27%) ⬆️
... and 35 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 38bd1e7...fa4c5a2. Read the comment docs.

@jakubdyszkiewicz jakubdyszkiewicz merged commit 5752bd6 into master Aug 11, 2021
@jakubdyszkiewicz jakubdyszkiewicz deleted the chore/kds-v3 branch August 11, 2021 15:43
mergify bot pushed a commit that referenced this pull request Aug 11, 2021
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
(cherry picked from commit 5752bd6)

# Conflicts:
#	pkg/kds/cache/snapshot.go
#	pkg/kds/server/type_adjust_callbacks.go
jakubdyszkiewicz added a commit that referenced this pull request Aug 13, 2021
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
jakubdyszkiewicz pushed a commit that referenced this pull request Aug 13, 2021
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
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

3 participants