-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ccl/sqlproxyccl: ensure that EnsureTenantPod always resumes a pod
This was a regression from the new load balancing work. Previously, the pods list in entry.go only stores a list of running pods. That has been modified to also store draining pods, and this breaks some of the existing logic. In particular, there could be an issue where EnsureTenantPod returned right away when there are only DRAINING pods left because we relied on the length of pods rather than checking through all their states. This commit fixes that buglet by ensuring that EnsureTenantPods will attempt to resume tenants whenever only DRAINING pods are left. This bug was prominent when the pod watcher restarted at the moment the DRAINING pod was deleted, causing the deletion event to be missed. When that happens, the cache is stuck with a DRAINING pod that will never get refreshed because (1) EnsureTenantPod does not attempt to resume that tenant, and (2) we don't call ReportFailure when we fail to obtain an address. The second behavior is expected because we relied on the fact that (1) should resume the tenant. Release note: None
- Loading branch information
1 parent
fb8ed97
commit 83e1815
Showing
6 changed files
with
105 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package tenant | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestHasRunningPod(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
|
||
for _, tc := range []struct { | ||
name string | ||
pods []*Pod | ||
expected bool | ||
}{ | ||
{ | ||
name: "no pods", | ||
pods: nil, | ||
expected: false, | ||
}, | ||
{ | ||
name: "single running pod", | ||
pods: []*Pod{{State: RUNNING}}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "single draining pod", | ||
pods: []*Pod{{State: DRAINING}}, | ||
expected: false, | ||
}, | ||
{ | ||
name: "multiple pods", | ||
pods: []*Pod{ | ||
{State: DRAINING}, | ||
{State: DRAINING}, | ||
{State: RUNNING}, | ||
{State: RUNNING}, | ||
}, | ||
expected: true, | ||
}, | ||
} { | ||
t.Run(tc.name, func(t *testing.T) { | ||
require.Equal(t, tc.expected, hasRunningPod(tc.pods)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters