Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Vitess Dependency to Latest #515

Merged
merged 4 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
sigs.k8s.io/controller-runtime v0.14.3
sigs.k8s.io/controller-tools v0.11.3
sigs.k8s.io/kustomize v2.0.3+incompatible
vitess.io/vitess v0.10.3-0.20231215192727-7c9fec7205cb
vitess.io/vitess v0.10.3-0.20231222054134-d807985131ed
)

require (
Expand Down Expand Up @@ -148,7 +148,7 @@ require (
go.uber.org/zap v1.24.0 // indirect
go4.org/intern v0.0.0-20230205224052-192e9f60865c // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230426161633-7e06285ff160 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.19.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -1186,5 +1186,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ih
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
vitess.io/vitess v0.10.3-0.20231215192727-7c9fec7205cb h1:dNI30GuQx70LgnhhJaPAOyzF1DkNuTgpypAJ2OrGM30=
vitess.io/vitess v0.10.3-0.20231215192727-7c9fec7205cb/go.mod h1:klf5QIzty1+nq+FXHFmimgRA5lh4DhP9edrrKPGDNgY=
vitess.io/vitess v0.10.3-0.20231222054134-d807985131ed h1:XHwJFwKTCWu2Mo3B8+41TOVGzGTHIzqU69yG+TmUSlM=
vitess.io/vitess v0.10.3-0.20231222054134-d807985131ed/go.mod h1:fIPsR9+FuCA/QwknylRPp0buFk41Tl9KNhOQPQTm+5Y=
14 changes: 13 additions & 1 deletion pkg/controller/vitesskeyspace/reconcile_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vttablet/tmclient"
"vitess.io/vitess/go/vt/wrangler"

Expand Down Expand Up @@ -74,9 +77,18 @@ func (r *reconcileHandler) tsInit(ctx context.Context) error {
r.tmc = tmclient.NewTabletManagerClient()
}

collationEnv := collations.NewEnvironment(servenv.MySQLServerVersion())
parser, err := sqlparser.New(sqlparser.Options{
MySQLServerVersion: servenv.MySQLServerVersion(),
TruncateUILen: servenv.TruncateUILen,
TruncateErrLen: servenv.TruncateErrLen,
})
if err != nil {
return err
}
// Wrangler wraps the necessary clients and implements
// multi-step Vitess cluster management workflows.
wr := wrangler.New(logutil.NewConsoleLogger(), r.ts.Server, r.tmc)
wr := wrangler.New(logutil.NewConsoleLogger(), r.ts.Server, r.tmc, collationEnv, parser)
r.wr = wr

return nil
Expand Down
18 changes: 15 additions & 3 deletions pkg/controller/vitessshard/reconcile_topo.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
"strings"
"time"

"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/topo/topoproto"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -63,7 +66,16 @@ func (r *ReconcileVitessShard) reconcileTopology(ctx context.Context, vts *plane
return resultBuilder.RequeueAfter(topoRequeueDelay)
}
defer ts.Close()
wr := wrangler.New(logutil.NewConsoleLogger(), ts.Server, nil)
collationEnv := collations.NewEnvironment(servenv.MySQLServerVersion())
parser, err := sqlparser.New(sqlparser.Options{
MySQLServerVersion: servenv.MySQLServerVersion(),
TruncateUILen: servenv.TruncateUILen,
TruncateErrLen: servenv.TruncateErrLen,
})
if err != nil {
return resultBuilder.Error(err)
}
wr := wrangler.New(logutil.NewConsoleLogger(), ts.Server, nil, collationEnv, parser)

// Get the shard record.
if shard, err := ts.GetShard(ctx, keyspaceName, vts.Spec.Name); err == nil {
Expand Down Expand Up @@ -168,8 +180,8 @@ func (r *ReconcileVitessShard) pruneShardCells(ctx context.Context, vts *planets
Keyspace: keyspaceName,
ShardName: vts.Spec.Name,
Cell: cellName,
Force: false /* force */,
Recursive: false /* recursive */,
Force: false, /* force */
Recursive: false, /* recursive */
}); err != nil {
r.recorder.Eventf(vts, corev1.EventTypeWarning, "TopoCleanupFailed", "unable to remove cell %s from shard: %v", cellName, err)
resultBuilder.RequeueAfter(topoRequeueDelay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (
"time"

"github.com/sirupsen/logrus"
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/sqlparser"

"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/vttablet/tmclient"
Expand Down Expand Up @@ -195,9 +198,18 @@ func (r *ReconcileVitessShard) Reconcile(cctx context.Context, request reconcile
tmc := tmclient.NewTabletManagerClient()
defer tmc.Close()

collationEnv := collations.NewEnvironment(servenv.MySQLServerVersion())
parser, err := sqlparser.New(sqlparser.Options{
MySQLServerVersion: servenv.MySQLServerVersion(),
TruncateUILen: servenv.TruncateUILen,
TruncateErrLen: servenv.TruncateErrLen,
})
if err != nil {
return resultBuilder.Error(err)
}
// Wrangler wraps the necessary clients and implements
// multi-step Vitess cluster management workflows.
wr := wrangler.New(logutil.NewConsoleLogger(), ts.Server, tmc)
wr := wrangler.New(logutil.NewConsoleLogger(), ts.Server, tmc, collationEnv, parser)

// Initialize replication if it has not already been started.
initReplicationResult, err := r.initReplication(ctx, vts, wr)
Expand Down
14 changes: 13 additions & 1 deletion pkg/operator/vitesstopo/prune_keyspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/wrangler"

Expand Down Expand Up @@ -91,9 +94,18 @@ func KeyspacesToPrune(keyspaceNames []string, desiredKeyspaces sets.String, orph
func DeleteKeyspaces(ctx context.Context, ts *topo.Server, recorder record.EventRecorder, eventObj runtime.Object, keyspaceNames []string) (reconcile.Result, error) {
resultBuilder := &results.Builder{}

collationEnv := collations.NewEnvironment(servenv.MySQLServerVersion())
parser, err := sqlparser.New(sqlparser.Options{
MySQLServerVersion: servenv.MySQLServerVersion(),
TruncateUILen: servenv.TruncateUILen,
TruncateErrLen: servenv.TruncateErrLen,
})
if err != nil {
return resultBuilder.Error(err)
}
// We use the Vitess wrangler (multi-step command executor) to recursively delete the keyspace.
// This is equivalent to `vtctl DeleteKeyspace -recursive`.
wr := wrangler.New(logutil.NewConsoleLogger(), ts, nil)
wr := wrangler.New(logutil.NewConsoleLogger(), ts, nil, collationEnv, parser)

for _, name := range keyspaceNames {
// Before we delete a keyspace, we must delete vschema for this operation to be idempotent.
Expand Down
15 changes: 14 additions & 1 deletion pkg/operator/vitesstopo/prune_shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/wrangler"

Expand Down Expand Up @@ -83,9 +86,19 @@ func ShardsToPrune(currentShards []string, desiredShards sets.String, orphanedSh
func DeleteShards(ctx context.Context, ts *topo.Server, recorder record.EventRecorder, eventObj runtime.Object, keyspaceName string, shardNames []string) (reconcile.Result, error) {
resultBuilder := &results.Builder{}

collationEnv := collations.NewEnvironment(servenv.MySQLServerVersion())
parser, err := sqlparser.New(sqlparser.Options{
MySQLServerVersion: servenv.MySQLServerVersion(),
TruncateUILen: servenv.TruncateUILen,
TruncateErrLen: servenv.TruncateErrLen,
})
if err != nil {
return resultBuilder.Error(err)
}

// We use the Vitess wrangler (multi-step command executor) to recursively delete the shard.
// This is equivalent to `vtctl DeleteShard -recursive`.
wr := wrangler.New(logutil.NewConsoleLogger(), ts, nil)
wr := wrangler.New(logutil.NewConsoleLogger(), ts, nil, collationEnv, parser)

for _, name := range shardNames {
// topo.NoNode is the error type returned if we can't find the shard when deleting. This ensures that this operation is idempotent.
Expand Down
Loading