File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/KubernetesClient/LeaderElection Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ public class LeaderElector : IDisposable
28
28
/// </summary>
29
29
public event Action < string > OnNewLeader ;
30
30
31
+ /// <summary>
32
+ /// OnError is called when there is an error trying to determine leadership.
33
+ /// </summary>
34
+ public event Action < Exception > OnError ;
35
+
31
36
private volatile LeaderElectionRecord observedRecord ;
32
37
private DateTimeOffset observedTime = DateTimeOffset . MinValue ;
33
38
private string reportedLeader ;
@@ -69,8 +74,9 @@ public async Task RunAsync(CancellationToken cancellationToken = default)
69
74
MaybeReportTransition ( ) ;
70
75
}
71
76
}
72
- catch
77
+ catch ( Exception e )
73
78
{
79
+ OnError ? . Invoke ( e ) ;
74
80
// ignore
75
81
return false ;
76
82
}
@@ -129,6 +135,8 @@ private async Task<bool> TryAcquireOrRenew(CancellationToken cancellationToken)
129
135
{
130
136
return false ;
131
137
}
138
+
139
+ OnError ? . Invoke ( e ) ;
132
140
}
133
141
134
142
if ( oldLeaderElectionRecord ? . AcquireTime == null ||
You can’t perform that action at this time.
0 commit comments