diff --git a/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs b/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs index 4d97842d8..e2540482f 100644 --- a/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs +++ b/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs @@ -9,6 +9,11 @@ public abstract class MetaObjectLock : ILock private readonly string identity; private T metaObjCache; + /// + /// OnHttpError is called when there is a http operation error. + /// + public event Action OnHttpError; + protected MetaObjectLock(IKubernetes client, string @namespace, string name, string identity) { this.client = client ?? throw new ArgumentNullException(nameof(client)); @@ -47,8 +52,9 @@ public async Task CreateAsync(LeaderElectionRecord record, CancellationTok Interlocked.Exchange(ref metaObjCache, createdObj); return true; } - catch (HttpOperationException) + catch (HttpOperationException e) { + OnHttpError?.Invoke(e); // ignore } @@ -79,8 +85,9 @@ public async Task UpdateAsync(LeaderElectionRecord record, CancellationTok Interlocked.Exchange(ref metaObjCache, replacedObj); return true; } - catch (HttpOperationException) + catch (HttpOperationException e) { + OnHttpError?.Invoke(e); // ignore }