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

feat(kuma-cp) KDS multiplexer #917

Merged
merged 9 commits into from
Jul 22, 2020
Merged

feat(kuma-cp) KDS multiplexer #917

merged 9 commits into from
Jul 22, 2020

Conversation

lobkovilya
Copy link
Contributor

Summary

This PR is an enhancement of existing KDS protocol, it allows Remote CP and Global CP to utilize the same grpc-stream under the hood. Thanks to that enhancement we can get rid of GlobalLbAddress and RemoteLbAddresses.

Current PR doesn't update kuma-cp.config.

Full changelog

  • mux.proto for multiplexing
  • ZoneResource is cluster scope (not namespace scope)

Issues resolved

Fix #XXX

Documentation

@lobkovilya lobkovilya requested a review from a team as a code owner July 21, 2020 05:12
Copy link
Contributor

@nickolaev nickolaev 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!

@@ -10,7 +10,7 @@ spec:
names:
kind: Zone
plural: zones
scope: ""
scope: Cluster
Copy link
Contributor

Choose a reason for hiding this comment

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

Good!

kdsStream := client.NewKDSStream(session.ClientStream(), session.PeerID())
zone := &system.ZoneResource{}
if err := rt.ReadOnlyResourceManager().Get(context.Background(), zone, store.GetByKey(session.PeerID(), "default")); err != nil {
// send error back to Remote CP, it will re-try later when ZoneResource will appear
Copy link
Contributor

Choose a reason for hiding this comment

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

That looks very robust!

Copy link
Contributor

Choose a reason for hiding this comment

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

and what are the conditions of retries? Is it retried immediately? 1s? exponential retry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends on ResilientComponent that wraps KDSClient. By default backoff time is 5 sec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exponential is actually a good idea, probably I should implement it

err = errors.New("timeout waiting for ServerStream.Recv()")
}
Expect(err).ToNot(HaveOccurred())
})
Copy link
Contributor

Choose a reason for hiding this comment

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

How about this

It("should block while proper Send called", func(done Done) {
    go func() {
        request, err := serverSession.ServerStream().Recv()
        Expect(err).ToNot(HaveOccurred())
        Expect(request.VersionInfo).To(Equal("1"))
        close(done)
    }()
    err := clientSession.ServerStream().Send(&envoy_api_v2.DiscoveryResponse{VersionInfo: "2"})
    Expect(err).ToNot(HaveOccurred())
    err = clientSession.ClientStream().Send(&envoy_api_v2.DiscoveryRequest{VersionInfo: "1"})
    Expect(err).ToNot(HaveOccurred())

    resp, err := serverSession.ClientStream().Recv()
    Expect(err).ToNot(HaveOccurred())
    Expect(resp.VersionInfo).To(Equal("2"))
}, "1s")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, much better! Didn't know about done Done

@jakubdyszkiewicz
Copy link
Contributor

What is the UX if user is trying to connect to Global CP, but Zone is not present? If I was reading PR correctly, we will terminate such connection, but what is the error message in Remote? We should state that in order to connect Remote to Global, you need to add Zone resource

@lobkovilya
Copy link
Contributor Author

@jakubdyszkiewicz you are right, now in Remote there is an error every 5 sec ZoneResource doesn't exist. The message should have some sort of instructions on how to add ZoneResource. Also discussed to create command kumactl generate zone for Remote, which will generate ZoneResource based on Ingress address.

@lobkovilya lobkovilya force-pushed the feat/kds-multiplexer branch from cbdb2b8 to dcbc89e Compare July 22, 2020 09:27
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
@lobkovilya lobkovilya merged commit 544d5a8 into master Jul 22, 2020
@lobkovilya lobkovilya deleted the feat/kds-multiplexer branch July 29, 2020 13:59
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