forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spanconfig: introduce the span config manager
This patch introduces the spanconfigmanager.Manager. This struct is responsible for setting up the auto span config reconciliation job. The auto span config reconciliation job is a per tenant job responsible for reconciling SQL zone configs to KV span configs. This is intended to be a per tenant singleton, non-cancellable job. The manager ensures these semantics. The manager will also provide the job access to components it needs to perform reconciliation. The skeleton to plumb these components has been added in this patch but the components themselves will come subsequently. References cockroachdb#67679 Release note: None
- Loading branch information
1 parent
796b827
commit 0db6ece
Showing
27 changed files
with
667 additions
and
27 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
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
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,12 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "spanconfig", | ||
srcs = [ | ||
"spanconfig.go", | ||
"testing_knobs.go", | ||
], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/spanconfig", | ||
visibility = ["//visibility:public"], | ||
deps = ["//pkg/base"], | ||
) |
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,28 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package spanconfig | ||
|
||
// ReconciliationDependencies captures what's needed by the span config | ||
// reconciliation job to perform its task. The job is responsible for | ||
// reconciling a tenant's zone configurations with the clusters span | ||
// configurations. | ||
type ReconciliationDependencies interface { | ||
// TODO(zcfgs-pod): Placeholder comment until subsequent PRs add useful | ||
// interfaces here. | ||
// The job will want access to two interfaces to reconcile. | ||
// 1. spanconfig.KVAccessor -- this will expose RPCs the job can use to fetch | ||
// span configs from KV and update them. It'll be implemented by Node for the | ||
// host tenant and the Connector for secondary tenants. | ||
// 2. spanconfig.SQLWatcher -- this will maintain a rangefeed over | ||
// system.{descriptors, zones} and be responsible for generating span config | ||
// updates. The job will respond to these updates by issuing RPCs using the | ||
// KVAccessor. | ||
} |
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,15 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "spanconfigjob", | ||
srcs = ["job.go"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/jobs", | ||
"//pkg/jobs/jobspb", | ||
"//pkg/settings/cluster", | ||
"//pkg/sql", | ||
"@com_github_cockroachdb_errors//:errors", | ||
], | ||
) |
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,51 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package spanconfigjob | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/jobs" | ||
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb" | ||
"github.com/cockroachdb/cockroach/pkg/settings/cluster" | ||
"github.com/cockroachdb/cockroach/pkg/sql" | ||
"github.com/cockroachdb/errors" | ||
) | ||
|
||
type resumer struct { | ||
job *jobs.Job | ||
} | ||
|
||
var _ jobs.Resumer = (*resumer)(nil) | ||
|
||
// Resume implements the jobs.Resumer interface. | ||
func (r *resumer) Resume(ctx context.Context, execCtxI interface{}) error { | ||
execCtx := execCtxI.(sql.JobExecContext) | ||
rc := execCtx.SpanConfigReconciliationJobDeps() | ||
// TODO(zcfg-pod): Upcoming PRs will actually make use of these reconciliation | ||
// dependencies. | ||
_ = rc | ||
|
||
<-ctx.Done() | ||
return ctx.Err() | ||
} | ||
|
||
// OnFailOrCancel implements the jobs.Resumer interface. | ||
func (r *resumer) OnFailOrCancel(context.Context, interface{}) error { | ||
return errors.AssertionFailedf("span config reconciliation job can never fail or be canceled") | ||
} | ||
|
||
func init() { | ||
jobs.RegisterConstructor(jobspb.TypeAutoSpanConfigReconciliation, | ||
func(job *jobs.Job, settings *cluster.Settings) jobs.Resumer { | ||
return &resumer{job: job} | ||
}) | ||
} |
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,43 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "spanconfigmanager", | ||
srcs = ["manager.go"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigmanager", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/jobs", | ||
"//pkg/jobs/jobspb", | ||
"//pkg/kv", | ||
"//pkg/security", | ||
"//pkg/spanconfig", | ||
"//pkg/sql/sem/tree", | ||
"//pkg/sql/sessiondata", | ||
"//pkg/sql/sqlutil", | ||
"//pkg/util/log", | ||
"//pkg/util/stop", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "spanconfigmanager_test", | ||
srcs = [ | ||
"main_test.go", | ||
"manager_test.go", | ||
], | ||
deps = [ | ||
":spanconfigmanager", | ||
"//pkg/base", | ||
"//pkg/jobs", | ||
"//pkg/security", | ||
"//pkg/security/securitytest", | ||
"//pkg/server", | ||
"//pkg/spanconfig", | ||
"//pkg/sql", | ||
"//pkg/testutils/serverutils", | ||
"//pkg/testutils/testcluster", | ||
"//pkg/util/leaktest", | ||
"//pkg/util/syncutil", | ||
"@com_github_stretchr_testify//require", | ||
], | ||
) |
Oops, something went wrong.