Skip to content

Commit

Permalink
Fix: the maxInodeID of a metapartition is not sync to others when rec…
Browse files Browse the repository at this point in the history
…overed from snapshot; docker build failing when running `build_docker.sh`; spelling mistakes in cli

Refactor: upgrade base image from `cfs-base:1.0` to `cfs-base:1.1` in dockerfile

Signed-off-by: xuxihao <[email protected]>
  • Loading branch information
xuxihao1 committed May 20, 2020
1 parent 7427cb1 commit 10c957b
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 30 deletions.
10 changes: 5 additions & 5 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func setupCommands(cfg *cmd.Config) *cobra.Command {
var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generate completion bash file",
Long: `To apply completion scripts:
#!/bin/bash
echo 'source {path of cfs-cli.sh}' >>~/.bashrc
source ~/.bashrc
`,
Long: `To use the completion, tool "bash-completion" is demanded,
1. $ ./cfs-cli completion # file named "cfs-cli.sh" will be generated
2. $ echo 'source /usr/share/bash-completion/bash_completion' >> ~/.bashrc
3. $ echo 'source {path of cfs-cli.sh}' >>~/.bashrc
4. $ source ~/.bashrc`,
Example: "cfs-cli completion",
Run: func(cmd *cobra.Command, args []string) {
cfsRootCmd.CFSCmd.GenBashCompletionFile("cfs-cli.sh")
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/datanode.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func newDataNodeCmd(client *master.MasterClient) *cobra.Command {
}

const (
cmdDataNodeListShort = "List information of meta nodes"
cmdDataNodeListShort = "List information of data nodes"
)

func newDataNodeListCmd(client *master.MasterClient) *cobra.Command {
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/datapartition.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ func newDataPartitionCmd(client *master.MasterClient) *cobra.Command {
}

const (
cmdDataPartitionGetShort = "List information of meta nodes"
cmdDataPartitionGetShort = "List information of data partitions"
)

func newDataPartitionGetCmd(client *master.MasterClient) *cobra.Command {
var cmd = &cobra.Command{
Use: CliOpInfo + " [VOLUME] [PARTITION ID]",
Short: cmdDataPartitionGetShort,
Args: cobra.MinimumNArgs(2),
Run: func(cmd *cobra.Command, args []string) {
var (
partition *proto.DataPartitionInfo
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
FROM golang:1.12

# intall rocksdb
RUN echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list && \
apt-get update && \
RUN apt-get update && \
apt-get -y install libz-dev libbz2-dev libsnappy-dev && \
apt-get -y -t stretch-backports install librocksdb-dev
apt-get -y install librocksdb-dev

ENV LTP_VERSION=20180926
ENV LTP_SOURCE=https://github.com/linux-test-project/ltp/archive/${LTP_VERSION}.tar.gz
Expand Down
42 changes: 23 additions & 19 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ networks:

services:
monitor:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
depends_on:
- consul
- prometheus
Expand All @@ -18,7 +18,7 @@ services:
extnetwork:

servers:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
depends_on:
- master1
- master2
Expand All @@ -39,7 +39,7 @@ services:
extnetwork:

master1:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "5901"
- "5902"
Expand All @@ -59,7 +59,7 @@ services:
ipv4_address: 192.168.0.11

master2:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "5901"
- "5902"
Expand All @@ -78,7 +78,7 @@ services:
extnetwork:
ipv4_address: 192.168.0.12
master3:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "5901"
- "5902"
Expand All @@ -98,14 +98,15 @@ services:
ipv4_address: 192.168.0.13

metanode1:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "17210"
- "17220"
- "17230"
- "17240"
- 9500
volumes:
- ./metadata/1:/cfs/data
- ./bin:/cfs/bin:ro
- ./log/metanode1:/cfs/log
- ./conf/metanode.json:/cfs/conf/metanode.json
Expand All @@ -118,14 +119,15 @@ services:
ipv4_address: 192.168.0.21

metanode2:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "17210"
- "17220"
- "17230"
- "17240"
- 9500
volumes:
- ./metadata/2:/cfs/data
- ./bin:/cfs/bin:ro
- ./log/metanode2:/cfs/log
- ./conf/metanode.json:/cfs/conf/metanode.json
Expand All @@ -138,14 +140,15 @@ services:
ipv4_address: 192.168.0.22

metanode3:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "17210"
- "17220"
- "17230"
- "17240"
- 9500
volumes:
- ./metadata/3:/cfs/data
- ./bin:/cfs/bin:ro
- ./log/metanode3:/cfs/log
- ./conf/metanode.json:/cfs/conf/metanode.json
Expand All @@ -158,14 +161,15 @@ services:
ipv4_address: 192.168.0.23

metanode4:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "17210"
- "17220"
- "17230"
- "17240"
- 9500
volumes:
- ./metadata/4:/cfs/data
- ./bin:/cfs/bin:ro
- ./log/metanode4:/cfs/log
- ./conf/metanode.json:/cfs/conf/metanode.json
Expand All @@ -178,7 +182,7 @@ services:
ipv4_address: 192.168.0.24

datanode1:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "17310"
- "17320"
Expand All @@ -199,7 +203,7 @@ services:
ipv4_address: 192.168.0.31

datanode2:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "17310"
- "17320"
Expand All @@ -220,7 +224,7 @@ services:
ipv4_address: 192.168.0.32

datanode3:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "17310"
- "17320"
Expand All @@ -241,7 +245,7 @@ services:
ipv4_address: 192.168.0.33

datanode4:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "17310"
- "17320"
Expand All @@ -262,7 +266,7 @@ services:
ipv4_address: 192.168.0.34

objectnode1:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "80"
- 9500
Expand All @@ -281,7 +285,7 @@ services:
ipv4_address: 192.168.0.41

objectnode2:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "80"
- 9500
Expand All @@ -300,7 +304,7 @@ services:
ipv4_address: 192.168.0.42

objectnode3:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- "80"
- 9500
Expand All @@ -319,7 +323,7 @@ services:
ipv4_address: 192.168.0.43

client:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
ports:
- 9500
volumes:
Expand Down Expand Up @@ -392,7 +396,7 @@ services:
ipv4_address: 192.168.0.104

build:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
volumes:
- ../:/go/src/github.com/chubaofs/chubaofs
command:
Expand All @@ -401,7 +405,7 @@ services:
extnetwork:

unit_test:
image: chubaofs/cfs-base:1.0
image: chubaofs/cfs-base:1.1
volumes:
- ../:/go/src/github.com/chubaofs/chubaofs
command:
Expand Down
2 changes: 1 addition & 1 deletion docker/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ clean() {
docker-compose -f ${RootPath}/docker/docker-compose.yml down
}

# test
# unit test
run_unit_test() {
docker-compose -f ${RootPath}/docker/docker-compose.yml run unit_test
}
Expand Down
9 changes: 9 additions & 0 deletions docker/script/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MntPoint=/cfs/mnt
mkdir -p /cfs/bin /cfs/log /cfs/mnt
src_path=/go/src/github.com/chubaofs/cfs
cli=/cfs/bin/cfs-cli
conf_path=/cfs/conf

Master1Addr="192.168.0.11:17010"
LeaderAddr=""
Expand All @@ -27,6 +28,13 @@ AccessKey=39bEF4RrAQgMj6RV
SecretKey=TRL6o3JL16YOqvZGIohBDFTHZDEcFsyd
AuthKey="0e20229116d5a9a4a9e876806b514a85"

init_cli() {
cp ${cli} /usr/bin/
echo -n "Init cfs-cli ... "
cd ${conf_path}
${cli} completion
echo 'source '${conf_path}'/cfs-cli.sh' >> ~/.bashrc
}
check_cluster() {
echo -n "Checking cluster ... "
for i in $(seq 1 300) ; do
Expand Down Expand Up @@ -249,6 +257,7 @@ run_s3_test() {
python3 -m unittest2 discover ${work_path} "*.py" -v
}

init_cli
check_cluster
create_cluster_user
ensure_node_writable "metanode"
Expand Down
9 changes: 9 additions & 0 deletions docker/script/start_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MntPoint=/cfs/mnt
mkdir -p /cfs/bin /cfs/log /cfs/mnt
src_path=/go/src/github.com/chubaofs/cfs
cli=/cfs/bin/cfs-cli
conf_path=/cfs/conf

LeaderAddr=""
VolName=ltptest
Expand All @@ -26,6 +27,13 @@ AccessKey=39bEF4RrAQgMj6RV
SecretKey=TRL6o3JL16YOqvZGIohBDFTHZDEcFsyd
TryTimes=5

init_cli() {
cp ${cli} /usr/bin/
echo -n "Init cfs-cli ... "
cd ${conf_path}
${cli} completion
echo 'source '${conf_path}'/cfs-cli.sh' >> ~/.bashrc
}
check_cluster() {
echo -n "Checking cluster ... "
for i in $(seq 1 300) ; do
Expand Down Expand Up @@ -126,6 +134,7 @@ start_client() {
exit 1
}

init_cli
check_cluster
create_cluster_user
ensure_node_writable "metanode"
Expand Down
2 changes: 2 additions & 0 deletions metanode/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const (
opFSMCreateMultipart
opFSMRemoveMultipart
opFSMAppendMultipart
opFSMSyncCursor
)

var (
Expand Down Expand Up @@ -134,6 +135,7 @@ const (
const (
// interval of persisting in-memory data
intervalToPersistData = time.Minute * 5
intervalToSyncCursor = time.Minute * 1
)

const (
Expand Down
7 changes: 7 additions & 0 deletions metanode/partition_fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,14 @@ func (mp *metaPartition) Apply(command []byte, index uint64) (resp interface{},
var multipart *Multipart
multipart = MultipartFromBytes(msg.V)
resp = mp.fsmAppendMultipart(multipart)
case opFSMSyncCursor:
var cursor uint64
cursor = binary.BigEndian.Uint64(msg.V)
if cursor > mp.config.Cursor {
mp.config.Cursor = cursor
}
}

return
}

Expand Down
13 changes: 13 additions & 0 deletions metanode/partition_store_ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package metanode

import (
"encoding/binary"
"time"

"github.com/chubaofs/chubaofs/cmd/common"
Expand All @@ -35,6 +36,7 @@ type storeMsg struct {
func (mp *metaPartition) startSchedule(curIndex uint64) {
timer := time.NewTimer(time.Hour * 24 * 365)
timer.Stop()
timerCursor := time.NewTimer(intervalToSyncCursor)
scheduleState := common.StateStopped
dumpFunc := func(msg *storeMsg) {
log.LogDebugf("[startSchedule] partitionId=%d: nowAppID"+
Expand Down Expand Up @@ -117,6 +119,17 @@ func (mp *metaPartition) startSchedule(curIndex uint64) {
timer.Reset(intervalToPersistData)
}
}
case <-timerCursor.C:
if _, ok := mp.IsLeader(); !ok {
timerCursor.Reset(intervalToSyncCursor)
continue
}
cursorBuf := make([]byte, 8)
binary.BigEndian.PutUint64(cursorBuf, mp.config.Cursor)
if _, err := mp.submit(opFSMSyncCursor, cursorBuf); err != nil {
log.LogErrorf("[startSchedule] raft submit: %s", err.Error())
}
timerCursor.Reset(intervalToSyncCursor)
}
}
}(mp.stopC)
Expand Down

0 comments on commit 10c957b

Please sign in to comment.