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

enter_modify #342

Closed
wants to merge 40 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c0a38f1
[fix]playbook/memcached
Cyber-SiKu Feb 22, 2023
10994d9
[fix]playbook/memcached
Cyber-SiKu Feb 22, 2023
de36749
Feature: support managing disk information in database
Mar 3, 2023
af342de
Merge pull request #188 from legionxiong/new-disk-format
tsonglew Mar 3, 2023
2c50545
Feature: support direct disk mounting for service container
Mar 19, 2023
397fc08
Merge pull request #201 from legionxiong/auto-mount-disk
tsonglew Apr 10, 2023
78c415a
[feat] add toolsv2
Cyber-SiKu Feb 28, 2023
d7db7c6
[feat]curvefs/curvebs: auto restart&mount
Cyber-SiKu Mar 7, 2023
050eb05
Fix: remove deprecated ioutil
fengshunli May 19, 2023
5feab2c
Fix: update package dependencies
fengshunli May 17, 2023
5c622b9
Feat: add golangci-lint
fengshunli May 17, 2023
62d83a2
Fix: format code
fengshunli May 30, 2023
f90ed57
Merge pull request #236 from fengshunli/code
caoxianfei1 May 31, 2023
9e46bbe
feature(curvebs): support poolset
jolly-sy Nov 28, 2022
8fa1398
[fix] repace harbor with opencurve
Cyber-SiKu Jun 21, 2023
26a6b3c
support deploy monitor
SeanHai Apr 26, 2023
c896257
add http service
SeanHai Apr 23, 2023
1ab4aac
support deploy website
SeanHai May 8, 2023
7cee1b6
Merge pull request #250 from SeanHai/curve-manager
SeanHai Jun 25, 2023
15076a4
[fix] update the example
montaguelhz Jun 25, 2023
e150a3b
fix clean monitor
SeanHai Jul 4, 2023
d750c94
Merge pull request #262 from SeanHai/auth
SeanHai Jul 4, 2023
8c55ada
fix generate target.json when curvefs
SeanHai Jul 6, 2023
60cee71
Merge pull request #264 from SeanHai/auth
SeanHai Jul 6, 2023
7d3bd4b
add dirs http service need
SeanHai Jul 14, 2023
3b6b0a1
Merge pull request #276 from SeanHai/auth
SeanHai Jul 14, 2023
dc048d1
support enable etcd auth
SeanHai Aug 3, 2023
eeda84f
[fix]playbook: fix format related variables position
Songjf-ttk Aug 30, 2023
df9eea9
[fix] add support for recognizing kernel versions like "3.15.0_.*"
jyf111 Aug 30, 2023
b1c5562
Merge pull request #305 from Songjf-ttk/fixposition
caoxianfei1 Aug 31, 2023
dbe508e
Merge pull request #306 from jyf111/fix-kernel-version
caoxianfei1 Aug 31, 2023
956c953
Merge pull request #281 from SeanHai/auth
SeanHai Aug 31, 2023
bc5ef37
Feature: podman can be an alternative container engine
caoxianfei1 Aug 10, 2023
061b6e4
bugfix: docker ps specify both --format and --quiet will warning sinc…
caoxianfei1 Aug 11, 2023
7401855
change replicas to instances
tiansuo114 Aug 27, 2023
28dd6b0
Update cli/command/status.go
Wine93 Sep 1, 2023
a13b532
[fix] older versions of the ss command do not have the --no-header op…
jyf111 Aug 19, 2023
de8f69d
[CI] add basic static check, compile, test
357447923 Aug 16, 2023
14c8166
[feat]curveadm: add clean command for bs format
Songjf-ttk Oct 7, 2023
8fc6f47
enter_modify
LYPWYT Nov 10, 2023
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
Prev Previous commit
Next Next commit
Feature: support direct disk mounting for service container
Disk UUID will be wrote into the config of service(chunkserver)
container during curvebs deployment if disks `service_mount_device`
was set `true`, then the service could directly mount disk device
via `entrypoint.sh` and restart automatically after host power recover.

