From f1d094f501f356cab2469a4bc6b999e384517dbe Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 18 Jan 2024 13:53:42 -0600 Subject: [PATCH 1/8] add mysql_server_version flag to vtgate Signed-off-by: Florent Poinsard --- Makefile | 2 +- go.mod | 30 ++-- go.sum | 20 +++ pkg/controller/vitesscell/reconcile_vtgate.go | 6 +- .../vitesscell/vitesscell_controller.go | 13 +- .../vitessshardreplication/reconcile_drain.go | 99 +------------ pkg/operator/mysql/mysql.go | 133 ++++++++++++++++++ .../mysql/mysql_test.go} | 4 +- pkg/operator/vtgate/deployment.go | 16 ++- 9 files changed, 201 insertions(+), 122 deletions(-) create mode 100644 pkg/operator/mysql/mysql.go rename pkg/{controller/vitessshardreplication/reconcile_drain_test.go => operator/mysql/mysql_test.go} (97%) diff --git a/Makefile b/Makefile index 29cc2164..76f7d37a 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ IMAGE_REGISTRY:=docker.io IMAGE_TAG:=latest -IMAGE:=planetscale/vitess-operator +IMAGE:=frouioui/vitess-operator IMAGE_NAME:=$(IMAGE_REGISTRY)/$(IMAGE) diff --git a/go.mod b/go.mod index 00e5da49..7abedcd6 100644 --- a/go.mod +++ b/go.mod @@ -21,11 +21,11 @@ require ( sigs.k8s.io/controller-runtime v0.16.3 sigs.k8s.io/controller-tools v0.11.3 sigs.k8s.io/kustomize v2.0.3+incompatible - vitess.io/vitess v0.10.3-0.20240112195828-c53420174d46 + vitess.io/vitess v0.10.3-0.20240118194106-4c36f2aa6469 ) require ( - cloud.google.com/go v0.111.0 // indirect + cloud.google.com/go v0.112.0 // indirect cloud.google.com/go/compute v1.23.3 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.5 // indirect @@ -44,7 +44,7 @@ require ( github.com/Microsoft/go-winio v0.6.1 // indirect github.com/aquarapid/vaultlib v0.5.1 // indirect github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go v1.49.16 // indirect + github.com/aws/aws-sdk-go v1.49.20 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect @@ -55,7 +55,7 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/ebitengine/purego v0.5.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch v5.7.0+incompatible // indirect + github.com/evanphx/json-patch v5.8.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/fatih/color v1.16.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -128,7 +128,7 @@ require ( github.com/planetscale/pargzip v0.0.0-20201116224723-90c7fc03ea8a // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/common v0.46.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect @@ -161,27 +161,27 @@ require ( go.uber.org/zap v1.26.0 // indirect go4.org/intern v0.0.0-20230525184215-6c62f75575cb // indirect go4.org/unsafe/assume-no-moving-gc v0.0.0-20231121144256-b99613f794b6 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.19.0 // indirect - golang.org/x/oauth2 v0.15.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.16.0 // indirect golang.org/x/term v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.16.1 // indirect + golang.org/x/tools v0.17.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/api v0.155.0 // indirect + google.golang.org/api v0.156.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect + google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect google.golang.org/grpc v1.60.1 // indirect google.golang.org/protobuf v1.32.0 // indirect - gopkg.in/DataDog/dd-trace-go.v1 v1.58.1 // indirect + gopkg.in/DataDog/dd-trace-go.v1 v1.59.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 15c1ff8a..6c674a52 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.111.0 h1:YHLKNupSD1KqjDbQ3+LVdQ81h/UJbJyZG203cEfnQgM= cloud.google.com/go v0.111.0/go.mod h1:0mibmpKP1TyOOFYQY5izo0LnT+ecvOQ0Sg3OdmMiNRU= +cloud.google.com/go v0.112.0/go.mod h1:3jEEVwZ/MHU4djK5t5RHuKOA/GbLddgTdVubX1qnPD4= cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk= cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= @@ -73,6 +74,7 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aws/aws-sdk-go v1.49.16 h1:KAQwhLg296hfffRdh+itA9p7Nx/3cXS/qOa3uF9ssig= github.com/aws/aws-sdk-go v1.49.16/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.20/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -123,6 +125,8 @@ github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBF github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch v5.8.0+incompatible h1:1Av9pn2FyxPdvrWNQszj1g6D6YthSmvCfcN6SYclTJg= +github.com/evanphx/json-patch v5.8.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= @@ -446,6 +450,7 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= @@ -549,6 +554,7 @@ go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ3 go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= +go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -584,9 +590,11 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 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/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -620,9 +628,11 @@ golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= +golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -703,6 +713,7 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -713,6 +724,7 @@ gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/api v0.155.0 h1:vBmGhCYs0djJttDNynWo44zosHlPvHmA0XiN2zP2DtA= google.golang.org/api v0.155.0/go.mod h1:GI5qK5f40kCpHfPn6+YzGAByIKWv8ujFnmoWm7Igduk= +google.golang.org/api v0.156.0/go.mod h1:bUSmn4KFO0Q+69zo9CNIDp4Psi6BqM0np0CbzKRSiSY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= @@ -723,10 +735,13 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 h1:nz5NESFLZbJGPFxDT/HCn+V1mZ8JGNoY4nUpmW/Y2eg= google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917/go.mod h1:pZqR+glSb11aJ+JQcczCvgf47+duRuzNSKqE8YAQnV0= +google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 h1:rcS6EyEaoCO52hQDupoSfrxI3R6C2Tq741is7X8OvnM= google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917/go.mod h1:CmlNWB9lSezaYELKS5Ym1r44VrrbPUa7JTvw+6MbpJ0= +google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:B5xPO//w8qmBDjGReYLpR6UJPnkldGkCSMoH/2vxJeg= google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= @@ -754,6 +769,7 @@ google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7 google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/DataDog/dd-trace-go.v1 v1.58.1 h1:zhVNyN5V9G7LVuDh44q3wkcbQwtjIsmmUCieayojNYo= gopkg.in/DataDog/dd-trace-go.v1 v1.58.1/go.mod h1:SmnEjjV9ZQr4MWRSUYEpoPyNtmtRK5J6UuJdAma+Yxw= +gopkg.in/DataDog/dd-trace-go.v1 v1.59.0/go.mod h1:7zSfmC8eQQ/37+e5ID+gBX7v+MUa+1XgN6HzxLNF0mo= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -831,3 +847,7 @@ sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= vitess.io/vitess v0.10.3-0.20240112195828-c53420174d46 h1:Hlh5hJg4qvjhlprzTCmHIbP6AAlgE5SiHQy61sTb0Hs= vitess.io/vitess v0.10.3-0.20240112195828-c53420174d46/go.mod h1:h03CHnbFzUMOVVxA9hLgBircydRKqeeyjhDqBjZmp+0= +vitess.io/vitess v0.10.3-0.20240118175459-c7c7ddeef557 h1:Y4yOB4bsr/NYjItkrVxzFgVz2riD4Rj/ovYF3nopcK8= +vitess.io/vitess v0.10.3-0.20240118175459-c7c7ddeef557/go.mod h1:W7loalC1u4Ke/QdTHZLKqUzmgN2Qr4+491q8ClTn7xY= +vitess.io/vitess v0.10.3-0.20240118194106-4c36f2aa6469 h1:qz8sZpGZuNDVw/khgIfcRa3Pi+E1LzLilyoW/epYPFQ= +vitess.io/vitess v0.10.3-0.20240118194106-4c36f2aa6469/go.mod h1:W7loalC1u4Ke/QdTHZLKqUzmgN2Qr4+491q8ClTn7xY= diff --git a/pkg/controller/vitesscell/reconcile_vtgate.go b/pkg/controller/vitesscell/reconcile_vtgate.go index 70559fcc..136e5055 100644 --- a/pkg/controller/vitesscell/reconcile_vtgate.go +++ b/pkg/controller/vitesscell/reconcile_vtgate.go @@ -71,7 +71,7 @@ func (m *secretCellsMapper) Map(ctx context.Context, obj client.Object) []reconc return requests } -func (r *ReconcileVitessCell) reconcileVtgate(ctx context.Context, vtc *planetscalev2.VitessCell) (reconcile.Result, error) { +func (r *ReconcileVitessCell) reconcileVtgate(ctx context.Context, vtc *planetscalev2.VitessCell, mysqldImage string) (reconcile.Result, error) { clusterName := vtc.Labels[planetscalev2.ClusterLabel] key := client.ObjectKey{Namespace: vtc.Namespace, Name: vtgate.ServiceName(clusterName, vtc.Spec.Name)} @@ -151,11 +151,11 @@ func (r *ReconcileVitessCell) reconcileVtgate(ctx context.Context, vtc *planetsc Kind: &appsv1.Deployment{}, New: func(key client.ObjectKey) runtime.Object { - return vtgate.NewDeployment(key, spec) + return vtgate.NewDeployment(key, spec, mysqldImage) }, UpdateInPlace: func(key client.ObjectKey, obj runtime.Object) { newObj := obj.(*appsv1.Deployment) - vtgate.UpdateDeployment(newObj, spec) + vtgate.UpdateDeployment(newObj, spec, mysqldImage) }, Status: func(key client.ObjectKey, obj runtime.Object) { curObj := obj.(*appsv1.Deployment) diff --git a/pkg/controller/vitesscell/vitesscell_controller.go b/pkg/controller/vitesscell/vitesscell_controller.go index a0f62d75..ab3a5686 100644 --- a/pkg/controller/vitesscell/vitesscell_controller.go +++ b/pkg/controller/vitesscell/vitesscell_controller.go @@ -181,6 +181,17 @@ func (r *ReconcileVitessCell) Reconcile(cctx context.Context, request reconcile. return resultBuilder.Error(err) } + // Fetch the VitessShard instance + vts := &planetscalev2.VitessShard{} + err = r.client.Get(ctx, request.NamespacedName, vts) + if err != nil { + if apierrors.IsNotFound(err) { + return resultBuilder.Result() + } + // Error reading the object - requeue the request. + return resultBuilder.Error(err) + } + // Reset status so it's all based on the latest observed state. oldStatus := vtc.Status vtc.Status = planetscalev2.NewVitessCellStatus() @@ -196,7 +207,7 @@ func (r *ReconcileVitessCell) Reconcile(cctx context.Context, request reconcile. } // Create/update vtgate deployments. - vtgateResult, err := r.reconcileVtgate(ctx, vtc) + vtgateResult, err := r.reconcileVtgate(ctx, vtc, vts.Spec.Images.Mysqld.Image()) resultBuilder.Merge(vtgateResult, err) // Check which VitessKeyspaces are deployed to this cell. diff --git a/pkg/controller/vitessshardreplication/reconcile_drain.go b/pkg/controller/vitessshardreplication/reconcile_drain.go index a06ae282..3eca8fd4 100644 --- a/pkg/controller/vitessshardreplication/reconcile_drain.go +++ b/pkg/controller/vitessshardreplication/reconcile_drain.go @@ -19,13 +19,10 @@ package vitessshardreplication import ( "context" "fmt" - "regexp" - "slices" - "strconv" - "strings" "time" "github.com/sirupsen/logrus" + "planetscale.dev/vitess-operator/pkg/operator/mysql" "vitess.io/vitess/go/mysql/replication" "vitess.io/vitess/go/vt/proto/tabletmanagerdata" topodatapb "vitess.io/vitess/go/vt/proto/topodata" @@ -508,7 +505,7 @@ func (r *ReconcileVitessShard) disableFastShutdown( } } - needsSafe, err := safeMysqldUpgrade(current, desiredImage) + needsSafe, err := mysql.DockerImageSafeUpgrade(current, desiredImage) if err != nil { return err } @@ -527,98 +524,6 @@ func (r *ReconcileVitessShard) disableFastShutdown( return nil } -var mysqlImageVersion = regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)`) - -func safeMysqldUpgrade(currentImage, desiredImage string) (bool, error) { - if currentImage == "" || desiredImage == "" { - // No action if we have unknown versions. - return false, nil - } - - // Quick check so no regexp matching is needed for the most common - // case where nothing changes. - if desiredImage == currentImage { - return false, nil - } - - currentParts := strings.SplitN(currentImage, ":", 2) - if len(currentParts) != 2 { - return false, nil - } - - desiredParts := strings.SplitN(desiredImage, ":", 2) - if len(desiredParts) != 2 { - return false, nil - } - - current := currentParts[1] - desired := desiredParts[1] - - curStrParts := mysqlImageVersion.FindStringSubmatch(current) - if len(curStrParts) != 4 { - // Invalid version, assume that we need to do a safe upgrade. - return true, nil - } - dstStrParts := mysqlImageVersion.FindStringSubmatch(desired) - if len(dstStrParts) != 4 { - // Invalid version, assume that we need to do a safe upgrade. - return true, nil - } - if slices.Equal(curStrParts, dstStrParts) { - return false, nil - } - dstParts := make([]int, len(dstStrParts)-1) - curParts := make([]int, len(curStrParts)-1) - for i, part := range dstStrParts[1:] { - // We already matched with `\d_` so there's no - // way this can trigger an error. - dstParts[i], _ = strconv.Atoi(part) - } - - for i, part := range curStrParts[1:] { - // We already matched with `\d_` so there's no - // way this can trigger an error. - curParts[i], _ = strconv.Atoi(part) - } - - if dstParts[0] < curParts[0] { - return false, fmt.Errorf("cannot downgrade major version from %s to %s", current, desired) - } - if dstParts[0] == curParts[1] && dstParts[1] < curParts[1] { - return false, fmt.Errorf("cannot downgrade minor version from %s to %s", current, desired) - } - - // Alright, here it gets more tricky. MySQL has had a complicated release history. For the 8.0 series, - // up to 8.0.34 at least (known at this point), it was not supported to downgrade patch releases - // as patch release could also include on-disk data format changes. This happened a number of times - // in practice as well, so this concern is real. - // - // MySQL though has announced a new release strategy, see: - // https://dev.mysql.com/blog-archive/introducing-mysql-innovation-and-long-term-support-lts-versions/ - // - // With that release strategy, it will become possible that patch releases will be safe to downgrade - // as well and since the data format doesn't change on-disk anymore, it's also safe to upgrade with - // fast shutdown enabled. - // Specifically, it calls out that "MySQL 8.0.34+ will become bugfix only release (red)". This means - // that we use that version as a cut-off point here for when we need to disable fast shutdown or not. - if dstParts[0] == 8 && dstParts[1] == 0 && curParts[0] == 8 && curParts[1] == 0 { - // Our upgrade process stays within the 8.0.x version range. - if dstParts[2] >= 34 && curParts[2] >= 34 { - // No need for safe upgrade if both versions are 8.0.34 or higher. - return false, nil - } - // We can't downgrade within the 8.0.x series before 8.0.34. - if dstParts[2] < curParts[2] { - return false, fmt.Errorf("cannot downgrade patch version from %s to %s", current, desired) - } - // Always need safe upgrade if we change the patch release for 8.0.x before 8.0.34. - return dstParts[2] != curParts[2], nil - } - - // For any major or minor version change we always need safe upgrade. - return dstParts[0] != curParts[0] || dstParts[1] != curParts[1], nil -} - type candidateInfo struct { tablet *topo.TabletInfo position replication.Position diff --git a/pkg/operator/mysql/mysql.go b/pkg/operator/mysql/mysql.go new file mode 100644 index 00000000..1928d5ba --- /dev/null +++ b/pkg/operator/mysql/mysql.go @@ -0,0 +1,133 @@ +/* +Copyright 2024 PlanetScale Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package mysql + +import ( + "fmt" + "regexp" + "slices" + "strconv" + "strings" + + "vitess.io/vitess/go/vt/sqlparser" +) + +var imageVersionRegExp = regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)`) + +func DockerImageGetVersionToString(currentVersionImage string) (string, error) { + currentVersionSlice := strings.SplitN(currentVersionImage, ":", 2) + if len(currentVersionSlice) != 2 { + return "", fmt.Errorf("could not parse the image name and image label, got: %s, but expected xx:xx", currentVersionImage) + } + + label := currentVersionSlice[1] + _, err := sqlparser.ConvertMySQLVersionToCommentVersion(label) + if err != nil { + return "", err + } + return fmt.Sprintf("%s-Vitess", label), nil +} + +func DockerImageSafeUpgrade(currentVersionImage, desiredVersionImage string) (bool, error) { + if currentVersionImage == "" || desiredVersionImage == "" { + // No action if we have unknown versions. + return false, nil + } + + // Quick check so no regexp matching is needed for the most common + // case where nothing changes. + if desiredVersionImage == currentVersionImage { + return false, nil + } + + currentParts := strings.SplitN(currentVersionImage, ":", 2) + if len(currentParts) != 2 { + return false, nil + } + + desiredParts := strings.SplitN(desiredVersionImage, ":", 2) + if len(desiredParts) != 2 { + return false, nil + } + + current := currentParts[1] + desired := desiredParts[1] + + curStrParts := imageVersionRegExp.FindStringSubmatch(current) + if len(curStrParts) != 4 { + // Invalid version, assume that we need to do a safe upgrade. + return true, nil + } + dstStrParts := imageVersionRegExp.FindStringSubmatch(desired) + if len(dstStrParts) != 4 { + // Invalid version, assume that we need to do a safe upgrade. + return true, nil + } + if slices.Equal(curStrParts, dstStrParts) { + return false, nil + } + dstParts := make([]int, len(dstStrParts)-1) + curParts := make([]int, len(curStrParts)-1) + for i, part := range dstStrParts[1:] { + // We already matched with `\d_` so there's no + // way this can trigger an error. + dstParts[i], _ = strconv.Atoi(part) + } + + for i, part := range curStrParts[1:] { + // We already matched with `\d_` so there's no + // way this can trigger an error. + curParts[i], _ = strconv.Atoi(part) + } + + if dstParts[0] < curParts[0] { + return false, fmt.Errorf("cannot downgrade major version from %s to %s", current, desired) + } + if dstParts[0] == curParts[1] && dstParts[1] < curParts[1] { + return false, fmt.Errorf("cannot downgrade minor version from %s to %s", current, desired) + } + + // Alright, here it gets more tricky. MySQL has had a complicated release history. For the 8.0 series, + // up to 8.0.34 at least (known at this point), it was not supported to downgrade patch releases + // as patch release could also include on-disk data format changes. This happened a number of times + // in practice as well, so this concern is real. + // + // MySQL though has announced a new release strategy, see: + // https://dev.mysql.com/blog-archive/introducing-mysql-innovation-and-long-term-support-lts-versions/ + // + // With that release strategy, it will become possible that patch releases will be safe to downgrade + // as well and since the data format doesn't change on-disk anymore, it's also safe to upgrade with + // fast shutdown enabled. + // Specifically, it calls out that "MySQL 8.0.34+ will become bugfix only release (red)". This means + // that we use that version as a cut-off point here for when we need to disable fast shutdown or not. + if dstParts[0] == 8 && dstParts[1] == 0 && curParts[0] == 8 && curParts[1] == 0 { + // Our upgrade process stays within the 8.0.x version range. + if dstParts[2] >= 34 && curParts[2] >= 34 { + // No need for safe upgrade if both versions are 8.0.34 or higher. + return false, nil + } + // We can't downgrade within the 8.0.x series before 8.0.34. + if dstParts[2] < curParts[2] { + return false, fmt.Errorf("cannot downgrade patch version from %s to %s", current, desired) + } + // Always need safe upgrade if we change the patch release for 8.0.x before 8.0.34. + return dstParts[2] != curParts[2], nil + } + + // For any major or minor version change we always need safe upgrade. + return dstParts[0] != curParts[0] || dstParts[1] != curParts[1], nil +} diff --git a/pkg/controller/vitessshardreplication/reconcile_drain_test.go b/pkg/operator/mysql/mysql_test.go similarity index 97% rename from pkg/controller/vitessshardreplication/reconcile_drain_test.go rename to pkg/operator/mysql/mysql_test.go index 734a4e89..c190dabf 100644 --- a/pkg/controller/vitessshardreplication/reconcile_drain_test.go +++ b/pkg/operator/mysql/mysql_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package vitessshardreplication +package mysql import ( "testing" @@ -132,7 +132,7 @@ func TestSafeMysqldUpgrade(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - needsSafe, err := safeMysqldUpgrade(tt.current, tt.desired) + needsSafe, err := DockerImageSafeUpgrade(tt.current, tt.desired) if tt.err != "" { assert.EqualError(t, err, tt.err) } else { diff --git a/pkg/operator/vtgate/deployment.go b/pkg/operator/vtgate/deployment.go index 3e34f831..8bdf1ae9 100644 --- a/pkg/operator/vtgate/deployment.go +++ b/pkg/operator/vtgate/deployment.go @@ -24,6 +24,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/pointer" + "planetscale.dev/vitess-operator/pkg/operator/mysql" "sigs.k8s.io/controller-runtime/pkg/client" planetscalev2 "planetscale.dev/vitess-operator/pkg/apis/planetscale/v2" @@ -86,7 +87,7 @@ type Spec struct { } // NewDeployment creates a new Deployment object for vtgate. -func NewDeployment(key client.ObjectKey, spec *Spec) *appsv1.Deployment { +func NewDeployment(key client.ObjectKey, spec *Spec, mysqldImage string) *appsv1.Deployment { // Fill in the immutable parts. obj := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ @@ -100,12 +101,12 @@ func NewDeployment(key client.ObjectKey, spec *Spec) *appsv1.Deployment { }, } // Set everything else. - UpdateDeployment(obj, spec) + UpdateDeployment(obj, spec, mysqldImage) return obj } // UpdateDeployment updates the mutable parts of the vtgate Deployment. -func UpdateDeployment(obj *appsv1.Deployment, spec *Spec) { +func UpdateDeployment(obj *appsv1.Deployment, spec *Spec, mysqldImage string) { // Set labels on the Deployment object. update.Labels(&obj.Labels, spec.Labels) @@ -223,6 +224,7 @@ func UpdateDeployment(obj *appsv1.Deployment, spec *Spec) { flags := spec.baseFlags() // Update the Pod template, container, and flags for various optional things. + updateMySQLServerVersion(flags, mysqldImage) updateAuth(spec, flags, vtgateContainer, &obj.Spec.Template.Spec) updateTransport(spec, flags, vtgateContainer, &obj.Spec.Template.Spec) update.Volumes(&obj.Spec.Template.Spec.Volumes, spec.ExtraVolumes) @@ -286,6 +288,14 @@ func (spec *Spec) baseFlags() vitess.Flags { } } +func updateMySQLServerVersion(flags vitess.Flags, mysqldImage string) { + value, err := mysql.DockerImageGetVersionToString(mysqldImage) + if err != nil { + return + } + flags["mysql_server_version"] = value +} + func updateAuth(spec *Spec, flags vitess.Flags, container *corev1.Container, podSpec *corev1.PodSpec) { if spec.Authentication.Static != nil && spec.Authentication.Static.Secret != nil { staticAuthFile := secrets.Mount(spec.Authentication.Static.Secret, staticAuthDirName) From 6a7482f5a08006429d0c5eec26b7b028b8439c67 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 18 Jan 2024 14:16:08 -0600 Subject: [PATCH 2/8] add mysql_server_version flag to vttablet Signed-off-by: Florent Poinsard --- pkg/operator/mysql/mysql.go | 11 ++++++++++- pkg/operator/vtgate/deployment.go | 10 +--------- pkg/operator/vttablet/pod.go | 2 ++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pkg/operator/mysql/mysql.go b/pkg/operator/mysql/mysql.go index 1928d5ba..4a4ca1f9 100644 --- a/pkg/operator/mysql/mysql.go +++ b/pkg/operator/mysql/mysql.go @@ -23,12 +23,21 @@ import ( "strconv" "strings" + "planetscale.dev/vitess-operator/pkg/operator/vitess" "vitess.io/vitess/go/vt/sqlparser" ) var imageVersionRegExp = regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)`) -func DockerImageGetVersionToString(currentVersionImage string) (string, error) { +func UpdateMySQLServerVersion(flags vitess.Flags, mysqldImage string) { + value, err := dockerImageGetVersionToString(mysqldImage) + if err != nil { + return + } + flags["mysql_server_version"] = value +} + +func dockerImageGetVersionToString(currentVersionImage string) (string, error) { currentVersionSlice := strings.SplitN(currentVersionImage, ":", 2) if len(currentVersionSlice) != 2 { return "", fmt.Errorf("could not parse the image name and image label, got: %s, but expected xx:xx", currentVersionImage) diff --git a/pkg/operator/vtgate/deployment.go b/pkg/operator/vtgate/deployment.go index 8bdf1ae9..a2882881 100644 --- a/pkg/operator/vtgate/deployment.go +++ b/pkg/operator/vtgate/deployment.go @@ -224,7 +224,7 @@ func UpdateDeployment(obj *appsv1.Deployment, spec *Spec, mysqldImage string) { flags := spec.baseFlags() // Update the Pod template, container, and flags for various optional things. - updateMySQLServerVersion(flags, mysqldImage) + mysql.UpdateMySQLServerVersion(flags, mysqldImage) updateAuth(spec, flags, vtgateContainer, &obj.Spec.Template.Spec) updateTransport(spec, flags, vtgateContainer, &obj.Spec.Template.Spec) update.Volumes(&obj.Spec.Template.Spec.Volumes, spec.ExtraVolumes) @@ -288,14 +288,6 @@ func (spec *Spec) baseFlags() vitess.Flags { } } -func updateMySQLServerVersion(flags vitess.Flags, mysqldImage string) { - value, err := mysql.DockerImageGetVersionToString(mysqldImage) - if err != nil { - return - } - flags["mysql_server_version"] = value -} - func updateAuth(spec *Spec, flags vitess.Flags, container *corev1.Container, podSpec *corev1.PodSpec) { if spec.Authentication.Static != nil && spec.Authentication.Static.Secret != nil { staticAuthFile := secrets.Mount(spec.Authentication.Static.Secret, staticAuthDirName) diff --git a/pkg/operator/vttablet/pod.go b/pkg/operator/vttablet/pod.go index 392ea282..5e8bdfbe 100644 --- a/pkg/operator/vttablet/pod.go +++ b/pkg/operator/vttablet/pod.go @@ -25,6 +25,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/pointer" + "planetscale.dev/vitess-operator/pkg/operator/mysql" "sigs.k8s.io/controller-runtime/pkg/client" topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/vt/topo/topoproto" @@ -86,6 +87,7 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) { key = strings.TrimLeft(key, "-") vttabletAllFlags[key] = value } + mysql.UpdateMySQLServerVersion(vttabletAllFlags, spec.Images.Mysqld.Image()) // Compute all operator-generated env vars first. env := tabletEnvVars.Get(spec) From 5f7d0b8af3c9256476db1836983dcab91a4a3a73 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 18 Jan 2024 14:20:47 -0600 Subject: [PATCH 3/8] add mysql_server_version flag to vtbackup and mysqlctld Signed-off-by: Florent Poinsard --- pkg/controller/vitessshard/reconcile_backup_job.go | 2 +- pkg/operator/vttablet/pod.go | 5 ++++- pkg/operator/vttablet/vtbackup_pod.go | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/controller/vitessshard/reconcile_backup_job.go b/pkg/controller/vitessshard/reconcile_backup_job.go index a302fb04..ab341cba 100644 --- a/pkg/controller/vitessshard/reconcile_backup_job.go +++ b/pkg/controller/vitessshard/reconcile_backup_job.go @@ -141,7 +141,7 @@ func (r *ReconcileVitessShard) reconcileBackupJob(ctx context.Context, vts *plan Kind: &corev1.Pod{}, New: func(key client.ObjectKey) runtime.Object { - return vttablet.NewBackupPod(key, specMap[key]) + return vttablet.NewBackupPod(key, specMap[key], vts.Spec.Images.Mysqld.Image()) }, Status: func(key client.ObjectKey, obj runtime.Object) { pod := obj.(*corev1.Pod) diff --git a/pkg/operator/vttablet/pod.go b/pkg/operator/vttablet/pod.go index 5e8bdfbe..9dcc25f1 100644 --- a/pkg/operator/vttablet/pod.go +++ b/pkg/operator/vttablet/pod.go @@ -167,13 +167,16 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) { var mysqldContainer *corev1.Container var mysqldExporterContainer *corev1.Container + mysqlctldAllFlags := mysqlctldFlags.Get(spec) + mysql.UpdateMySQLServerVersion(mysqlctldAllFlags, spec.Images.Mysqld.Image()) + if spec.Mysqld != nil { mysqldContainer = &corev1.Container{ Name: MysqldContainerName, Image: spec.Images.Mysqld.Image(), ImagePullPolicy: spec.ImagePullPolicies.Mysqld, Command: []string{mysqldCommand}, - Args: mysqlctldFlags.Get(spec).FormatArgs(), + Args: mysqlctldAllFlags.FormatArgs(), Ports: []corev1.ContainerPort{ { Name: planetscalev2.DefaultMysqlPortName, diff --git a/pkg/operator/vttablet/vtbackup_pod.go b/pkg/operator/vttablet/vtbackup_pod.go index 8dcd80d6..5823cdb1 100644 --- a/pkg/operator/vttablet/vtbackup_pod.go +++ b/pkg/operator/vttablet/vtbackup_pod.go @@ -23,6 +23,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/pointer" + "planetscale.dev/vitess-operator/pkg/operator/mysql" "sigs.k8s.io/controller-runtime/pkg/client" planetscalev2 "planetscale.dev/vitess-operator/pkg/apis/planetscale/v2" @@ -92,7 +93,7 @@ func InitialBackupPodName(clusterName, keyspaceName string, keyRange planetscale // NewBackupPod creates a new vtbackup Pod, which is like a special kind of // minimal tablet used to run backups as a batch process. -func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec) *corev1.Pod { +func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec, mysqldImage string) *corev1.Pod { tabletSpec := backupSpec.TabletSpec // Include vttablet env vars, since we run some vttablet code like backups. @@ -132,6 +133,8 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec) *corev1.Pod { // Make a copy of Resources since it contains pointers. update.ResourceRequirements(&containerResources, &tabletSpec.Mysqld.Resources) + vtbackupAllFlags := vtbackupFlags.Get(backupSpec) + mysql.UpdateMySQLServerVersion(vtbackupAllFlags, mysqldImage) pod := &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Namespace: key.Namespace, @@ -171,7 +174,7 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec) *corev1.Pod { Image: tabletSpec.Images.Mysqld.Image(), ImagePullPolicy: tabletSpec.ImagePullPolicies.Mysqld, Command: []string{vtbackupCommand}, - Args: vtbackupFlags.Get(backupSpec).FormatArgs(), + Args: vtbackupAllFlags.FormatArgs(), Resources: containerResources, SecurityContext: securityContext, Env: env, From 25f08b621b319fa71a68f6b0d2244e6476b1f43d Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 18 Jan 2024 14:27:02 -0600 Subject: [PATCH 4/8] add mysql_server_version flag to vtctld Signed-off-by: Florent Poinsard --- pkg/controller/vitesscluster/reconcile_vtctld.go | 6 +++--- pkg/operator/vtctld/deployment.go | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/controller/vitesscluster/reconcile_vtctld.go b/pkg/controller/vitesscluster/reconcile_vtctld.go index 156a033f..3520544f 100644 --- a/pkg/controller/vitesscluster/reconcile_vtctld.go +++ b/pkg/controller/vitesscluster/reconcile_vtctld.go @@ -84,19 +84,19 @@ func (r *ReconcileVitessCluster) reconcileVtctld(ctx context.Context, vt *planet Kind: &appsv1.Deployment{}, New: func(key client.ObjectKey) runtime.Object { - return vtctld.NewDeployment(key, specMap[key]) + return vtctld.NewDeployment(key, specMap[key], vt.Spec.Images.Mysqld.Image()) }, UpdateInPlace: func(key client.ObjectKey, obj runtime.Object) { newObj := obj.(*appsv1.Deployment) if *vt.Spec.UpdateStrategy.Type == planetscalev2.ImmediateVitessClusterUpdateStrategyType { - vtctld.UpdateDeployment(newObj, specMap[key]) + vtctld.UpdateDeployment(newObj, specMap[key], vt.Spec.Images.Mysqld.Image()) return } vtctld.UpdateDeploymentImmediate(newObj, specMap[key]) }, UpdateRollingInPlace: func(key client.ObjectKey, obj runtime.Object) { newObj := obj.(*appsv1.Deployment) - vtctld.UpdateDeployment(newObj, specMap[key]) + vtctld.UpdateDeployment(newObj, specMap[key], vt.Spec.Images.Mysqld.Image()) }, Status: func(key client.ObjectKey, obj runtime.Object) { // This function will get called once for each Deployment. diff --git a/pkg/operator/vtctld/deployment.go b/pkg/operator/vtctld/deployment.go index 391673e2..5901cf3e 100644 --- a/pkg/operator/vtctld/deployment.go +++ b/pkg/operator/vtctld/deployment.go @@ -24,6 +24,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/pointer" + "planetscale.dev/vitess-operator/pkg/operator/mysql" "sigs.k8s.io/controller-runtime/pkg/client" planetscalev2 "planetscale.dev/vitess-operator/pkg/apis/planetscale/v2" @@ -74,7 +75,7 @@ type Spec struct { } // NewDeployment creates a new Deployment object for vtctld. -func NewDeployment(key client.ObjectKey, spec *Spec) *appsv1.Deployment { +func NewDeployment(key client.ObjectKey, spec *Spec, mysqldImage string) *appsv1.Deployment { // Fill in the immutable parts. obj := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ @@ -88,7 +89,7 @@ func NewDeployment(key client.ObjectKey, spec *Spec) *appsv1.Deployment { }, } // Set everything else. - UpdateDeployment(obj, spec) + UpdateDeployment(obj, spec, mysqldImage) return obj } @@ -104,7 +105,7 @@ func UpdateDeploymentImmediate(obj *appsv1.Deployment, spec *Spec) { // UpdateDeployment updates the mutable parts of the vtctld Deployment // that should be changed as part of a gradual, rolling update. -func UpdateDeployment(obj *appsv1.Deployment, spec *Spec) { +func UpdateDeployment(obj *appsv1.Deployment, spec *Spec, mysqldImage string) { UpdateDeploymentImmediate(obj, spec) // Reset Pod template labels so we remove old ones. @@ -131,6 +132,7 @@ func UpdateDeployment(obj *appsv1.Deployment, spec *Spec) { key = strings.TrimLeft(key, "-") flags[key] = value } + mysql.UpdateMySQLServerVersion(flags, mysqldImage) // Set only the Pod template fields we care about. // Use functions from the `operator/update` package for lists From 3a2729593836b31b1f17e0bc20f59c2b18172743 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 18 Jan 2024 14:29:44 -0600 Subject: [PATCH 5/8] apply go mod tidy Signed-off-by: Florent Poinsard --- go.mod | 1 - go.sum | 50 ++++++++++++++------------------------------------ 2 files changed, 14 insertions(+), 37 deletions(-) diff --git a/go.mod b/go.mod index 7abedcd6..89514e16 100644 --- a/go.mod +++ b/go.mod @@ -107,7 +107,6 @@ require ( github.com/mattn/go-ieproxy v0.0.11 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/minio/minio-go v0.0.0-20190131015406-c8a261de75c1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect diff --git a/go.sum b/go.sum index 6c674a52..e3dba0a6 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,5 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.111.0 h1:YHLKNupSD1KqjDbQ3+LVdQ81h/UJbJyZG203cEfnQgM= -cloud.google.com/go v0.111.0/go.mod h1:0mibmpKP1TyOOFYQY5izo0LnT+ecvOQ0Sg3OdmMiNRU= +cloud.google.com/go v0.112.0 h1:tpFCD7hpHFlQ8yPwT3x+QeXqc2T6+n6T+hmABHfDUSM= cloud.google.com/go v0.112.0/go.mod h1:3jEEVwZ/MHU4djK5t5RHuKOA/GbLddgTdVubX1qnPD4= cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk= cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI= @@ -72,8 +71,7 @@ github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aws/aws-sdk-go v1.49.16 h1:KAQwhLg296hfffRdh+itA9p7Nx/3cXS/qOa3uF9ssig= -github.com/aws/aws-sdk-go v1.49.16/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.20 h1:VgEUq2/ZbUkLbqPyDcxrirfXB+PgiZUUF5XbsgWe2S0= github.com/aws/aws-sdk-go v1.49.20/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -123,8 +121,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= -github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= -github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.8.0+incompatible h1:1Av9pn2FyxPdvrWNQszj1g6D6YthSmvCfcN6SYclTJg= github.com/evanphx/json-patch v5.8.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= @@ -364,8 +360,6 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= @@ -448,8 +442,7 @@ github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cY github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= -github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -552,9 +545,8 @@ go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= -go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= -go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -588,12 +580,10 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -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/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= -golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o= golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -626,12 +616,10 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= -golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= +golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -711,8 +699,7 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -722,8 +709,7 @@ golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSm golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= -google.golang.org/api v0.155.0 h1:vBmGhCYs0djJttDNynWo44zosHlPvHmA0XiN2zP2DtA= -google.golang.org/api v0.155.0/go.mod h1:GI5qK5f40kCpHfPn6+YzGAByIKWv8ujFnmoWm7Igduk= +google.golang.org/api v0.156.0 h1:yloYcGbBtVYjLKQe4enCunxvwn3s2w/XPrrhVf6MsvQ= google.golang.org/api v0.156.0/go.mod h1:bUSmn4KFO0Q+69zo9CNIDp4Psi6BqM0np0CbzKRSiSY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -733,14 +719,11 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 h1:nz5NESFLZbJGPFxDT/HCn+V1mZ8JGNoY4nUpmW/Y2eg= -google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917/go.mod h1:pZqR+glSb11aJ+JQcczCvgf47+duRuzNSKqE8YAQnV0= +google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 h1:/IWabOtPziuXTEtI1KYCpM6Ss7vaAkeMxk+uXV/xvZs= google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 h1:rcS6EyEaoCO52hQDupoSfrxI3R6C2Tq741is7X8OvnM= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917/go.mod h1:CmlNWB9lSezaYELKS5Ym1r44VrrbPUa7JTvw+6MbpJ0= +google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 h1:OPXtXn7fNMaXwO3JvOmF1QyTc00jsSFFz1vXXBOdCDo= google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:B5xPO//w8qmBDjGReYLpR6UJPnkldGkCSMoH/2vxJeg= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 h1:gphdwh0npgs8elJ4T6J+DQJHPVF7RsuJHCfwztUb4J4= google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= @@ -767,8 +750,7 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/DataDog/dd-trace-go.v1 v1.58.1 h1:zhVNyN5V9G7LVuDh44q3wkcbQwtjIsmmUCieayojNYo= -gopkg.in/DataDog/dd-trace-go.v1 v1.58.1/go.mod h1:SmnEjjV9ZQr4MWRSUYEpoPyNtmtRK5J6UuJdAma+Yxw= +gopkg.in/DataDog/dd-trace-go.v1 v1.59.0 h1:W1Bfpc5+m6UdQeZDJg7GczerO2m9KmDw93yGOefRU2c= gopkg.in/DataDog/dd-trace-go.v1 v1.59.0/go.mod h1:7zSfmC8eQQ/37+e5ID+gBX7v+MUa+1XgN6HzxLNF0mo= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -845,9 +827,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.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= -vitess.io/vitess v0.10.3-0.20240112195828-c53420174d46 h1:Hlh5hJg4qvjhlprzTCmHIbP6AAlgE5SiHQy61sTb0Hs= -vitess.io/vitess v0.10.3-0.20240112195828-c53420174d46/go.mod h1:h03CHnbFzUMOVVxA9hLgBircydRKqeeyjhDqBjZmp+0= -vitess.io/vitess v0.10.3-0.20240118175459-c7c7ddeef557 h1:Y4yOB4bsr/NYjItkrVxzFgVz2riD4Rj/ovYF3nopcK8= -vitess.io/vitess v0.10.3-0.20240118175459-c7c7ddeef557/go.mod h1:W7loalC1u4Ke/QdTHZLKqUzmgN2Qr4+491q8ClTn7xY= vitess.io/vitess v0.10.3-0.20240118194106-4c36f2aa6469 h1:qz8sZpGZuNDVw/khgIfcRa3Pi+E1LzLilyoW/epYPFQ= vitess.io/vitess v0.10.3-0.20240118194106-4c36f2aa6469/go.mod h1:W7loalC1u4Ke/QdTHZLKqUzmgN2Qr4+491q8ClTn7xY= From fcc688fb26544b5fb25fcd2e6e304dcd93781c31 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 18 Jan 2024 14:41:35 -0600 Subject: [PATCH 6/8] fix new wrangler calls and set MySQLServerVersion value Signed-off-by: Florent Poinsard --- pkg/controller/vitessshard/reconcile_topo.go | 2 +- .../vitessshardreplication_controller.go | 2 +- pkg/operator/environment/environment.go | 6 +++--- pkg/operator/mysql/mysql.go | 2 ++ pkg/operator/vitesstopo/prune_keyspaces.go | 2 +- pkg/operator/vitesstopo/prune_shards.go | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/controller/vitessshard/reconcile_topo.go b/pkg/controller/vitessshard/reconcile_topo.go index 9769ecc2..c41c9134 100644 --- a/pkg/controller/vitessshard/reconcile_topo.go +++ b/pkg/controller/vitessshard/reconcile_topo.go @@ -68,7 +68,7 @@ func (r *ReconcileVitessShard) reconcileTopology(ctx context.Context, vts *plane if err != nil { return resultBuilder.Error(err) } - wr := wrangler.New(logutil.NewConsoleLogger(), ts.Server, nil, collationEnv, parser) + wr := wrangler.New(logutil.NewConsoleLogger(), ts.Server, nil, collationEnv, parser, environment.MySQLServerVersion) // Get the shard record. if shard, err := ts.GetShard(ctx, keyspaceName, vts.Spec.Name); err == nil { diff --git a/pkg/controller/vitessshardreplication/vitessshardreplication_controller.go b/pkg/controller/vitessshardreplication/vitessshardreplication_controller.go index e9e746a2..c8deb3e3 100644 --- a/pkg/controller/vitessshardreplication/vitessshardreplication_controller.go +++ b/pkg/controller/vitessshardreplication/vitessshardreplication_controller.go @@ -202,7 +202,7 @@ func (r *ReconcileVitessShard) Reconcile(cctx context.Context, request reconcile } // Wrangler wraps the necessary clients and implements // multi-step Vitess cluster management workflows. - wr := wrangler.New(logutil.NewConsoleLogger(), ts.Server, tmc, collationEnv, parser) + wr := wrangler.New(logutil.NewConsoleLogger(), ts.Server, tmc, collationEnv, parser, environment.MySQLServerVersion) // Initialize replication if it has not already been started. initReplicationResult, err := r.initReplication(ctx, vts, wr) diff --git a/pkg/operator/environment/environment.go b/pkg/operator/environment/environment.go index bd9404c1..9dbd9e74 100644 --- a/pkg/operator/environment/environment.go +++ b/pkg/operator/environment/environment.go @@ -33,7 +33,7 @@ import ( var ( reconcileTimeout time.Duration - mySQLServerVersion = "8.0.30-Vitess" + MySQLServerVersion = "8.0.30-Vitess" // truncateUILen truncate queries in debug UIs to the given length. 0 means unlimited. truncateUILen = 512 // truncateErrLen truncate queries in error logs to the given length. 0 means unlimited. @@ -68,9 +68,9 @@ func ReconcileTimeout() time.Duration { // CollationEnvAndParser gets the collation environment and parser to be used in the operator. func CollationEnvAndParser() (*collations.Environment, *sqlparser.Parser, error) { - collationEnv := collations.NewEnvironment(mySQLServerVersion) + collationEnv := collations.NewEnvironment(MySQLServerVersion) parser, err := sqlparser.New(sqlparser.Options{ - MySQLServerVersion: mySQLServerVersion, + MySQLServerVersion: MySQLServerVersion, TruncateUILen: truncateUILen, TruncateErrLen: truncateErrLen, }) diff --git a/pkg/operator/mysql/mysql.go b/pkg/operator/mysql/mysql.go index 4a4ca1f9..16ffb3dd 100644 --- a/pkg/operator/mysql/mysql.go +++ b/pkg/operator/mysql/mysql.go @@ -23,6 +23,7 @@ import ( "strconv" "strings" + "planetscale.dev/vitess-operator/pkg/operator/environment" "planetscale.dev/vitess-operator/pkg/operator/vitess" "vitess.io/vitess/go/vt/sqlparser" ) @@ -35,6 +36,7 @@ func UpdateMySQLServerVersion(flags vitess.Flags, mysqldImage string) { return } flags["mysql_server_version"] = value + environment.MySQLServerVersion = value } func dockerImageGetVersionToString(currentVersionImage string) (string, error) { diff --git a/pkg/operator/vitesstopo/prune_keyspaces.go b/pkg/operator/vitesstopo/prune_keyspaces.go index 445b10a8..c3c92afa 100644 --- a/pkg/operator/vitesstopo/prune_keyspaces.go +++ b/pkg/operator/vitesstopo/prune_keyspaces.go @@ -98,7 +98,7 @@ func DeleteKeyspaces(ctx context.Context, ts *topo.Server, recorder record.Event } // 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, collationEnv, parser) + wr := wrangler.New(logutil.NewConsoleLogger(), ts, nil, collationEnv, parser, environment.MySQLServerVersion) for _, name := range keyspaceNames { // Before we delete a keyspace, we must delete vschema for this operation to be idempotent. diff --git a/pkg/operator/vitesstopo/prune_shards.go b/pkg/operator/vitesstopo/prune_shards.go index 3cb63a7c..b45ef0e6 100644 --- a/pkg/operator/vitesstopo/prune_shards.go +++ b/pkg/operator/vitesstopo/prune_shards.go @@ -91,7 +91,7 @@ func DeleteShards(ctx context.Context, ts *topo.Server, recorder record.EventRec // 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, collationEnv, parser) + wr := wrangler.New(logutil.NewConsoleLogger(), ts, nil, collationEnv, parser, environment.MySQLServerVersion) 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. From 524e7ee99833c010ab196eee0b18f7b472000c2a Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 18 Jan 2024 16:20:55 -0600 Subject: [PATCH 7/8] fix API call to get the VitessShard information in vtgate reconcile loop Signed-off-by: Florent Poinsard --- .../vitesscell/vitesscell_controller.go | 34 ++++++++++++------- .../vitesskeyspace/reconcile_handler.go | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/pkg/controller/vitesscell/vitesscell_controller.go b/pkg/controller/vitesscell/vitesscell_controller.go index ab3a5686..025f7ef9 100644 --- a/pkg/controller/vitesscell/vitesscell_controller.go +++ b/pkg/controller/vitesscell/vitesscell_controller.go @@ -22,6 +22,7 @@ import ( "time" "github.com/sirupsen/logrus" + apilabels "k8s.io/apimachinery/pkg/labels" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -181,17 +182,6 @@ func (r *ReconcileVitessCell) Reconcile(cctx context.Context, request reconcile. return resultBuilder.Error(err) } - // Fetch the VitessShard instance - vts := &planetscalev2.VitessShard{} - err = r.client.Get(ctx, request.NamespacedName, vts) - if err != nil { - if apierrors.IsNotFound(err) { - return resultBuilder.Result() - } - // Error reading the object - requeue the request. - return resultBuilder.Error(err) - } - // Reset status so it's all based on the latest observed state. oldStatus := vtc.Status vtc.Status = planetscalev2.NewVitessCellStatus() @@ -206,8 +196,28 @@ func (r *ReconcileVitessCell) Reconcile(cctx context.Context, request reconcile. resultBuilder.Error(err) } + // List all VitessShard in the same cluster, we do this to determine what is the image used for the mysqld container + // Note that this is cheap because it comes from the local cache. + labels := map[string]string{ + planetscalev2.ClusterLabel: vtc.Labels[planetscalev2.ClusterLabel], + } + opts := &client.ListOptions{ + Namespace: vtc.Namespace, + LabelSelector: apilabels.SelectorFromSet(labels), + } + vts := &planetscalev2.VitessShardList{} + if err := r.client.List(ctx, vts, opts); err != nil { + r.recorder.Eventf(vtc, corev1.EventTypeWarning, "ListFailed", "failed to list VitessShard objects: %v", err) + return resultBuilder.Error(err) + } + + var mysqldImage string + if len(vts.Items) > 0 { + mysqldImage = vts.Items[0].Spec.Images.Mysqld.Image() + } + // Create/update vtgate deployments. - vtgateResult, err := r.reconcileVtgate(ctx, vtc, vts.Spec.Images.Mysqld.Image()) + vtgateResult, err := r.reconcileVtgate(ctx, vtc, mysqldImage) resultBuilder.Merge(vtgateResult, err) // Check which VitessKeyspaces are deployed to this cell. diff --git a/pkg/controller/vitesskeyspace/reconcile_handler.go b/pkg/controller/vitesskeyspace/reconcile_handler.go index fb41cbee..54695b3e 100644 --- a/pkg/controller/vitesskeyspace/reconcile_handler.go +++ b/pkg/controller/vitesskeyspace/reconcile_handler.go @@ -81,7 +81,7 @@ func (r *reconcileHandler) tsInit(ctx context.Context) error { } // Wrangler wraps the necessary clients and implements // multi-step Vitess cluster management workflows. - wr := wrangler.New(logutil.NewConsoleLogger(), r.ts.Server, r.tmc, collationEnv, parser) + wr := wrangler.New(logutil.NewConsoleLogger(), r.ts.Server, r.tmc, collationEnv, parser, environment.MySQLServerVersion) r.wr = wr return nil From bcb703f1ecd1413afba74fc0aeb91e21d366a581 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 18 Jan 2024 16:21:37 -0600 Subject: [PATCH 8/8] revert unwanted change to Makefile Signed-off-by: Florent Poinsard --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 76f7d37a..29cc2164 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ IMAGE_REGISTRY:=docker.io IMAGE_TAG:=latest -IMAGE:=frouioui/vitess-operator +IMAGE:=planetscale/vitess-operator IMAGE_NAME:=$(IMAGE_REGISTRY)/$(IMAGE)