Skip to content

Commit

Permalink
version: prohibit operating TiCDC clusters across major and minor ver…
Browse files Browse the repository at this point in the history
…sions (#2481) (#2599)
  • Loading branch information
ti-chi-bot authored Aug 21, 2021
1 parent eeecc30 commit fea259b
Show file tree
Hide file tree
Showing 30 changed files with 570 additions and 261 deletions.
110 changes: 72 additions & 38 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: integration-tests
# events but only for the master branch
on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
concurrency:
Expand All @@ -20,16 +20,16 @@ jobs:
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.16.4'
go-version: "1.16.4"

- name: Cache Vendor
id: cache-vendor
Expand All @@ -44,8 +44,11 @@ jobs:
- name: Pull images
run: docker-compose -f docker-compose-avro.yml pull --ignore-pull-failures

- name: TiKV version
run: docker run pingcap/tikv:release-4.0-nightly -V
- name: TiDB version
run: |
docker run pingcap/tidb:v5.1.0-nightly -V
docker run pingcap/tikv:v5.1.0-nightly -V
docker run pingcap/pd:v5.1.0-nightly -V
- name: Build Integration Framework
run: |
Expand All @@ -58,6 +61,10 @@ jobs:
cd $GITHUB_WORKSPACE/integration
./integration -protocol=mysql
- name: Try to dump container logs
if: ${{ failure() }}
run: docker-compose -f docker-compose-avro.yml logs -t

- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
Expand All @@ -75,16 +82,16 @@ jobs:
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.16.4'
go-version: "1.16.4"

- name: Cache Vendor
id: cache-vendor
Expand All @@ -99,8 +106,11 @@ jobs:
- name: Pull images
run: docker-compose -f docker-compose-avro.yml pull --ignore-pull-failures

- name: TiKV version
run: docker run pingcap/tikv:release-4.0-nightly -V
- name: TiDB version
run: |
docker run pingcap/tidb:v5.1.0-nightly -V
docker run pingcap/tikv:v5.1.0-nightly -V
docker run pingcap/pd:v5.1.0-nightly -V
- name: Build Integration Framework
run: |
Expand All @@ -113,6 +123,10 @@ jobs:
cd $GITHUB_WORKSPACE/integration
./integration -protocol=simple-mysql-checking-old-value
- name: Try to dump container logs
if: ${{ failure() }}
run: docker-compose -f docker-compose-avro.yml logs -t

- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
Expand All @@ -130,16 +144,16 @@ jobs:
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.16.4'
go-version: "1.16.4"

- name: Cache Vendor
id: cache-vendor
Expand All @@ -154,8 +168,11 @@ jobs:
- name: Pull images
run: docker-compose -f docker-compose-canal.yml pull --ignore-pull-failures

- name: TiKV version
run: docker run pingcap/tikv:release-4.0-nightly -V
- name: TiDB version
run: |
docker run pingcap/tidb:v5.1.0-nightly -V
docker run pingcap/tikv:v5.1.0-nightly -V
docker run pingcap/pd:v5.1.0-nightly -V
- name: Build Integration Framework
run: |
Expand All @@ -168,6 +185,10 @@ jobs:
cd $GITHUB_WORKSPACE/integration
./integration -protocol=canalJson
- name: Try to dump container logs
if: ${{ failure() }}
run: docker-compose -f docker-compose-canal.yml logs -t

- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
Expand All @@ -179,23 +200,22 @@ jobs:
run: |
$GITHUB_WORKSPACE/scripts/canal/canal-local-test.sh down
Canal-integration:
runs-on: ubuntu-latest

steps:
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.16.4'
go-version: "1.16.4"

- name: Cache Vendor
id: cache-vendor
Expand All @@ -210,8 +230,11 @@ jobs:
- name: Pull images
run: docker-compose -f docker-compose-canal.yml pull --ignore-pull-failures

- name: TiKV version
run: docker run pingcap/tikv:release-4.0-nightly -V
- name: TiDB version
run: |
docker run pingcap/tidb:v5.1.0-nightly -V
docker run pingcap/tikv:v5.1.0-nightly -V
docker run pingcap/pd:v5.1.0-nightly -V
- name: Build Integration Framework
run: |
Expand All @@ -224,6 +247,10 @@ jobs:
cd $GITHUB_WORKSPACE/integration
./integration -protocol=canal
- name: Try to dump container logs
if: ${{ failure() }}
run: docker-compose -f docker-compose-canal.yml logs -t

- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
Expand All @@ -241,16 +268,16 @@ jobs:
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
docker volume prune -f
docker image prune -f
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.16.4'
go-version: "1.16.4"

- name: Cache Vendor
id: cache-vendor
Expand All @@ -265,8 +292,11 @@ jobs:
- name: Pull images
run: docker-compose -f docker-compose-avro.yml pull --ignore-pull-failures

- name: TiKV version
run: docker run pingcap/tikv:release-4.0-nightly -V
- name: TiDB version
run: |
docker run pingcap/tidb:v5.1.0-nightly -V
docker run pingcap/tikv:v5.1.0-nightly -V
docker run pingcap/pd:v5.1.0-nightly -V
- name: Build Integration Framework
run: |
Expand All @@ -279,6 +309,10 @@ jobs:
cd $GITHUB_WORKSPACE/integration
./integration
- name: Try to dump container logs
if: ${{ failure() }}
run: docker-compose -f docker-compose-avro.yml logs -t

- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16-alpine as builder
FROM golang:1.16-alpine3.12 as builder
RUN apk add --no-cache git make bash
WORKDIR /go/src/github.com/pingcap/ticdc
COPY . .
Expand Down
53 changes: 36 additions & 17 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var (
captureID string
interval uint
disableGCSafePointCheck bool
disableVersionCheck bool

syncPointEnabled bool
syncPointInterval time.Duration
Expand Down Expand Up @@ -126,6 +127,7 @@ type processorMeta struct {
}

func newCliCommand() *cobra.Command {
verifyCDCClusterVersionList := make([]string, 0)
command := &cobra.Command{
Use: "cli",
Short: "Manage replication task and TiCDC cluster",
Expand Down Expand Up @@ -195,18 +197,25 @@ func newCliCommand() *cobra.Command {
if err != nil {
return errors.Annotatef(err, "fail to open PD client, pd=\"%s\"", cliPdAddr)
}
ctx := defaultContext
errorTiKVIncompatible := true // Error if TiKV is incompatible.
for _, pdEndpoint := range pdEndpoints {
err = version.CheckClusterVersion(ctx, pdCli, pdEndpoint, credential, errorTiKVIncompatible)
if err == nil {
break
checkVersion := needVerifyVersion(cmd, verifyCDCClusterVersionList)
if checkVersion && !disableVersionCheck {
ctx := defaultContext
_, err = verifyAndGetTiCDCClusterVersion(ctx, cdcEtcdCli)
if err != nil {
return err
}
errorTiKVIncompatible := true // Error if TiKV is incompatible.
for _, pdEndpoint := range pdEndpoints {
err = version.CheckClusterVersion(
ctx, pdCli, pdEndpoint, credential, errorTiKVIncompatible)
if err == nil {
break
}
}
if err != nil {
return err
}
}
if err != nil {
return err
}

return nil
},
Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -215,14 +224,24 @@ func newCliCommand() *cobra.Command {
}
},
}
command.AddCommand(
newCaptureCommand(),
newChangefeedCommand(),
newProcessorCommand(),
newUnsafeCommand(),
newTsoCommand(),
)

capture := newCaptureCommand()
command.AddCommand(capture)
verifyCDCClusterVersionList = append(verifyCDCClusterVersionList, capture.Name())

changefeed := newChangefeedCommand()
command.AddCommand(changefeed)
verifyCDCClusterVersionList = append(verifyCDCClusterVersionList, changefeed.Name())

processor := newProcessorCommand()
command.AddCommand(processor)
verifyCDCClusterVersionList = append(verifyCDCClusterVersionList, processor.Name())

// Disable version check to ease internal testing.
command.PersistentFlags().BoolVar(&disableVersionCheck, "disable-version-check", false, "Disable version check")
_ = command.PersistentFlags().MarkHidden("disable-version-check")

command.AddCommand(newUnsafeCommand(), newTsoCommand())
return command
}

Expand Down
15 changes: 9 additions & 6 deletions cmd/client_changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ func newQueryChangefeedCommand() *cobra.Command {
return command
}

func verifyChangefeedParameters(ctx context.Context, cmd *cobra.Command, isCreate bool, credential *security.Credential, captureInfos []*model.CaptureInfo) (*model.ChangeFeedInfo, error) {
func verifyChangefeedParameters(
ctx context.Context, cmd *cobra.Command, isCreate bool,
credential *security.Credential, cdcClusterVer version.TiCDCClusterVersion,
) (*model.ChangeFeedInfo, error) {
if isCreate {
if sinkURI == "" {
return nil, errors.New("Creating changefeed without a sink-uri")
Expand All @@ -264,10 +267,6 @@ func verifyChangefeedParameters(ctx context.Context, cmd *cobra.Command, isCreat
return nil, err
}
}
cdcClusterVer, err := version.GetTiCDCClusterVersion(captureInfos)
if err != nil {
return nil, errors.Trace(err)
}
cfg := config.GetDefaultReplicaConfig()

if !cdcClusterVer.ShouldEnableOldValueByDefault() {
Expand Down Expand Up @@ -474,7 +473,11 @@ func newCreateChangefeedCommand() *cobra.Command {
if err != nil {
return err
}
info, err := verifyChangefeedParameters(ctx, cmd, true /* isCreate */, getCredential(), captureInfos)
cdcClusterVer, err := version.GetTiCDCClusterVersion(captureInfos)
if err != nil {
return err
}
info, err := verifyChangefeedParameters(ctx, cmd, true /* isCreate */, getCredential(), cdcClusterVer)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit fea259b

Please sign in to comment.