Skip to content

Commit ef392e9

Browse files
authored
Maintenance events: add NodeMaintenanceScaleComplete (#1902)
Recognize the upcoming `NodeMaintenanceScaleComplete` event to handle Redis cluster scaling (either direction).
1 parent 27339cd commit ef392e9

4 files changed

Lines changed: 9 additions & 0 deletions

File tree

docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Release Notes
22

33
## Unreleased
4+
- Add support for NodeMaintenanceScaleComplete event (handles Redis cluster scaling) (#1902 via NickCraver)
45

56
## 2.2.79
67

src/StackExchange.Redis/Maintenance/AzureMaintenanceEvent.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ await sub.SubscribeAsync(PubSubChannelName, async (channel, message) =>
138138
{
139139
case AzureNotificationType.NodeMaintenanceEnded:
140140
case AzureNotificationType.NodeMaintenanceFailoverComplete:
141+
case AzureNotificationType.NodeMaintenanceScaleComplete:
141142
await multiplexer.ReconfigureAsync(first: false, reconfigureAll: true, log: logProxy, blame: null, cause: $"Azure Event: {newMessage.NotificationType}").ForAwait();
142143
break;
143144
}
@@ -188,6 +189,7 @@ await sub.SubscribeAsync(PubSubChannelName, async (channel, message) =>
188189
// This is temporary until server changes go into effect - to be removed in later versions
189190
"NodeMaintenanceFailover" => AzureNotificationType.NodeMaintenanceFailoverComplete,
190191
"NodeMaintenanceFailoverComplete" => AzureNotificationType.NodeMaintenanceFailoverComplete,
192+
"NodeMaintenanceScaleComplete" => AzureNotificationType.NodeMaintenanceScaleComplete,
191193
_ => AzureNotificationType.Unknown,
192194
};
193195
}

src/StackExchange.Redis/Maintenance/AzureNotificationType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,10 @@ public enum AzureNotificationType
3434
/// Indicates that a replica has been promoted to primary.
3535
/// </summary>
3636
NodeMaintenanceFailoverComplete,
37+
38+
/// <summary>
39+
/// Indicates that a scale event (adding or removing nodes) has completed for a cluster.
40+
/// </summary>
41+
NodeMaintenanceScaleComplete,
3742
}
3843
}

tests/StackExchange.Redis.Tests/AzureMaintenanceEventTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public AzureMaintenanceEventTests(ITestOutputHelper output) : base(output)
2020
[InlineData("NotificationType|NodeMaintenanceStarting|StartTimeInUTC|2021-03-02T23:26:57|IsReplica|j|IPAddress||SSLPort|char|NonSSLPort|char", AzureNotificationType.NodeMaintenanceStarting, "2021-03-02T23:26:57", false, null, 0, 0)]
2121
[InlineData("NotificationType|NodeMaintenanceStarting|somejunkkey|somejunkvalue|StartTimeInUTC|2021-03-02T23:26:57|IsReplica|False|IPAddress||SSLPort|15999|NonSSLPort|139991", AzureNotificationType.NodeMaintenanceStarting, "2021-03-02T23:26:57", false, null, 15999, 139991)]
2222
[InlineData("NotificationType|NodeMaintenanceStarting|somejunkkey|somejunkvalue|StartTimeInUTC|2021-03-02T23:26:57|IsReplica|False|IPAddress|127.0.0.1|SSLPort|15999|NonSSLPort|139991", AzureNotificationType.NodeMaintenanceStarting, "2021-03-02T23:26:57", false, "127.0.0.1", 15999, 139991)]
23+
[InlineData("NotificationType|NodeMaintenanceScaleComplete|somejunkkey|somejunkvalue|StartTimeInUTC|2021-03-02T23:26:57|IsReplica|False|IPAddress|127.0.0.1|SSLPort|15999|NonSSLPort|139991", AzureNotificationType.NodeMaintenanceScaleComplete, "2021-03-02T23:26:57", false, "127.0.0.1", 15999, 139991)]
2324
[InlineData("NotificationTypeNodeMaintenanceStartingsomejunkkeysomejunkvalueStartTimeInUTC2021-03-02T23:26:57IsReplicaFalseIPAddress127.0.0.1SSLPort15999NonSSLPort139991", AzureNotificationType.Unknown, null, false, null, 0, 0)]
2425
[InlineData("NotificationType|", AzureNotificationType.Unknown, null, false, null, 0, 0)]
2526
[InlineData("NotificationType|NodeMaintenanceStarting1", AzureNotificationType.Unknown, null, false, null, 0, 0)]

0 commit comments

Comments
 (0)