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

[fix]getClusterPool: performing a type conversion on a nil. #309

Merged
merged 2 commits into from
Nov 22, 2023
Merged
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
16 changes: 13 additions & 3 deletions cli/command/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ var (
)

type migrateOptions struct {
filename string
filename string
poolset string
poolsetDiskType string
}

func NewMigrateCommand(curveadm *cli.CurveAdm) *cobra.Command {
Expand All @@ -120,6 +122,10 @@ func NewMigrateCommand(curveadm *cli.CurveAdm) *cobra.Command {
DisableFlagsInUseLine: true,
}

flags := cmd.Flags()
flags.StringVar(&options.poolset, "poolset", "default", "Specify the poolset")
flags.StringVar(&options.poolsetDiskType, "poolset-disktype", "ssd", "Specify the disk type of physical pool")

return cmd
}

Expand Down Expand Up @@ -178,13 +184,15 @@ func getMigrates(curveadm *cli.CurveAdm, data string) []*configure.MigrateServer
}

func genMigratePlaybook(curveadm *cli.CurveAdm,
dcs []*topology.DeployConfig, data string) (*playbook.Playbook, error) {
dcs []*topology.DeployConfig, options migrateOptions, data string) (*playbook.Playbook, error) {
diffs, _ := diffTopology(curveadm, data)
dcs2add := diffs[topology.DIFF_ADD]
dcs2del := diffs[topology.DIFF_DELETE]
migrates := getMigrates(curveadm, data)
role := migrates[0].From.GetRole()
steps := MIGRATE_ROLE_STEPS[role]
poolset := options.poolset
poolsetDiskType := options.poolsetDiskType

pb := playbook.NewPlaybook(curveadm)
for _, step := range steps {
Expand All @@ -210,6 +218,8 @@ func genMigratePlaybook(curveadm *cli.CurveAdm,
case playbook.CREATE_PHYSICAL_POOL:
options[comm.KEY_CREATE_POOL_TYPE] = comm.POOL_TYPE_PHYSICAL
options[comm.KEY_MIGRATE_SERVERS] = migrates
options[comm.POOLSET] = poolset
options[comm.POOLSET_DISK_TYPE] = poolsetDiskType
case playbook.CREATE_LOGICAL_POOL:
options[comm.KEY_CREATE_POOL_TYPE] = comm.POOL_TYPE_LOGICAL
options[comm.KEY_MIGRATE_SERVERS] = migrates
Expand Down Expand Up @@ -270,7 +280,7 @@ func runMigrate(curveadm *cli.CurveAdm, options migrateOptions) error {
}

// 6) generate migrate playbook
pb, err := genMigratePlaybook(curveadm, dcs, data)
pb, err := genMigratePlaybook(curveadm, dcs, options, data)
if err != nil {
return err
}
Expand Down