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

config(dm): fix can't downgrade config #4936

Merged
merged 4 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 21 additions & 2 deletions dm/dm/config/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,25 @@ func NewMySQLInstancesForDowngrade(mysqlInstances []*MySQLInstance) []*MySQLInst
return mysqlInstancesForDowngrade
}

// LoaderConfigForDowngrade is the base configuration for loader in v2.0.
// This config is used for downgrade(config export) from a higher dmctl version.
// When we add any new config item into LoaderConfig, we should update it also.
type LoaderConfigForDowngrade struct {
PoolSize int `yaml:"pool-size" toml:"pool-size" json:"pool-size"`
Dir string `yaml:"dir" toml:"dir" json:"dir"`
}

func NewLoaderConfigForDowngrade(loaderConfigs map[string]*LoaderConfig) map[string]*LoaderConfigForDowngrade {
loaderConfigsForDowngrade := make(map[string]*LoaderConfigForDowngrade, len(loaderConfigs))
for k, v := range loaderConfigs {
loaderConfigsForDowngrade[k] = &LoaderConfigForDowngrade{
PoolSize: v.PoolSize,
Dir: v.Dir,
}
}
return loaderConfigsForDowngrade
}

// SyncerConfigForDowngrade is the base configuration for syncer in v2.0.
// This config is used for downgrade(config export) from a higher dmctl version.
// When we add any new config item into SyncerConfig, we should update it also.
Expand Down Expand Up @@ -1057,7 +1076,7 @@ type TaskConfigForDowngrade struct {
BWList map[string]*filter.Rules `yaml:"black-white-list"`
BAList map[string]*filter.Rules `yaml:"block-allow-list"`
Mydumpers map[string]*MydumperConfig `yaml:"mydumpers"`
Loaders map[string]*LoaderConfig `yaml:"loaders"`
Loaders map[string]*LoaderConfigForDowngrade `yaml:"loaders"`
Syncers map[string]*SyncerConfigForDowngrade `yaml:"syncers"`
CleanDumpFile bool `yaml:"clean-dump-file"`
EnableANSIQuotes bool `yaml:"ansi-quotes"`
Expand Down Expand Up @@ -1092,7 +1111,7 @@ func NewTaskConfigForDowngrade(taskConfig *TaskConfig) *TaskConfigForDowngrade {
BWList: taskConfig.BWList,
BAList: taskConfig.BAList,
Mydumpers: taskConfig.Mydumpers,
Loaders: taskConfig.Loaders,
Loaders: NewLoaderConfigForDowngrade(taskConfig.Loaders),
Syncers: NewSyncerConfigsForDowngrade(taskConfig.Syncers),
CleanDumpFile: taskConfig.CleanDumpFile,
EnableANSIQuotes: taskConfig.EnableANSIQuotes,
Expand Down
2 changes: 0 additions & 2 deletions dm/tests/new_relay/configs/tasks/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ loaders:
load-01:
pool-size: 16
dir: ./dumped_data
import-mode: sql
on-duplicate: replace
syncers:
sync-01:
meta-file: ""
Expand Down