Skip to content

Commit

Permalink
config(dm): fix can't downgrade config (#4936)
Browse files Browse the repository at this point in the history
ref #4287
  • Loading branch information
lance6716 authored Mar 17, 2022
1 parent 233ab57 commit d61f8e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
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

0 comments on commit d61f8e0

Please sign in to comment.