Skip to content

Commit 6b9c3ec

Browse files
craig[bot]jeffswensoncthumuluru-crdbRaduBerinde
committed
148013: randgen: add schema filters for ldr r=jeffswenson a=jeffswenson The first two commits in the PR are intended to be purely mechanical. The final commit adds support for schema filters that limit which schemas can be randomly generated. ## randgen: rework TableOpt to follow option pattern This commit reworks randgen so that TableOpt follows the standard go option convention. This allows for spelling non-binary options like type filters or transformations. Release note: none ## randgen: extract table logic into stand alone file Previously, the logic for generating schemas was mixed up with the logic for generating tables. This moves table specific logic into its own file. Release note: none ## randgen: add filter options for ldr Add options to filter the columns, primary key, and secondary indexes generated by randgen. This will be used when testing LDR to constraint schema generation to schemas that are compatible with LDR. Release note: none Informs: CRDB-44094 148057: *: consolidate `AdminClient` RPC client creation r=cthumuluru-crdb a=cthumuluru-crdb This commit consolidates `AdminClient` RPC client creation logic in cli, kv, and server packages. It is a continuation of the work done in #147606. Epic: CRDB-48923 Fixes: #148158 Release note: none 148171: github: change check-pebble-deps action to post Slack message r=RaduBerinde a=RaduBerinde This action checks that Pebble dependency is up-to-date for recent release branches. It currently files issues but they are annoying to triage and close. This commit removes the github issue posting for the script and instead sends a message to the storage-notifications channel on Slack. Epic: none Release note: None Co-authored-by: Jeff Swenson <[email protected]> Co-authored-by: Chandra Thumuluru <[email protected]> Co-authored-by: Radu Berinde <[email protected]>
4 parents 98ab43e + 7372262 + fc3187a + 728831c commit 6b9c3ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1058
-586
lines changed

.github/workflows/check-pebble-dep.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,42 @@ name: Check Pebble dep
22
on:
33
schedule:
44
- cron: '0 8 * * 0,3' # Every Sun and Wed at 8:00 UTC
5+
workflow_dispatch:
56

67
jobs:
78
check-pebble-dep:
89
runs-on: ubuntu-latest
910
env:
1011
GH_TOKEN: ${{ github.token }}
1112
steps:
12-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1314
with:
1415
fetch-depth: 0
1516

1617
- name: Check Pebble deps
17-
shell: bash
18-
run: scripts/check-pebble-dep.sh
18+
id: run_script
19+
run: |
20+
EXIT_CODE=0
21+
OUTPUT=$(scripts/check-pebble-dep.sh 2>&1) || EXIT_CODE=$?
22+
echo "$OUTPUT"
23+
# Set output as a multi-line string.
24+
echo "output<<EOF" >> $GITHUB_OUTPUT
25+
echo "$OUTPUT" >> $GITHUB_OUTPUT
26+
echo "EOF" >> $GITHUB_OUTPUT
27+
# Set exit code.
28+
echo "exitcode=$EXIT_CODE" >> $GITHUB_OUTPUT
29+
30+
- name: Notify Slack on failure
31+
if: steps.run_script.outputs.exitcode != '0'
32+
uses: slackapi/[email protected]
33+
with:
34+
method: chat.postMessage
35+
token: ${{ secrets.PEBBLE_SLACK_BOT_TOKEN }}
36+
# The channel ID is for #storage-notifications.
37+
payload: |
38+
channel: C08JE13CM9S
39+
text: |
40+
Some Pebble dependencies are not up to date. Details below:
41+
```
42+
${{ steps.run_script.outputs.output }}
43+
```

