-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
ResourceWatcher reconnection fixes #523
Conversation
… ObjectDisposedException after leader reelections
…e void OnException(Exception e)
I think that the subscription from the ctor should be also moved to _reconnectSubscription =
_reconnectHandler
.Select(Observable.Timer)
.Switch()
.Retry()
.Subscribe(async _ => await WatchResource(), error => _logger.LogError(error, $"There was an error while restarting the resource watcher {typeof(TEntity)}")); The reconnect subscription should be either recreated on each Let me know please which one is the preferred solution and I can do it, too. Thx. EDIT: For now I moved the disposal of |
Hey @tomasfabian Would you mind to add a test case for this scenario? It should be fairly easy to add a test where you call the sequence of methods as mentioned in the issue and this PR and see if the await method throws an error. Thank you for the contribution! |
Hello @buehler, What do you think / suggest? |
I can introduce a new interface public interface IResourceWatcherMetrics<TEntity> : IResourceWatcherMetrics
where TEntity : IKubernetesObject<V1ObjectMeta>
{
}
public interface IResourceWatcherMetrics
{
IGauge Running { get; }
// Gauge.Child Running { get; }
ICounter WatchedEvents { get; }
// Counter.Child WatchedEvents { get; }
ICounter WatcherExceptions { get; }
// Counter.Child WatcherExceptions { get; }
ICounter WatcherClosed { get; }
// Counter.Child WatcherClosed { get; }
}
internal class ResourceWatcherMetrics<TEntity> : IResourceWatcherMetrics<TEntity>
where TEntity : IKubernetesObject<V1ObjectMeta>
{
// ...
} And then in the Services.AddSingleton(typeof(IResourceWatcherMetrics<>), typeof(ResourceWatcherMetrics<>));
// Services.AddSingleton(typeof(ResourceWatcherMetrics<>)); Thx |
Ahh I see, yeah, you're right. No, then we'll leave it this way. If there is another issue with this matter, we can introduce an internal interface for this and add tests. |
Removed disposal of
_reconnectHandler
inResourceWatcher
which causesObjectDisposedException
after leader reelections and the watcher stops observing the resource. #522The situation happens after a consecutive call to
StartAsync
afterStopAsync
:The
_reconnectHandler
should be disposed only in the if statement of the Disposing method:Thx