Skip to content

Commit

Permalink
liveness: rename TimeUntilStoreDead variable
Browse files Browse the repository at this point in the history
Rename the go variable names to refer to Nodes instead of Stores:

TimeUntilStoreDead -> TimeUntilNodeDead
TimeAfterStoreSuspect -> TimeAfterNodeSuspect

Epic: none

Release note: None
  • Loading branch information
andrewbaptist committed Jun 12, 2023
1 parent f14710f commit 42e45b4
Show file tree
Hide file tree
Showing 18 changed files with 137 additions and 130 deletions.
2 changes: 1 addition & 1 deletion pkg/cli/zip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func TestPartialZip(t *testing.T) {
// is no risk to see the override bumped due to a gossip update
// because this setting is not otherwise set in the test cluster.
s := tc.Server(0)
liveness.TimeUntilStoreDead.Override(ctx, &s.ClusterSettings().SV, liveness.TestTimeUntilStoreDead)
liveness.TimeUntilNodeDead.Override(ctx, &s.ClusterSettings().SV, liveness.TestTimeUntilNodeDead)

// This last case may take a little while to converge. To make this work with datadriven and at the same
// time retain the ability to use the `-rewrite` flag, we use a retry loop within that already checks the
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/roachtest/tests/autoupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func registerAutoUpgrade(r registry.Registry) {
c.Start(ctx, t.L(), option.DefaultStartOpts(), install.MakeClusterSettings(), c.Range(1, nodes))

const stageDuration = 30 * time.Second
const timeUntilStoreDead = 90 * time.Second
const timeUntilNodeDead = 90 * time.Second
const buff = 10 * time.Second

sleep := func(ts time.Duration) error {
Expand All @@ -62,7 +62,7 @@ func registerAutoUpgrade(r registry.Registry) {
defer db.Close()

if _, err := db.ExecContext(ctx,
"SET CLUSTER SETTING server.time_until_store_dead = $1", timeUntilStoreDead.String(),
"SET CLUSTER SETTING server.time_until_store_dead = $1", timeUntilNodeDead.String(),
); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func registerAutoUpgrade(r registry.Registry) {
if err := decommissionAndStop(nodeDecommissioned); err != nil {
t.Fatal(err)
}
if err := sleep(timeUntilStoreDead + buff); err != nil {
if err := sleep(timeUntilNodeDead + buff); err != nil {
t.Fatal(err)
}

Expand Down
30 changes: 15 additions & 15 deletions pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,12 +843,12 @@ func TestAllocatorReplaceDecommissioningReplica(t *testing.T) {
gossiputil.NewStoreGossiper(g).GossipStores(storeDescriptors, t)

// Override liveness of n3 to decommissioning so the only available target is s4.
oSp := storepool.NewOverrideStorePool(sp, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilStoreDead time.Duration) livenesspb.NodeLivenessStatus {
oSp := storepool.NewOverrideStorePool(sp, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilNodeDead time.Duration) livenesspb.NodeLivenessStatus {
if nid == roachpb.NodeID(3) {
return livenesspb.NodeLivenessStatus_DECOMMISSIONING
}

return sp.NodeLivenessFn(nid, now, timeUntilStoreDead)
return sp.NodeLivenessFn(nid, now, timeUntilNodeDead)
}, getNumNodes)

result, _, err := a.AllocateVoter(
Expand Down Expand Up @@ -901,12 +901,12 @@ func TestAllocatorReplaceFailsOnConstrainedDecommissioningReplica(t *testing.T)
gossiputil.NewStoreGossiper(g).GossipStores(sameDCStores, t)

// Override liveness of n3 to decommissioning so the only available target is s4.
oSp := storepool.NewOverrideStorePool(sp, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilStoreDead time.Duration) livenesspb.NodeLivenessStatus {
oSp := storepool.NewOverrideStorePool(sp, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilNodeDead time.Duration) livenesspb.NodeLivenessStatus {
if nid == roachpb.NodeID(3) {
return livenesspb.NodeLivenessStatus_DECOMMISSIONING
}

return sp.NodeLivenessFn(nid, now, timeUntilStoreDead)
return sp.NodeLivenessFn(nid, now, timeUntilNodeDead)
}, func() int {
return 4
})
Expand Down Expand Up @@ -2331,7 +2331,7 @@ func TestAllocatorTransferLeaseTargetDraining(t *testing.T) {
ctx := context.Background()
st := cluster.MakeTestingClusterSettings()
stopper, g, _, storePool, nl := storepool.CreateTestStorePool(ctx, st,
liveness.TestTimeUntilStoreDeadOff, true, /* deterministic */
liveness.TestTimeUntilNodeDeadOff, true, /* deterministic */
func() int { return 10 }, /* nodeCount */
livenesspb.NodeLivenessStatus_LIVE)
a := MakeAllocator(st, true /* deterministic */, func(id roachpb.NodeID) (time.Duration, bool) {
Expand Down Expand Up @@ -2720,7 +2720,7 @@ func TestAllocatorShouldTransferLeaseDraining(t *testing.T) {
ctx := context.Background()
st := cluster.MakeTestingClusterSettings()
stopper, g, _, storePool, nl := storepool.CreateTestStorePool(ctx, st,
liveness.TestTimeUntilStoreDeadOff, true, /* deterministic */
liveness.TestTimeUntilNodeDeadOff, true, /* deterministic */
func() int { return 10 }, /* nodeCount */
livenesspb.NodeLivenessStatus_LIVE)
a := MakeAllocator(st, true /* deterministic */, func(id roachpb.NodeID) (time.Duration, bool) {
Expand Down Expand Up @@ -2788,7 +2788,7 @@ func TestAllocatorShouldTransferSuspected(t *testing.T) {
ctx := context.Background()
st := cluster.MakeTestingClusterSettings()
stopper, g, clock, storePool, nl := storepool.CreateTestStorePool(ctx, st,
liveness.TestTimeUntilStoreDeadOff, true, /* deterministic */
liveness.TestTimeUntilNodeDeadOff, true, /* deterministic */
func() int { return 10 }, /* nodeCount */
livenesspb.NodeLivenessStatus_LIVE)
a := MakeAllocator(st, true /* deterministic */, func(id roachpb.NodeID) (time.Duration, bool) {
Expand Down Expand Up @@ -2821,7 +2821,7 @@ func TestAllocatorShouldTransferSuspected(t *testing.T) {
)
require.Equal(t, expected, result)
}
timeAfterStoreSuspect := storepool.TimeAfterStoreSuspect.Get(&a.st.SV)
timeAfterNodeSuspect := liveness.TimeAfterNodeSuspect.Get(&a.st.SV)
// Based on capacity node 1 is desirable.
assertShouldTransferLease(true)
// Flip node 1 to unavailable, there should be no lease transfer now.
Expand All @@ -2831,7 +2831,7 @@ func TestAllocatorShouldTransferSuspected(t *testing.T) {
nl.SetNodeStatus(1, livenesspb.NodeLivenessStatus_LIVE)
assertShouldTransferLease(false)
// Wait out the suspected store timeout, verify that lease transfers are back.
clock.Advance(timeAfterStoreSuspect + time.Millisecond)
clock.Advance(timeAfterNodeSuspect + time.Millisecond)
assertShouldTransferLease(true)
}

Expand Down Expand Up @@ -5576,7 +5576,7 @@ func TestAllocatorTransferLeaseTargetLoadBased(t *testing.T) {
ctx := context.Background()
st := cluster.MakeTestingClusterSettings()
stopper, g, _, storePool, _ := storepool.CreateTestStorePool(ctx, st,
liveness.TestTimeUntilStoreDeadOff, true, /* deterministic */
liveness.TestTimeUntilNodeDeadOff, true, /* deterministic */
func() int { return 10 }, /* nodeCount */
livenesspb.NodeLivenessStatus_LIVE)
defer stopper.Stop(ctx)
Expand Down Expand Up @@ -6830,14 +6830,14 @@ func TestAllocatorComputeActionWithStorePoolRemoveDead(t *testing.T) {
// Mark all dead nodes as alive, so we can override later.
all := append(tcase.live, tcase.dead...)
mockStorePool(sp, all, nil, nil, nil, nil, nil)
oSp := storepool.NewOverrideStorePool(sp, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilStoreDead time.Duration) livenesspb.NodeLivenessStatus {
oSp := storepool.NewOverrideStorePool(sp, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilNodeDead time.Duration) livenesspb.NodeLivenessStatus {
for _, deadStoreID := range tcase.dead {
if nid == roachpb.NodeID(deadStoreID) {
return livenesspb.NodeLivenessStatus_DEAD
}
}

return sp.NodeLivenessFn(nid, now, timeUntilStoreDead)
return sp.NodeLivenessFn(nid, now, timeUntilNodeDead)
}, getNumNodes)
action, _ := a.ComputeAction(ctx, oSp, conf, &tcase.desc)
if tcase.expectedAction != action {
Expand Down Expand Up @@ -7722,7 +7722,7 @@ func TestAllocatorComputeActionDynamicNumReplicas(t *testing.T) {
ctx := context.Background()
st := cluster.MakeTestingClusterSettings()
stopper, _, _, sp, _ := storepool.CreateTestStorePool(ctx, st,
liveness.TestTimeUntilStoreDeadOff, false, /* deterministic */
liveness.TestTimeUntilNodeDeadOff, false, /* deterministic */
func() int { return numNodes },
livenesspb.NodeLivenessStatus_LIVE)
a := MakeAllocator(st, false /* deterministic */, func(id roachpb.NodeID) (time.Duration, bool) {
Expand Down Expand Up @@ -8446,7 +8446,7 @@ func TestAllocatorFullDisks(t *testing.T) {

g := gossip.NewTest(1, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef())

liveness.TimeUntilStoreDead.Override(ctx, &st.SV, liveness.TestTimeUntilStoreDeadOff)
liveness.TimeUntilNodeDead.Override(ctx, &st.SV, liveness.TestTimeUntilNodeDeadOff)

const generations = 100
const nodes = 20
Expand Down Expand Up @@ -8904,7 +8904,7 @@ func exampleRebalancing(
// adding / rebalancing ranges of random sizes.
g := gossip.NewTest(1, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef())

liveness.TimeUntilStoreDead.Override(ctx, &st.SV, liveness.TestTimeUntilStoreDeadOff)
liveness.TimeUntilNodeDead.Override(ctx, &st.SV, liveness.TestTimeUntilNodeDeadOff)

const nodes = 20

Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/allocator/allocatorimpl/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func CreateTestAllocatorWithKnobs(
) (*stop.Stopper, *gossip.Gossip, *storepool.StorePool, Allocator, *timeutil.ManualTime) {
st := cluster.MakeTestingClusterSettings()
stopper, g, manual, storePool, _ := storepool.CreateTestStorePool(ctx, st,
liveness.TestTimeUntilStoreDeadOff, deterministic,
liveness.TestTimeUntilNodeDeadOff, deterministic,
func() int { return numNodes },
livenesspb.NodeLivenessStatus_LIVE)
a := MakeAllocator(st, deterministic, func(id roachpb.NodeID) (time.Duration, bool) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kv/kvserver/allocator/storepool/override_store_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ var _ AllocatorStorePool = &OverrideStorePool{}
func OverrideNodeLivenessFunc(
overrides map[roachpb.NodeID]livenesspb.NodeLivenessStatus, realNodeLivenessFunc NodeLivenessFunc,
) NodeLivenessFunc {
return func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilStoreDead time.Duration) livenesspb.NodeLivenessStatus {
return func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilNodeDead time.Duration) livenesspb.NodeLivenessStatus {
if override, ok := overrides[nid]; ok {
return override
}

return realNodeLivenessFunc(nid, now, timeUntilStoreDead)
return realNodeLivenessFunc(nid, now, timeUntilNodeDead)
}
}

Expand Down
18 changes: 9 additions & 9 deletions pkg/kv/kvserver/allocator/storepool/override_store_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ func TestOverrideStorePoolStatusString(t *testing.T) {
const nodeCount = 5

stopper, g, _, testStorePool, mnl := CreateTestStorePool(ctx, st,
liveness.TestTimeUntilStoreDead, false, /* deterministic */
liveness.TestTimeUntilNodeDead, false, /* deterministic */
func() int { return nodeCount }, /* nodeCount */
livenesspb.NodeLivenessStatus_DEAD)
defer stopper.Stop(ctx)
sg := gossiputil.NewStoreGossiper(g)

livenessOverrides := make(map[roachpb.NodeID]livenesspb.NodeLivenessStatus)
sp := NewOverrideStorePool(testStorePool, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilStoreDead time.Duration) livenesspb.NodeLivenessStatus {
sp := NewOverrideStorePool(testStorePool, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilNodeDead time.Duration) livenesspb.NodeLivenessStatus {
if overriddenLiveness, ok := livenessOverrides[nid]; ok {
return overriddenLiveness
}

return mnl.NodeLivenessFunc(nid, now, timeUntilStoreDead)
return mnl.NodeLivenessFunc(nid, now, timeUntilNodeDead)
}, func() int {
excluded := 0
for _, overriddenLiveness := range livenessOverrides {
Expand Down Expand Up @@ -118,19 +118,19 @@ func TestOverrideStorePoolDecommissioningReplicas(t *testing.T) {
const nodeCount = 5

stopper, g, _, testStorePool, mnl := CreateTestStorePool(ctx, st,
liveness.TestTimeUntilStoreDead, false, /* deterministic */
liveness.TestTimeUntilNodeDead, false, /* deterministic */
func() int { return nodeCount }, /* nodeCount */
livenesspb.NodeLivenessStatus_DEAD)
defer stopper.Stop(ctx)
sg := gossiputil.NewStoreGossiper(g)

livenessOverrides := make(map[roachpb.NodeID]livenesspb.NodeLivenessStatus)
sp := NewOverrideStorePool(testStorePool, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilStoreDead time.Duration) livenesspb.NodeLivenessStatus {
sp := NewOverrideStorePool(testStorePool, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilNodeDead time.Duration) livenesspb.NodeLivenessStatus {
if overriddenLiveness, ok := livenessOverrides[nid]; ok {
return overriddenLiveness
}

return mnl.NodeLivenessFunc(nid, now, timeUntilStoreDead)
return mnl.NodeLivenessFunc(nid, now, timeUntilNodeDead)
}, func() int {
excluded := 0
for _, overriddenLiveness := range livenessOverrides {
Expand Down Expand Up @@ -235,19 +235,19 @@ func TestOverrideStorePoolGetStoreList(t *testing.T) {

// We're going to manually mark stores dead in this test.
stopper, g, _, testStorePool, mnl := CreateTestStorePool(ctx, st,
liveness.TestTimeUntilStoreDead, false, /* deterministic */
liveness.TestTimeUntilNodeDead, false, /* deterministic */
func() int { return nodeCount }, /* nodeCount */
livenesspb.NodeLivenessStatus_DEAD)
defer stopper.Stop(ctx)
sg := gossiputil.NewStoreGossiper(g)

livenessOverrides := make(map[roachpb.NodeID]livenesspb.NodeLivenessStatus)
sp := NewOverrideStorePool(testStorePool, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilStoreDead time.Duration) livenesspb.NodeLivenessStatus {
sp := NewOverrideStorePool(testStorePool, func(nid roachpb.NodeID, now hlc.Timestamp, timeUntilNodeDead time.Duration) livenesspb.NodeLivenessStatus {
if overriddenLiveness, ok := livenessOverrides[nid]; ok {
return overriddenLiveness
}

return mnl.NodeLivenessFunc(nid, now, timeUntilStoreDead)
return mnl.NodeLivenessFunc(nid, now, timeUntilNodeDead)
}, func() int {
excluded := 0
for _, overriddenLiveness := range livenessOverrides {
Expand Down
Loading

0 comments on commit 42e45b4

Please sign in to comment.