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

Add Disconnect call in Reconcile #296

Merged
merged 2 commits into from
Dec 2, 2021

Conversation

vaspahomov
Copy link
Contributor

Description of your changes

I've add Disconnect call in end of Reconcile.
Some sdks required Close call after use. But I still want to create sdk in Connect call rather then create sdk in each Observe, Create, Update, Delete. And it's not possible to dispose sdk in the end of Reconcile.

I have:

  • Read and followed Crossplane's [contribution process].
  • Run make reviewable test to ensure this PR is ready for review.

@vaspahomov vaspahomov force-pushed the feature/disconnect-in-reconcile branch from 6df5539 to a1ef79f Compare October 1, 2021 08:50
@negz negz requested a review from muvaf October 11, 2021 20:25
@negz negz self-assigned this Oct 11, 2021
Copy link
Member

@negz negz left a comment

Choose a reason for hiding this comment

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

Thanks for raising this! Could you add a little more information about your use case - what SDK have you found that needs an explicit disconnect? I think I've run into a similar case in the past, but I can't remember what it was.

In general this approach looks good to me - could you please also update the PR description with information about how you've tested this, and add a unit test for the case in which the deferred Disconnect fails.

pkg/reconciler/managed/reconciler.go Outdated Show resolved Hide resolved
pkg/reconciler/managed/reconciler.go Outdated Show resolved Hide resolved
pkg/reconciler/managed/reconciler.go Show resolved Hide resolved
pkg/reconciler/managed/reconciler.go Outdated Show resolved Hide resolved
@vaspahomov vaspahomov force-pushed the feature/disconnect-in-reconcile branch from a1ef79f to 5296080 Compare October 12, 2021 07:46
@vaspahomov
Copy link
Contributor Author

what SDK have you found that needs an explicit disconnect?

I've found what yandex-cloud/go-sdk needs disconnect.
We need Shutdown call in Disconnect. Otherwise we'll face with connections leak.

@vaspahomov
Copy link
Contributor Author

Thanks for review! I've committed fixes

pkg/reconciler/managed/reconciler.go Outdated Show resolved Hide resolved
pkg/reconciler/managed/reconciler.go Show resolved Hide resolved
Signed-off-by: vaspahomov <vas2142553@gmail.com>
@vaspahomov vaspahomov force-pushed the feature/disconnect-in-reconcile branch from 5296080 to 8af1fca Compare October 28, 2021 10:22
Signed-off-by: vaspahomov <vas2142553@gmail.com>
@vaspahomov vaspahomov force-pushed the feature/disconnect-in-reconcile branch from 8af1fca to a5ff67d Compare October 28, 2021 10:25
if disconnectErr := r.external.Disconnect(ctx); disconnectErr != nil {
log.Debug("Cannot disconnect from provider", "error", disconnectErr)
record.Event(managed, event.Warning(reasonCannotDisconnect, disconnectErr))
managed.SetConditions(xpv1.ReconcileError(errors.Wrap(disconnectErr, errReconcileDisconnect)))
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 this SetCondition call might cause flapping/overwritten conditions in cases where the deferred function is called because we're returning from another error case where we would also update the same condition. I'll fix this up in a future PR though.

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.

2 participants