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

✨ enable grpc keepalive. #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

morvencao
Copy link
Member

@morvencao morvencao commented Jul 19, 2024

Summary

This PR introduces keepalive parameters to the cloudevents client using gRPC. By default, these parameters are disabled. Users can optionally enable it to detect broken gRPC connections. MQTT has similar feature to detect the half-open connection.

Related issue(s)

Fixes #

@openshift-ci openshift-ci bot requested review from deads2k and qiujian16 July 19, 2024 04:33
@morvencao morvencao force-pushed the br_enable_grpc_keepalive branch from 127f758 to a512ec8 Compare July 19, 2024 05:48
@morvencao
Copy link
Member Author

/assign @qiujian16 @skeeey


// PermitWithoutStream determines if keepalive pings are sent when there are no active RPCs.
// If false, pings are not sent and Time and Timeout are ignored. Default is false.
PermitWithoutStream bool `json:"permitWithoutStream,omitempty" yaml:"permitWithoutStream,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

what is the different with the enable? if we set enable=true and permitwithoutstream=false, what happens?

Copy link
Member Author

@morvencao morvencao Jul 19, 2024

Choose a reason for hiding this comment

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

enable is the global flag to control whether enable keepalive or not, while permitwithoutstream is grpc keepalive parameter to control whether the client should send keepalive pings even with no active RPCs, see: https://pkg.go.dev/google.golang.org/grpc/keepalive#ClientParameters

if we set enable=true and permitwithoutstream=false, the keep alive will be enabled, but it will not send ping if no rpc streaming (for example, no client is subscribing to resource status using grpc stream).

Copy link
Member

Choose a reason for hiding this comment

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

so we may enable this by default? because we generally need a subscription

Copy link
Member Author

Choose a reason for hiding this comment

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

Will raise another PR in maestro to enable this.

type KeepAliveConfig struct {
// Enable specifies whether the keepalive option is enabled.
// When disabled, other keepalive configurations are ignored. Default is false.
Enable bool `json:"enable,omitempty" yaml:"enable,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Under what cases should we enable this?

Copy link
Member Author

@morvencao morvencao Jul 19, 2024

Choose a reason for hiding this comment

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

If we want to quick detect the broken connection (for example, the broken connection caused by broken network), we can enable this.

When we enable the keepalive, client will send keeepalive pings with configured interval, if we can't receive ping response for a certain duration, the client will close the connection (state from READY to IDLE), and we have logic to recreate the cloudevents client once we detect the connection become IDLE.

Copy link
Member

Choose a reason for hiding this comment

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

so for our case, we may enable this by default?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will raise another PR in maestro to enable this.

Copy link

openshift-ci bot commented Aug 12, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: morvencao
Once this PR has been reviewed and has the lgtm label, please ask for approval from qiujian16. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: morvencao <[email protected]>
@morvencao morvencao force-pushed the br_enable_grpc_keepalive branch from 37faf51 to 3937d37 Compare August 12, 2024 03:29
@morvencao
Copy link
Member Author

/assign @qiujian16

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.

4 participants