mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-30 17:13:08 +08:00
fix(region,host): ceph add enable messenger v2 options (#21445)
This commit is contained in:
@@ -60,9 +60,10 @@ func init() {
|
||||
info := struct {
|
||||
StorageType string `json:"storage_type"`
|
||||
StorageConf struct {
|
||||
Key string `json:"key"`
|
||||
MonHost string `json:"mon_host"`
|
||||
Pool string `json:"pool"`
|
||||
Key string `json:"key"`
|
||||
MonHost string `json:"mon_host"`
|
||||
Pool string `json:"pool"`
|
||||
EnableMessengerV2 bool `json:"enable_messenger_v2"`
|
||||
}
|
||||
}{}
|
||||
err = result.Unmarshal(&info)
|
||||
@@ -76,6 +77,7 @@ func init() {
|
||||
info.StorageConf.MonHost,
|
||||
info.StorageConf.Key,
|
||||
info.StorageConf.Pool,
|
||||
info.StorageConf.EnableMessengerV2,
|
||||
)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "cephutils.NewClient")
|
||||
|
||||
@@ -77,6 +77,9 @@ type StorageCreateInput struct {
|
||||
// example: 192.168.222.3,192.168.222.4,192.168.222.99
|
||||
RbdMonHost string `json:"rbd_mon_host"`
|
||||
|
||||
// enable ceph messenger v2
|
||||
EnableMessengerV2 *bool `json:"enable_messenger_v2"`
|
||||
|
||||
// swagger:ignore
|
||||
MonHost string
|
||||
|
||||
@@ -239,6 +242,9 @@ type StorageUpdateInput struct {
|
||||
// example: AQDigB9dtnDAKhAAxS6X4zi4BPR/lIle4nf4Dw==
|
||||
RbdKey string `json:"rbd_key"`
|
||||
|
||||
// enable ceph messenger v2
|
||||
EnableMessengerV2 *bool `json:"enable_messenger_v2"`
|
||||
|
||||
RbdTimeoutInput
|
||||
|
||||
// swagger:ignore
|
||||
|
||||
@@ -87,6 +87,10 @@ func (self *SRbdStorageDriver) ValidateCreateData(ctx context.Context, userCred
|
||||
}
|
||||
}
|
||||
|
||||
enableMessengerV2 := false
|
||||
if input.EnableMessengerV2 != nil {
|
||||
enableMessengerV2 = *input.EnableMessengerV2
|
||||
}
|
||||
input.StorageConf.Update(
|
||||
jsonutils.Marshal(map[string]interface{}{
|
||||
"mon_host": input.MonHost,
|
||||
@@ -95,6 +99,7 @@ func (self *SRbdStorageDriver) ValidateCreateData(ctx context.Context, userCred
|
||||
"rados_mon_op_timeout": input.RadosMonOpTimeout,
|
||||
"rados_osd_op_timeout": input.RadosOsdOpTimeout,
|
||||
"client_mount_timeout": input.ClientMountTimeout,
|
||||
"enable_messenger_v2": enableMessengerV2,
|
||||
}))
|
||||
return nil
|
||||
}
|
||||
@@ -110,6 +115,11 @@ func (self *SRbdStorageDriver) ValidateUpdateData(ctx context.Context, userCred
|
||||
}
|
||||
}
|
||||
|
||||
if input.EnableMessengerV2 != nil {
|
||||
input.StorageConf.Set("enable_messenger_v2", jsonutils.NewBool(*input.EnableMessengerV2))
|
||||
input.UpdateStorageConf = true
|
||||
}
|
||||
|
||||
if len(input.RbdKey) > 0 {
|
||||
input.StorageConf.Set("key", jsonutils.NewString(strings.Trim(input.RbdKey, " ")))
|
||||
input.UpdateStorageConf = true
|
||||
|
||||
@@ -47,9 +47,13 @@ const (
|
||||
)
|
||||
|
||||
type sStorageConf struct {
|
||||
MonHost string
|
||||
Key string
|
||||
Pool string
|
||||
MonHost string
|
||||
Key string
|
||||
Pool string
|
||||
// https://docs.ceph.com/en/latest/rados/configuration/msgr2/
|
||||
// The messenger v2 protocol, or msgr2, is the second major
|
||||
// revision on Ceph’s on-wire protocol.
|
||||
EnableMessengerV2 bool
|
||||
RadosMonOpTimeout int64
|
||||
RadosOsdOpTimeout int64
|
||||
ClientMountTimeout int64
|
||||
@@ -98,7 +102,7 @@ func (s *SRbdStorage) getCephClient(pool string) (*cephutils.CephClient, error)
|
||||
if pool == "" {
|
||||
pool = s.Pool
|
||||
}
|
||||
return cephutils.NewClient(s.MonHost, s.Key, pool)
|
||||
return cephutils.NewClient(s.MonHost, s.Key, pool, s.EnableMessengerV2)
|
||||
}
|
||||
|
||||
func (s *SRbdStorage) getClient() (*cephutils.CephClient, error) {
|
||||
|
||||
@@ -54,6 +54,7 @@ type StorageUpdateOptions struct {
|
||||
RbdRadosMonOpTimeout int64 `help:"ceph rados_mon_op_timeout"`
|
||||
RbdRadosOsdOpTimeout int64 `help:"ceph rados_osd_op_timeout"`
|
||||
RbdClientMountTimeout int64 `help:"ceph client_mount_timeout"`
|
||||
RbdEnableMessengerV2 bool `help:"ceph enable Messenger V2"`
|
||||
RbdKey string `help:"ceph rbd key"`
|
||||
Reserved string `help:"Reserved storage space"`
|
||||
Capacity int `help:"Capacity for storage"`
|
||||
@@ -71,6 +72,7 @@ type StorageCreateOptions struct {
|
||||
MediumType string `help:"Medium type" choices:"ssd|rotate" default:"ssd"`
|
||||
StorageType string `help:"Storage type" choices:"local|nas|vsan|rbd|nfs|gpfs|baremetal|clvm|slvm"`
|
||||
RbdMonHost string `help:"Ceph mon_host config"`
|
||||
RbdEnableMessengerV2 bool `help:"ceph enable Messenger V2"`
|
||||
RbdRadosMonOpTimeout int64 `help:"ceph rados_mon_op_timeout"`
|
||||
RbdRadosOsdOpTimeout int64 `help:"ceph rados_osd_op_timeout"`
|
||||
RbdClientMountTimeout int64 `help:"ceph client_mount_timeout"`
|
||||
|
||||
@@ -230,7 +230,7 @@ func (cli *CephClient) SetTimeout(timeout int) {
|
||||
|
||||
const DEFAULT_TIMTOUT_SECOND = 15
|
||||
|
||||
func NewClient(monHost, key, pool string) (*CephClient, error) {
|
||||
func NewClient(monHost, key, pool string, enableMessengerV2 bool) (*CephClient, error) {
|
||||
client := &CephClient{
|
||||
monHost: monHost,
|
||||
key: key,
|
||||
@@ -248,15 +248,24 @@ func NewClient(monHost, key, pool string) (*CephClient, error) {
|
||||
}
|
||||
}
|
||||
monHosts := []string{}
|
||||
for _, monHost := range strings.Split(client.monHost, ",") {
|
||||
monHosts = append(monHosts, fmt.Sprintf(`[%s]`, monHost))
|
||||
if enableMessengerV2 {
|
||||
for _, monHost := range strings.Split(client.monHost, ",") {
|
||||
monHosts = append(monHosts, fmt.Sprintf(`[v2:%s:3300/0,v1:%s:6789/0]`, monHost, monHost))
|
||||
}
|
||||
} else {
|
||||
monHosts := []string{}
|
||||
for _, monHost := range strings.Split(client.monHost, ",") {
|
||||
monHosts = append(monHosts, fmt.Sprintf(`[%s]`, monHost))
|
||||
}
|
||||
}
|
||||
client.monHost = strings.Join(monHosts, ",")
|
||||
|
||||
conf := fmt.Sprintf(`[global]
|
||||
mon host = %s
|
||||
rados mon op timeout = 5
|
||||
rados osd_op timeout = 1200
|
||||
client mount timeout = 120
|
||||
`, strings.Join(monHosts, ","))
|
||||
`, client.monHost)
|
||||
if len(client.key) == 0 {
|
||||
conf = fmt.Sprintf(`%s
|
||||
auth_cluster_required = none
|
||||
|
||||
Reference in New Issue
Block a user