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

fix: resource watcher restart on failure #765

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/KubeOps.Operator/Watcher/ResourceWatcher{TEntity}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ static async ValueTask CastAndDispose(IDisposable resource)

private async Task WatchClientEventsAsync(CancellationToken stoppingToken)
{
try
while (!stoppingToken.IsCancellationRequested)
{
while (!stoppingToken.IsCancellationRequested)
try
{
await foreach ((WatchEventType type, TEntity? entity) in client.WatchAsync<TEntity>(
settings.Namespace,
Expand Down Expand Up @@ -184,14 +184,14 @@ void LogReconciliationFailed(Exception exception)
}
}
}
}
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
{
// Don't throw if the cancellation was indeed requested.
}
catch (Exception e)
{
await OnWatchErrorAsync(e);
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
{
// Don't throw if the cancellation was indeed requested.
}
catch (Exception e)
{
await OnWatchErrorAsync(e);
}
}
}

Expand Down