-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add Disconnect call in Reconcile #296
Conversation
6df5539
to
a1ef79f
Compare
There was a problem hiding this 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.
a1ef79f
to
5296080
Compare
I've found what yandex-cloud/go-sdk needs disconnect. |
Thanks for review! I've committed fixes |
Signed-off-by: vaspahomov <vas2142553@gmail.com>
5296080
to
8af1fca
Compare
Signed-off-by: vaspahomov <vas2142553@gmail.com>
8af1fca
to
a5ff67d
Compare
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))) |
There was a problem hiding this comment.
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.
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:
make reviewable test
to ensure this PR is ready for review.