From b5588987fb328b0ef2fe96e6f4c4c33683cfb0dd Mon Sep 17 00:00:00 2001 From: Brendan Burns <5751682+brendandburns@users.noreply.github.com> Date: Fri, 19 Jun 2026 16:06:38 +0000 Subject: [PATCH] chore(deps): combine dependabot updates and fix CI review feedback --- Directory.Packages.props | 6 ++-- .../openTelemetryConsole.csproj | 9 +++--- tests/E2E.Tests/MinikubeTests.cs | 11 ++++--- .../LeaderElection/LeaderElectionTests.cs | 29 ++++++++++--------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 22b88c7ff..8ee684b4d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,14 +10,14 @@ - + - + @@ -26,7 +26,7 @@ - + diff --git a/examples/openTelemetryConsole/openTelemetryConsole.csproj b/examples/openTelemetryConsole/openTelemetryConsole.csproj index 1be34a84c..e0d6cb033 100644 --- a/examples/openTelemetryConsole/openTelemetryConsole.csproj +++ b/examples/openTelemetryConsole/openTelemetryConsole.csproj @@ -6,10 +6,9 @@ enable - - - - - + + + + diff --git a/tests/E2E.Tests/MinikubeTests.cs b/tests/E2E.Tests/MinikubeTests.cs index 5152ed24f..739eaf8e1 100644 --- a/tests/E2E.Tests/MinikubeTests.cs +++ b/tests/E2E.Tests/MinikubeTests.cs @@ -752,19 +752,18 @@ await clientSet.CoreV1.Pod // replace + get (retry on conflict due to Kubernetes optimistic concurrency) { - var retries = 5; - while (retries-- > 0) + const int maxAttempts = 5; + for (var attempt = 1; attempt <= maxAttempts; attempt++) { + var pod = await clientSet.CoreV1.Pod.GetAsync(podName, namespaceParameter).ConfigureAwait(false); + pod.Spec.Containers[0].Image = "httpd"; try { - var pod = await clientSet.CoreV1.Pod.GetAsync(podName, namespaceParameter).ConfigureAwait(false); - pod.Spec.Containers[0].Image = "httpd"; await clientSet.CoreV1.Pod.UpdateAsync(pod, podName, namespaceParameter).ConfigureAwait(false); break; } - catch (HttpOperationException e) when (e.Response.StatusCode == System.Net.HttpStatusCode.Conflict) + catch (HttpOperationException e) when (e.Response.StatusCode == System.Net.HttpStatusCode.Conflict && attempt < maxAttempts) { - if (retries == 0) throw; await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); } } diff --git a/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs b/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs index 6dcf126b0..a8b159a48 100644 --- a/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs +++ b/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs @@ -1,6 +1,7 @@ using k8s.LeaderElection; using Moq; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -84,8 +85,8 @@ public void SimpleLeaderElection() [Fact] public void LeaderElection() { - var electionHistory = new List(); - var leadershipHistory = new List(); + var electionHistory = new ConcurrentQueue(); + var leadershipHistory = new ConcurrentQueue(); var electionHistoryCountdown = new CountdownEvent(7); var renewCountA = 3; @@ -95,19 +96,19 @@ public void LeaderElection() { renewCountA--; - electionHistory.Add("A creates record"); - leadershipHistory.Add("A gets leadership"); + electionHistory.Enqueue("A creates record"); + leadershipHistory.Enqueue("A gets leadership"); electionHistoryCountdown.Signal(); }; mockLockA.OnUpdate += (_) => { renewCountA--; - electionHistory.Add("A updates record"); + electionHistory.Enqueue("A updates record"); electionHistoryCountdown.Signal(); }; - mockLockA.OnChange += (_) => { leadershipHistory.Add("A gets leadership"); }; + mockLockA.OnChange += (_) => { leadershipHistory.Enqueue("A gets leadership"); }; var leaderElectionConfigA = new LeaderElectionConfig(mockLockA) { @@ -123,19 +124,19 @@ public void LeaderElection() { renewCountB--; - electionHistory.Add("B creates record"); + electionHistory.Enqueue("B creates record"); electionHistoryCountdown.Signal(); - leadershipHistory.Add("B gets leadership"); + leadershipHistory.Enqueue("B gets leadership"); }; mockLockB.OnUpdate += (_) => { renewCountB--; - electionHistory.Add("B updates record"); + electionHistory.Enqueue("B updates record"); electionHistoryCountdown.Signal(); }; - mockLockB.OnChange += (_) => { leadershipHistory.Add("B gets leadership"); }; + mockLockB.OnChange += (_) => { leadershipHistory.Enqueue("B gets leadership"); }; var leaderElectionConfigB = new LeaderElectionConfig(mockLockB) { @@ -153,13 +154,13 @@ public void LeaderElection() leaderElector.OnStartedLeading += () => { - leadershipHistory.Add("A starts leading"); + leadershipHistory.Enqueue("A starts leading"); testLeaderElectionLatch.Signal(); }; leaderElector.OnStoppedLeading += () => { - leadershipHistory.Add("A stops leading"); + leadershipHistory.Enqueue("A stops leading"); testLeaderElectionLatch.Signal(); lockAStopLeading.Set(); }; @@ -176,13 +177,13 @@ public void LeaderElection() leaderElector.OnStartedLeading += () => { - leadershipHistory.Add("B starts leading"); + leadershipHistory.Enqueue("B starts leading"); testLeaderElectionLatch.Signal(); }; leaderElector.OnStoppedLeading += () => { - leadershipHistory.Add("B stops leading"); + leadershipHistory.Enqueue("B stops leading"); testLeaderElectionLatch.Signal(); };