Skip to content

Commit

Permalink
[fix]getClusterPool: performing a type conversion on a nil.
Browse files Browse the repository at this point in the history
fix curveadm is performing a type conversion on a nil.
Solution: Add poolset and diskType to the option choices.
Signed-off-by: sjf <[email protected]>
  • Loading branch information
Songjf-ttk committed Sep 18, 2023
1 parent 956c953 commit ae49c7a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cli/command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ func genDeployPlaybook(curveadm *cli.CurveAdm,
options[comm.POOLSET_DISK_TYPE] = diskType
} else if step == CREATE_LOGICAL_POOL {
options[comm.KEY_CREATE_POOL_TYPE] = comm.POOL_TYPE_LOGICAL
options[comm.POOLSET] = poolset
options[comm.POOLSET_DISK_TYPE] = diskType
}

pb.AddStep(&playbook.PlaybookStep{
Expand Down
16 changes: 14 additions & 2 deletions cli/command/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ var (

type migrateOptions struct {
filename string

Check failure on line 106 in cli/command/migrate.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofmt`-ed with `-s` (gofmt)
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,10 +218,14 @@ 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
options[comm.KEY_NEW_TOPOLOGY_DATA] = data
options[comm.POOLSET] = poolset
options[comm.POOLSET_DISK_TYPE] = poolsetDiskType
case playbook.UPDATE_TOPOLOGY:
options[comm.KEY_NEW_TOPOLOGY_DATA] = data
}
Expand Down Expand Up @@ -270,7 +282,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

0 comments on commit ae49c7a

Please sign in to comment.