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

added connection and retry options for jsm client #408

Conversation

astelmashenko
Copy link
Member

Proposed Changes

  • 🎁 Add new feature

The PR introduces reconnect options, connection handler to log in case of connection lost or reconnect attempts finished. In case it could not reconnect it halts dispatcher, so k8s can restart it.

Release Note

Add additional connection options:
config-nats ConfigMap supports the next parameters: connOpts.retryOnFailedConnect, maxReconnects, reconnectWait

see docs/jetstream.md for details

@knative-prow knative-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 29, 2023
@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

Merging #408 (da7c0b1) into main (030b206) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #408   +/-   ##
=======================================
  Coverage   38.97%   38.97%           
=======================================
  Files          29       29           
  Lines        1919     1919           
=======================================
  Hits          748      748           
  Misses       1125     1125           
  Partials       46       46           

@astelmashenko
Copy link
Member Author

/assign @dan-j

@knative-prow
Copy link

knative-prow bot commented Jun 29, 2023

@astelmashenko: GitHub didn't allow me to assign the following users: dan-j.

Note that only knative-sandbox members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @dan-j

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@astelmashenko
Copy link
Member Author

@matzew , work is complete, ready for review. Are you going to review or should I assign somebody else (before I worked with Evan Anderson and Lionel Villard)?
Thanks

@astelmashenko
Copy link
Member Author

cc @dan-j

@astelmashenko
Copy link
Member Author

/assign @matzew

@astelmashenko
Copy link
Member Author

/assign @lionelvillard

@dan-j
Copy link
Contributor

dan-j commented Jul 4, 2023

Apologies, just caught up on notifications and seen this. Changes seem sensible, thanks for the contribution!

I'm not sure I have permissions to lgtm/approve but trying anyway

/lgtm
/approve

@knative-prow
Copy link

knative-prow bot commented Jul 4, 2023

@dan-j: changing LGTM is restricted to collaborators

In response to this:

Apologies, just caught up on notifications and seen this. Changes seem sensible, thanks for the contribution!

I'm not sure I have permissions to lgtm/approve but trying anyway

/lgtm
/approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@astelmashenko
Copy link
Member Author

@evankanderson , could you please review and put lgtm label?

@astelmashenko
Copy link
Member Author

/lgtm

@knative-prow
Copy link

knative-prow bot commented Jul 6, 2023

@astelmashenko: you cannot LGTM your own PR.

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Comment on lines 82 to 83
// reconnection options
if config.ConnOpts.RetryOnFailedConnect {
Copy link
Member

Choose a reason for hiding this comment

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

I think you need to check for config.ConnOpts != nil

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 74 to 75
// ReconnectWait time between reconnects in milliseconds
ReconnectWait time.Duration `json:"reconnectWait,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Usually, Kubernetes recommends to have the unit in the name: https://github.com/zecke/Kubernetes/blob/master/docs/devel/api-conventions.md#units and the type being just int the reason being, time.Duration is a Go only type and format, so it limits the client that can easily use the API

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 93 to 95
if attempts < 5 {
logger.Infof("Attempts left: %d", config.ConnOpts.MaxReconnects-attempts)
}
Copy link
Member

Choose a reason for hiding this comment

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

Why is 5 hardcoded here?

Copy link
Member Author

@astelmashenko astelmashenko Jul 7, 2023

Choose a reason for hiding this comment

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

This is just to show 5 last messages of recconnecting attepmts. Should I give it a name, make it debug and log everything or just remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@pierDipi
Copy link
Member

pierDipi commented Jul 7, 2023

@astelmashenko @dan-j Regarding lgtm and approve permissions, we can give you them if there is interest, also because you're the one maintaining the Eventing with Nats integration, would you be interested in that?

@astelmashenko
Copy link
Member Author

@astelmashenko @dan-j Regarding lgtm and approve permissions, we can give you them if there is interest, also because you're the one maintaining the Eventing with Nats integration, would you be interested in that?

I'm already able to lgtm/approve. Dan-j was going to apply for that as well.

@astelmashenko
Copy link
Member Author

@pierDipi , could you please take a look. I've addressed all the comments.

@pierDipi
Copy link
Member

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 11, 2023
@pierDipi
Copy link
Member

/approve

@knative-prow
Copy link

knative-prow bot commented Jul 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: astelmashenko, dan-j, pierDipi

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

The pull request process is described 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

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 11, 2023
@knative-prow knative-prow bot merged commit 4b73aaa into knative-extensions:main Jul 11, 2023
@astelmashenko astelmashenko deleted the feature/jsm-connection-options branch July 12, 2023 06:39
@astelmashenko
Copy link
Member Author

/cherrypick main

@knative-prow-robot
Copy link
Contributor

@astelmashenko: base branch (main) needs to differ from target branch (main)

In response to this:

/cherrypick main

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants