From 4835a2c1d4bc1993781a9c1ed6cfec51dfe27449 Mon Sep 17 00:00:00 2001 From: Tim McCurdy Date: Fri, 13 Sep 2024 14:28:56 +0100 Subject: [PATCH 1/2] Added OnError event to MetaObjectLock --- .../LeaderElection/ResourceLock/MetaObjectLock.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs b/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs index 4d97842d8..cddceff5b 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; + /// + /// OnError is called when there is a http operation error. + /// + public event Action OnError; + 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) { + OnError?.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) { + OnError?.Invoke(e); // ignore } From e396bd940bc95e83764981fd21d66d9a9d833173 Mon Sep 17 00:00:00 2001 From: Tim McCurdy Date: Tue, 17 Sep 2024 09:37:00 +0100 Subject: [PATCH 2/2] Updated event name --- .../LeaderElection/ResourceLock/MetaObjectLock.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs b/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs index cddceff5b..e2540482f 100644 --- a/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs +++ b/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs @@ -10,9 +10,9 @@ public abstract class MetaObjectLock : ILock private T metaObjCache; /// - /// OnError is called when there is a http operation error. + /// OnHttpError is called when there is a http operation error. /// - public event Action OnError; + public event Action OnHttpError; protected MetaObjectLock(IKubernetes client, string @namespace, string name, string identity) { @@ -54,7 +54,7 @@ public async Task CreateAsync(LeaderElectionRecord record, CancellationTok } catch (HttpOperationException e) { - OnError?.Invoke(e); + OnHttpError?.Invoke(e); // ignore } @@ -87,7 +87,7 @@ public async Task UpdateAsync(LeaderElectionRecord record, CancellationTok } catch (HttpOperationException e) { - OnError?.Invoke(e); + OnHttpError?.Invoke(e); // ignore }