Signed-off-by: Lijin Xiong <[email protected]>
Lijin Xiong committed Mar 19, 2023
commit 2c505454a6a82736fa8cf28157ec0381cf9f1789
83 changes: 51 additions & 32 deletions cli/command/disks/commit.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ import (

"github.com/fatih/color"
"github.com/opencurve/curveadm/cli/cli"
"github.com/opencurve/curveadm/internal/common"
comm "github.com/opencurve/curveadm/internal/common"
"github.com/opencurve/curveadm/internal/configure/disks"
"github.com/opencurve/curveadm/internal/configure/topology"
@@ -40,7 +39,8 @@ import (
)

const (
COMMIT_EXAMPLE = `Examples:
HOST_DEVICE_SEP = ":"
COMMIT_EXAMPLE = `Examples:
$ curveadm disks commit /path/to/disks.yaml # Commit disks`
)

@@ -89,35 +89,55 @@ func readAndCheckDisks(curveadm *cli.CurveAdm, options commitOptions) (string, [
}

// 3) check disks data
dcs, err = disks.ParseDisks(data, curveadm)
dcs, err = disks.ParseDisks(data)
return data, dcs, err
}

func assambleNewDiskRecords(dcs []*disks.DiskConfig,
oldDiskRecords []storage.Disk) ([]storage.Disk, []storage.Disk) {
keySep := ":"
newDiskMap := make(map[string]bool)

// "ServiceMountDevice=0" means write disk UUID into /etc/fstab for host mounting.
// "ServiceMountDevice=1" means not to update /etc/fstab, the disk UUID will be wrote
// into the config of service(chunkserver) container for disk automatic mounting.
serviceMountDevice := 0 // 0: false, 1: true
var newDiskRecords, diskRecordDeleteList []storage.Disk
for _, dc := range dcs {
for _, host := range dc.GetHost() {
key := strings.Join([]string{host, dc.GetDevice()}, keySep)
device := dc.GetDevice()
key := strings.Join([]string{host, device}, HOST_DEVICE_SEP)
newDiskMap[key] = true
if dc.GetServiceMount() {
serviceMountDevice = 1
}
diskSize := comm.DISK_DEFAULT_NULL_SIZE
diskUri := comm.DISK_DEFAULT_NULL_URI
diskChunkserverId := comm.DISK_DEFAULT_NULL_CHUNKSERVER_ID
for _, dr := range oldDiskRecords {
if dr.Host == host && device == dr.Device {
diskSize = dr.Size
diskUri = dr.URI
diskChunkserverId = dr.ChunkServerID
break
}
}
newDiskRecords = append(
newDiskRecords, storage.Disk{
Host: host,
Device: dc.GetDevice(),
Size: comm.DISK_DEFAULT_NULL_SIZE,
URI: comm.DISK_DEFAULT_NULL_URI,
MountPoint: dc.GetMountPoint(),
FormatPercent: dc.GetFormatPercent(),
ChunkServerID: comm.DISK_DEFAULT_NULL_CHUNKSERVER_ID,
Host: host,
Device: device,
Size: diskSize,
URI: diskUri,
MountPoint: dc.GetMountPoint(),
ContainerImage: dc.GetContainerImage(),
FormatPercent: dc.GetFormatPercent(),
ChunkServerID: diskChunkserverId,
ServiceMountDevice: serviceMountDevice,
})
}
}

for _, dr := range oldDiskRecords {
key := strings.Join([]string{dr.Host, dr.Device}, keySep)
key := strings.Join([]string{dr.Host, dr.Device}, HOST_DEVICE_SEP)
if _, ok := newDiskMap[key]; !ok {
diskRecordDeleteList = append(diskRecordDeleteList, dr)
}
@@ -127,19 +147,16 @@ func assambleNewDiskRecords(dcs []*disks.DiskConfig,
}

func writeDiskRecord(dr storage.Disk, curveadm *cli.CurveAdm) error {
if diskRecords, err := curveadm.Storage().GetDisk(
common.DISK_FILTER_DEVICE, dr.Host, dr.Device); err != nil {
if err := curveadm.Storage().SetDisk(
dr.Host,
dr.Device,
dr.MountPoint,
dr.ContainerImage,
dr.FormatPercent,
dr.ServiceMountDevice); err != nil {
return err
} else if len(diskRecords) == 0 {
if err := curveadm.Storage().SetDisk(
dr.Host,
dr.Device,
dr.MountPoint,
dr.ContainerImage,
dr.FormatPercent); err != nil {
return err
}
}

return nil
}

@@ -153,15 +170,17 @@ func syncDiskRecords(data string, dcs []*disks.DiskConfig,
oldDiskRecordsString := tui.FormatDisks(oldDiskRecords)
newDiskRecordsString := tui.FormatDisks(newDiskRecords)

if !options.slient {
diff := utils.Diff(oldDiskRecordsString, newDiskRecordsString)
curveadm.WriteOutln(diff)
}
if len(newDiskRecords) != len(oldDiskRecords) {
if !options.slient {
diff := utils.Diff(oldDiskRecordsString, newDiskRecordsString)
curveadm.WriteOutln(diff)
}

pass := tuicomm.ConfirmYes("Disk changes are showing above. Do you want to continue?")
if !pass {
curveadm.WriteOut(tuicomm.PromptCancelOpetation("commit disk table"))
return errno.ERR_CANCEL_OPERATION
pass := tuicomm.ConfirmYes("Disk changes are showing above. Do you want to continue?")
if !pass {
curveadm.WriteOut(tuicomm.PromptCancelOpetation("commit disk table"))
return errno.ERR_CANCEL_OPERATION
}
}

// write new disk records
14 changes: 11 additions & 3 deletions cli/command/format.go
Original file line number Diff line number Diff line change
@@ -155,9 +155,17 @@ func runFormat(curveadm *cli.CurveAdm, options formatOptions) error {
if err != nil {
return err
}
fc.UseDiskUri = true
chunkserverId := dr.ChunkServerID
if len(chunkserverId) > 1 {

fc.FromDiskRecord = true

// "ServiceMountDevice=0" means write disk UUID into /etc/fstab for host mounting.
// "ServiceMountDevice=1" means not to update /etc/fstab, the disk UUID will be wrote
// into the config of service(chunkserver) container for disk automatic mounting.
if dr.ServiceMountDevice != 0 {
fc.ServiceMountDevice = true
}

if dr.ChunkServerID != comm.DISK_DEFAULT_NULL_CHUNKSERVER_ID {
// skip formatting the disk with nonempty chunkserver id
continue
}
11 changes: 6 additions & 5 deletions configs/bs/cluster/disks.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
global:
format_percent: 95
container_image: opencurvedocker/curvebs:v1.2
service_mount_device: false # disk device will be mounted by service(chunkserver) directly if set "true", default "false"
host:
- curve-1
- curve-2
- curve-3

disk:
- device: /dev/sdb1
mount: /data/chunkserver0
- device: /dev/sdb1 # disk device path
mount: /data/chunkserver0 # mount point for disk formatting, consistent with the "data_dir" field of chunkserver service in topology
- device: /dev/sdc1
mount: /data/chunkserver1
format_percent: 90
format_percent: 90 # use a different value for disk format percent
- device: /dev/sdd1
mount: /data/chunkserver2
exclude: # for the use case that some hosts have not certain disk device
exclude: # for the use case that disk device does not exist in some hosts
- curve-3
- device: /dev/sde1
mount: /data/chunkserver3
host:
host: # override global host config, for the use case that disk device only exists in some hosts
- curve-1
- curve-2
4 changes: 2 additions & 2 deletions internal/common/common.go
Original file line number Diff line number Diff line change
@@ -57,8 +57,8 @@ const (
DISK_FILTER_MOUNT = "mount"
DISK_FILTER_SERVICE = "service"
DISK_EXCLUDE_HOST = "exclude"

DISK_FORMAT_PERCENT = "format_percent"
DISK_SERVICE_MOUNT_DEVICE = "service_mount_device"
DISK_FORMAT_PERCENT = "format_percent"

DISK_FORMAT_MOUNT_POINT = "mount"
DISK_FORMAT_CONTAINER_IMAGE = "container_image"
47 changes: 22 additions & 25 deletions internal/configure/common/item_set.go
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ const (
REQUIRE_BOOL
REQUIRE_INT
REQUIRE_POSITIVE_INTEGER
REQUIRE_SLICE
REQUIRE_STRING_SLICE
)

type (
@@ -82,6 +82,25 @@ func (itemset *ItemSet) GetAll() []*Item {
return itemset.items
}

func convertSlice[T int | string | any](key, value any) ([]T, error) {
var slice []T
if !utils.IsAnySlice(value) || len(value.([]any)) == 0 {
return slice, errno.ERR_CONFIGURE_VALUE_REQUIRES_NONEMPTY_SLICE
}
anySlice := value.([]any)
switch anySlice[0].(type) {
case T:
for _, str := range anySlice {
slice = append(slice, str.(T))
}
default:
return slice, errno.ERR_UNSUPPORT_CONFIGURE_VALUE_TYPE.
F("%s: %v", key, value)
}

return slice, nil
}

func (itemset *ItemSet) Build(key string, value interface{}) (interface{}, error) {
item := itemset.Get(key)
if item == nil {
@@ -135,34 +154,12 @@ func (itemset *ItemSet) Build(key string, value interface{}) (interface{}, error
return v, nil
}

case REQUIRE_SLICE:
anySlice := value.([]any)
if len(anySlice) > 0 {
switch anySlice[0].(type) {
case string:
return convertSlice[string](value), nil
case int:
return convertSlice[int](value), nil
case bool:
return convertSlice[bool](value), nil
default:
return []any{}, errno.ERR_UNSUPPORT_CONFIGURE_VALUE_TYPE.
F("%s: %v", key, value)
}
}
return []any{}, nil
case REQUIRE_STRING_SLICE:
return convertSlice[string](key, value)

default:
// do nothing
}

return value, nil
}

func convertSlice[T int | string | any](value any) []T {
var slice []T
for _, str := range value.([]any) {
slice = append(slice, str.(T))
}
return slice
}
9 changes: 9 additions & 0 deletions internal/configure/disks/dc_get.go
Original file line number Diff line number Diff line change
@@ -55,6 +55,14 @@ func (dc *DiskConfig) getInt(i *comm.Item) int {
return v.(int)
}

func (hc *DiskConfig) getBool(i *comm.Item) bool {
v := hc.get(i)
if v == nil {
return false
}
return v.(bool)
}

func (dc *DiskConfig) getStrSlice(i *comm.Item) []string {
v := dc.get(i)
if v == nil {
@@ -65,6 +73,7 @@ func (dc *DiskConfig) getStrSlice(i *comm.Item) []string {

func (dc *DiskConfig) GetContainerImage() string { return dc.getString(CONFIG_GLOBAL_CONTAINER_IMAGE) }
func (dc *DiskConfig) GetFormatPercent() int { return dc.getInt(CONFIG_GLOBAL_FORMAT_PERCENT) }
func (dc *DiskConfig) GetServiceMount() bool { return dc.getBool(CONFIG_GLOBAL_SERVICE_MOUNT_DEVICE) }
func (dc *DiskConfig) GetHost() []string { return dc.getStrSlice(CONFIG_GLOBAL_HOST) }
func (dc *DiskConfig) GetDevice() string { return dc.getString(CONFIG_DISK_DEVICE) }
func (dc *DiskConfig) GetMountPoint() string { return dc.getString(CONFIG_DISK_MOUNT_POINT) }
12 changes: 10 additions & 2 deletions internal/configure/disks/dc_item.go
Original file line number Diff line number Diff line change
@@ -48,12 +48,20 @@ var (
DEFAULT_FORMAT_PERCENT,
)

CONFIG_GLOBAL_SERVICE_MOUNT_DEVICE = itemset.Insert(
common.DISK_SERVICE_MOUNT_DEVICE,
comm.REQUIRE_BOOL,
false,
false,
)

CONFIG_GLOBAL_HOST = itemset.Insert(
common.DISK_FILTER_HOST,
comm.REQUIRE_SLICE,
comm.REQUIRE_STRING_SLICE,
false,
nil,
)

CONFIG_DISK_DEVICE = itemset.Insert(
common.DISK_FILTER_DEVICE,
comm.REQUIRE_STRING,
@@ -70,7 +78,7 @@ var (

CONFIG_DISK_HOST_EXCLUDE = itemset.Insert(
common.DISK_EXCLUDE_HOST,
comm.REQUIRE_SLICE,
comm.REQUIRE_STRING_SLICE,
false,
nil,
)
Loading