Skip to content

Commit 42a4400

Browse files
williamhbakerclaude
andcommitted
allocator: zero limit in SetExiting for backward compatibility
When deploying to existing clusters, old allocators don't understand the Exiting field and need to see a zeroed limit to drain items from exiting members. Revert this commit once the cluster is fully upgraded. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 682c4d0 commit 42a4400

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

allocator/allocator_key_space_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ type testMember struct {
361361

362362
func (m testMember) ItemLimit() int { return m.R }
363363
func (m testMember) Validate() error { return nil }
364-
func (m *testMember) SetExiting() { m.E = true }
364+
// TODO(whb): Zero'ing R is for backward compatibility; remove once deployment is complete.
365+
func (m *testMember) SetExiting() { m.E = true; m.R = 0 }
365366
func (m testMember) IsExiting() bool { return m.E }
366367

367368
func (m *testMember) MarshalString() string {

allocator/announce_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ func (s *AnnounceSuite) TestBasicSessionStart(c *gc.C) {
127127
close(sigCh)
128128

129129
c.Check(args.Tasks.Wait(), gc.IsNil) // All tasks have exited.
130-
c.Check(spec.E, gc.Equals, true) // Member was marked as exiting.
130+
c.Check(spec.E, gc.Equals, true) // Member was marked as exiting.
131+
c.Check(spec.R, gc.Equals, 0) // TODO(whb): Remove once backward compat is removed.
131132

132133
leasesResp, err := etcd.Leases(context.Background())
133134
c.Check(err, gc.IsNil)

broker/protocol/broker_spec_extensions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ func (m *BrokerSpec) ItemLimit() int { return int(m.JournalLimit) }
5656
func (m *BrokerSpec) IsExiting() bool { return m.Exiting }
5757

5858
// SetExiting marks this BrokerSpec as exiting.
59-
func (m *BrokerSpec) SetExiting() { m.Exiting = true }
59+
// TODO(whb): Zero'ing JournalLimit is for backward compatibility; remove once
60+
// deployment is complete.
61+
func (m *BrokerSpec) SetExiting() { m.Exiting = true; m.JournalLimit = 0 }
6062

6163
const (
6264
minZoneLen = 1

consumer/protocol/shard_spec_extensions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ func (m *ConsumerSpec) ItemLimit() int { return int(m.ShardLimit) }
289289
func (m *ConsumerSpec) IsExiting() bool { return m.Exiting }
290290

291291
// SetExiting marks this ConsumerSpec as exiting.
292-
func (m *ConsumerSpec) SetExiting() { m.Exiting = true }
292+
// TODO(whb): Zero'ing ShardLimit is for backward compatibility; remove once
293+
// deployment is complete.
294+
func (m *ConsumerSpec) SetExiting() { m.Exiting = true; m.ShardLimit = 0 }
293295

294296
// Reduce folds another ReplicaStatus into this one.
295297
func (m *ReplicaStatus) Reduce(other *ReplicaStatus) {

0 commit comments

Comments
 (0)