pkg/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ ALL_TESTS = [
180180
"//pkg/crosscluster/physical:physical_test",
181181
"//pkg/crosscluster/producer:producer_disallowed_imports_test",
182182
"//pkg/crosscluster/producer:producer_test",
183+
"//pkg/crosscluster/replicationtestutils:replicationtestutils_test",
183184
"//pkg/crosscluster/replicationutils:replicationutils_test",
184185
"//pkg/crosscluster/streamclient/randclient:randclient_test",
185186
"//pkg/crosscluster/streamclient:streamclient_test",
@@ -1322,6 +1323,7 @@ GO_TARGETS = [
13221323
"//pkg/crosscluster/producer:producer",
13231324
"//pkg/crosscluster/producer:producer_test",
13241325
"//pkg/crosscluster/replicationtestutils:replicationtestutils",
1326+
"//pkg/crosscluster/replicationtestutils:replicationtestutils_test",
13251327
"//pkg/crosscluster/replicationutils:replicationutils",
13261328
"//pkg/crosscluster/replicationutils:replicationutils_test",
13271329
"//pkg/crosscluster/streamclient/randclient:randclient",

pkg/cli/debug_recover_loss_of_quorum.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,12 @@ func runDebugDeadReplicaCollect(cmd *cobra.Command, args []string) error {
308308
var stats loqrecovery.CollectionStats
309309

310310
if len(debugRecoverCollectInfoOpts.Stores.Specs) == 0 {
311-
c, finish, err := getAdminClient(ctx, serverCfg)
311+
c, finish, err := dialAdminClient(ctx, serverCfg)
312312
if err != nil {
313313
return errors.Wrapf(err, "failed to get admin connection to cluster")
314314
}
315315
defer finish()
316+
316317
replicaInfo, stats, err = loqrecovery.CollectRemoteReplicaInfo(ctx, c,
317318
debugRecoverCollectInfoOpts.maxConcurrency, stderr /* logOutput */)
318319
if err != nil {
@@ -426,11 +427,12 @@ func runDebugPlanReplicaRemoval(cmd *cobra.Command, args []string) error {
426427
if len(args) == 0 {
427428
// If no replica info is provided, try to connect to a cluster default or
428429
// explicitly provided to retrieve replica info.
429-
c, finish, err := getAdminClient(ctx, serverCfg)
430+
c, finish, err := dialAdminClient(ctx, serverCfg)
430431
if err != nil {
431432
return errors.Wrapf(err, "failed to get admin connection to cluster")
432433
}
433434
defer finish()
435+
434436
replicas, stats, err = loqrecovery.CollectRemoteReplicaInfo(ctx, c,
435437
debugRecoverPlanOpts.maxConcurrency, stderr /* logOutput */)
436438
if err != nil {
@@ -675,7 +677,7 @@ func stageRecoveryOntoCluster(
675677
ignoreInternalVersion bool,
676678
maxConcurrency int,
677679
) error {
678-
c, finish, err := getAdminClient(ctx, serverCfg)
680+
c, finish, err := dialAdminClient(ctx, serverCfg)
679681
if err != nil {
680682
return errors.Wrapf(err, "failed to get admin connection to cluster")
681683
}
@@ -686,6 +688,7 @@ func stageRecoveryOntoCluster(
686688
nodeID roachpb.NodeID
687689
planID string
688690
}
691+
689692
vr, err := c.RecoveryVerify(ctx, &serverpb.RecoveryVerifyRequest{
690693
MaxConcurrency: int32(maxConcurrency),
691694
})
@@ -948,11 +951,12 @@ func runDebugVerify(cmd *cobra.Command, args []string) error {
948951
_, _ = fmt.Printf("Checking application of recovery plan %s\n", updatePlan.PlanID)
949952
}
950953

951-
c, finish, err := getAdminClient(ctx, serverCfg)
954+
c, finish, err := dialAdminClient(ctx, serverCfg)
952955
if err != nil {
953956
return errors.Wrapf(err, "failed to get admin connection to cluster")
954957
}
955958
defer finish()
959+
956960
req := serverpb.RecoveryVerifyRequest{
957961
DecommissionedNodeIDs: updatePlan.DecommissionedNodeIDs,
958962
MaxReportedRanges: 20,

pkg/cli/debug_reset_quorum.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ func runDebugResetQuorum(cmd *cobra.Command, args []string) error {
4545
}
4646

4747
// Set up GRPC Connection for running ResetQuorum.
48-
cc, finish, err := getClientGRPCConn(ctx, serverCfg)
48+
conn, finish, err := newClientConn(ctx, serverCfg)
4949
if err != nil {
5050
log.Errorf(ctx, "connection to server failed: %v", err)
5151
return err
5252
}
5353
defer finish()
5454

5555
// Call ResetQuorum to reset quorum for given range on target node.
56-
_, err = kvpb.NewInternalClient(cc).ResetQuorum(ctx, &kvpb.ResetQuorumRequest{
56+
_, err = conn.NewInternalClient().ResetQuorum(ctx, &kvpb.ResetQuorumRequest{
5757
RangeID: int32(rangeID),
5858
})
5959
if err != nil {

pkg/cli/debug_send_kv_batch.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,11 @@ func runSendKVBatch(cmd *cobra.Command, args []string) error {
166166
// Send BatchRequest.
167167
ctx, cancel := context.WithCancel(context.Background())
168168
defer cancel()
169-
conn, finish, err := getClientGRPCConn(ctx, serverCfg)
169+
admin, finish, err := dialAdminClient(ctx, serverCfg)
170170
if err != nil {
171171
return errors.Wrap(err, "failed to connect to the node")
172172
}
173173
defer finish()
174-
admin := serverpb.NewAdminClient(conn)
175174

176175
br, rec, err := sendKVBatchRequestWithTracingOption(ctx, enableTracing, admin, &ba)
177176
if err != nil {

pkg/cli/democluster/demo_cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ func (c *transientCluster) waitForNodeIDReadiness(
795795
if err != nil {
796796
return err
797797
}
798-
c.servers[idx].adminClient = serverpb.NewAdminClient(conn)
798+
c.servers[idx].adminClient = conn.NewAdminClient()
799799

800800
}
801801
break
@@ -1219,7 +1219,7 @@ func (c *transientCluster) startServerInternal(
12191219

12201220
c.servers[serverIdx] = serverEntry{
12211221
TestServerInterface: s,
1222-
adminClient: serverpb.NewAdminClient(conn),
1222+
adminClient: conn.NewAdminClient(),
12231223
nodeID: nodeID,
12241224
}
12251225

pkg/cli/gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ func generateMetricList(ctx context.Context, skipFiltering bool) (map[string]*La
407407
if err != nil {
408408
return err
409409
}
410-
client := serverpb.NewAdminClient(conn)
410+
client := conn.NewAdminClient()
411411

412412
resp, err := client.ChartCatalog(ctx, &serverpb.ChartCatalogRequest{})
413413
if err != nil {

pkg/cli/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func dialAndCheckHealth(ctx context.Context) error {
8989
// (Attempt to) establish the gRPC connection. If that fails,
9090
// it may be that the server hasn't started to listen yet, in
9191
// which case we'll retry.
92-
conn, finish, err := getClientGRPCConn(ctx, serverCfg)
92+
conn, finish, err := newClientConn(ctx, serverCfg)
9393
if err != nil {
9494
return err
9595
}
@@ -98,7 +98,7 @@ func dialAndCheckHealth(ctx context.Context) error {
9898
// Access the /health endpoint. Until/unless this succeeds, the
9999
// node is not yet fully initialized and ready to accept
100100
// Bootstrap requests.
101-
ac := serverpb.NewAdminClient(conn)
101+
ac := conn.NewAdminClient()
102102
_, err = ac.Health(ctx, &serverpb.HealthRequest{})
103103
return err
104104
}

pkg/cli/rpc_clients.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,18 @@ func makeRPCClientConfig(cfg server.Config) rpc.ClientConnConfig {
7373
func newClientConn(ctx context.Context, cfg server.Config) (rpcConn, func(), error) {
7474
ccfg := makeRPCClientConfig(cfg)
7575
cc, finish, err := rpc.NewClientConn(ctx, ccfg)
76-
return &grpcConn{conn: cc}, finish, errors.Wrap(err, "failed to connect to the node")
77-
}
78-
79-
func getClientGRPCConn(ctx context.Context, cfg server.Config) (*grpc.ClientConn, func(), error) {
80-
ccfg := makeRPCClientConfig(cfg)
81-
return rpc.NewClientConn(ctx, ccfg)
76+
if err != nil {
77+
return nil, nil, errors.Wrap(err, "failed to connect to the node")
78+
}
79+
return &grpcConn{conn: cc}, finish, nil
8280
}
8381

84-
// getAdminClient returns an AdminClient and a closure that must be invoked
85-
// to free associated resources.
86-
func getAdminClient(ctx context.Context, cfg server.Config) (serverpb.AdminClient, func(), error) {
87-
conn, finish, err := getClientGRPCConn(ctx, cfg)
82+
// dialAdminClient dials a client connection and returns an AdminClient and a
83+
// closure that must be invoked to free associated resources.
84+
func dialAdminClient(ctx context.Context, cfg server.Config) (serverpb.AdminClient, func(), error) {
85+
cc, finish, err := newClientConn(ctx, cfg)
8886
if err != nil {
89-
return nil, nil, errors.Wrap(err, "failed to connect to the node")
87+
return nil, nil, err
9088
}
91-
return serverpb.NewAdminClient(conn), finish, nil
89+
return cc.NewAdminClient(), finish, nil
9290
}

pkg/crosscluster/logical/logical_replication_job_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ func TestRandomTables(t *testing.T) {
913913
rng,
914914
tableName,
915915
1,
916-
randgen.TableOptSkipColumnFamilyMutations)
916+
[]randgen.TableOption{randgen.WithSkipColumnFamilyMutations()})
917917
stmt := tree.SerializeForDisplay(createStmt)
918918
t.Log(stmt)
919919
runnerA.Exec(t, stmt)

0 commit comments

Comments
 (0)