Skip to content

Commit 79646b3

Browse files
authored
fix: ensure ResourceWatcher reconnection (#523)
Removed disposal of `_reconnectHandler` in `ResourceWatcher` which causes `ObjectDisposedException` after [leader reelections](https://github.com/buehler/dotnet-operator-sdk/blob/a2290ff9edc41bbbb3a7b47a13a00c99e469f8f9/src/KubeOps/Operator/Controller/ResourceControllerManager.cs#L45) and the watcher stops observing the resource. This fixes #522.
1 parent 09946f2 commit 79646b3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/KubeOps/Operator/Kubernetes/ResourceWatcher{TEntity}.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ private void Disposing(bool fromStop)
7373
{
7474
_watchEvents.Dispose();
7575
_reconnectHandler.Dispose();
76+
_reconnectSubscription.Dispose();
7677
}
7778

78-
_reconnectHandler.Dispose();
79-
_reconnectSubscription.Dispose();
79+
_resetReconnectCounter?.Dispose();
80+
8081
if (_cancellation?.IsCancellationRequested == false)
8182
{
8283
_cancellation.Cancel();
@@ -195,8 +196,6 @@ e.InnerException is JsonException &&
195196
.Timer(TimeSpan.FromMinutes(1))
196197
.FirstAsync()
197198
.Subscribe(_ => _reconnectAttempts = 0);
198-
199-
_reconnectHandler.OnNext(backoff);
200199
}
201200
catch (Exception exception)
202201
{

0 commit comments

Comments
 (0)