Skip to content

Commit

Permalink
style(blobstore): duplicating const string
Browse files Browse the repository at this point in the history
close cubefs#2574

Signed-off-by: slasher <[email protected]>
  • Loading branch information
sejust committed Sep 4, 2023
1 parent cf85623 commit 71eddc4
Show file tree
Hide file tree
Showing 35 changed files with 166 additions and 166 deletions.
2 changes: 1 addition & 1 deletion blobstore/access/controller/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ RETRY:

span := trace.SpanFromContextSafe(ctx)
if lastHost == "" {
span.Errorf("no any host of %s", name)
span.Errorf("no any service host of %s", name)
return "", errors.Newf("no any host of %s", name)
}
span.Warnf("all host were punished of %s, return the last one %s", name, lastHost)
Expand Down
5 changes: 0 additions & 5 deletions blobstore/access/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ func (s *Service) Put(c *rpc.Context) {

span.Debugf("accept /put request args:%+v", args)
if !args.IsValid() {
span.Debugf("invalid args:%+v", args)
c.RespondError(errcode.ErrIllegalArguments)
return
}
Expand Down Expand Up @@ -306,7 +305,6 @@ func (s *Service) PutAt(c *rpc.Context) {

span.Debugf("accept /putat request args:%+v", args)
if !args.IsValid() {
span.Debugf("invalid args:%+v", args)
c.RespondError(errcode.ErrIllegalArguments)
return
}
Expand Down Expand Up @@ -362,7 +360,6 @@ func (s *Service) Alloc(c *rpc.Context) {

span.Debugf("accept /alloc request args:%+v", args)
if !args.IsValid() {
span.Debugf("invalid args:%+v", args)
c.RespondError(errcode.ErrIllegalArguments)
return
}
Expand Down Expand Up @@ -401,7 +398,6 @@ func (s *Service) Get(c *rpc.Context) {

span.Debugf("accept /get request args:%+v", args)
if !args.IsValid() || !verifyCrc(&args.Location) {
span.Debugf("invalid args:%+v", args)
c.RespondError(errcode.ErrIllegalArguments)
return
}
Expand Down Expand Up @@ -559,7 +555,6 @@ func (s *Service) DeleteBlob(c *rpc.Context) {

span.Debugf("accept /deleteblob request args:%+v", args)
if !args.IsValid() {
span.Debugf("invalid args:%+v", args)
c.RespondError(errcode.ErrIllegalArguments)
return
}
Expand Down
4 changes: 2 additions & 2 deletions blobstore/access/stream_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ func (h *Handler) readOneShard(ctx context.Context, serviceController controller
span.Warnf("read %s on %s: %s", blob.ID(), vuid.ID(), err.Error())
return shardResult
}
span.Warnf("read %s on %s: %s", blob.ID(), vuid.ID(), errors.Detail(err))
span.Warnf("rpc read %s on %s: %s", blob.ID(), vuid.ID(), errors.Detail(err))
return shardResult
}
defer body.Close()
Expand All @@ -516,7 +516,7 @@ func (h *Handler) readOneShard(ctx context.Context, serviceController controller
_, err = io.ReadFull(body, buf[shardOffset:shardOffset+shardReadSize])
if err != nil {
h.memPool.Put(buf)
span.Warnf("read %s on %s: %s", blob.ID(), vuid.ID(), err.Error())
span.Warnf("io read %s on %s: %s", blob.ID(), vuid.ID(), err.Error())
return shardResult
}

Expand Down
34 changes: 13 additions & 21 deletions blobstore/blobnode/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ func (s *Service) ChunkCreate(c *rpc.Context) {
span.Infof("chunk create args:%v", args)

if args.ChunkSize < 0 || args.ChunkSize > disk.MaxChunkSize {
span.Debugf("args:%v", args)
c.RespondError(bloberr.ErrInvalidParam)
return
}

if !bnapi.IsValidDiskID(args.DiskID) {
span.Debugf("args:%v", args)
c.RespondError(bloberr.ErrInvalidDiskId)
return
}
Expand Down Expand Up @@ -99,7 +97,6 @@ func (s *Service) ChunkInspect(c *rpc.Context) {

span.Debugf("chunk inspect args: %v", args)
if !bnapi.IsValidDiskID(args.DiskID) {
span.Debugf("args:%v", args)
c.RespondError(bloberr.ErrInvalidDiskId)
return
}
Expand Down Expand Up @@ -148,18 +145,17 @@ func (s *Service) ChunkRelease(c *rpc.Context) {
ctx := c.Request.Context()
span := trace.SpanFromContextSafe(ctx)

span.Debugf("args: %v", args)
span.Debugf("chunk release args: %v", args)

if !bnapi.IsValidDiskID(args.DiskID) {
span.Debugf("args:%v", args)
c.RespondError(bloberr.ErrInvalidDiskId)
return
}

limitKey := args.Vuid
err := s.ChunkLimitPerVuid.Acquire(limitKey)
if err != nil {
span.Errorf("vuid(%v) status concurry conflict", args.Vuid)
span.Errorf("release vuid(%v) status concurry conflict", args.Vuid)
c.RespondError(bloberr.ErrOverload)
return
}
Expand All @@ -169,14 +165,14 @@ func (s *Service) ChunkRelease(c *rpc.Context) {
ds, exist := s.Disks[args.DiskID]
s.lock.RUnlock()
if !exist {
span.Errorf("disk:%v not found", args.DiskID)
span.Errorf("release disk:%v not found", args.DiskID)
c.RespondError(bloberr.ErrNoSuchDisk)
return
}

cs, exist := ds.GetChunkStorage(args.Vuid)
if !exist {
span.Errorf("vuid:%v not found", args.Vuid)
span.Errorf("release vuid:%v not found", args.Vuid)
c.RespondError(bloberr.ErrNoSuchVuid)
return
}
Expand Down Expand Up @@ -213,18 +209,17 @@ func (s *Service) ChunkReadonly(c *rpc.Context) {
ctx := c.Request.Context()
span := trace.SpanFromContextSafe(ctx)

span.Debugf("args: %v", args)
span.Debugf("chunk readonly args: %v", args)

if !bnapi.IsValidDiskID(args.DiskID) {
span.Debugf("args:%v", args)
c.RespondError(bloberr.ErrInvalidDiskId)
return
}

limitKey := args.Vuid
err := s.ChunkLimitPerVuid.Acquire(limitKey)
if err != nil {
span.Errorf("vuid(%v) status concurry conflict", args.Vuid)
span.Errorf("readonly vuid(%v) status concurry conflict", args.Vuid)
c.RespondError(bloberr.ErrOverload)
return
}
Expand All @@ -234,14 +229,14 @@ func (s *Service) ChunkReadonly(c *rpc.Context) {
ds, exist := s.Disks[args.DiskID]
s.lock.RUnlock()
if !exist {
span.Errorf("disk:%v not found", args.DiskID)
span.Errorf("readonly disk:%v not found", args.DiskID)
c.RespondError(bloberr.ErrNoSuchDisk)
return
}

cs, exist := ds.GetChunkStorage(args.Vuid)
if !exist {
span.Errorf("vuid:%v not found", args.Vuid)
span.Errorf("readonly vuid:%v not found", args.Vuid)
c.RespondError(bloberr.ErrNoSuchVuid)
return
}
Expand Down Expand Up @@ -283,18 +278,17 @@ func (s *Service) ChunkReadwrite(c *rpc.Context) {
ctx := c.Request.Context()
span := trace.SpanFromContextSafe(ctx)

span.Debugf("args: %v", args)
span.Debugf("chunk readwrite args: %v", args)

if !bnapi.IsValidDiskID(args.DiskID) {
span.Debugf("args:%v", args)
c.RespondError(bloberr.ErrInvalidDiskId)
return
}

limitKey := args.Vuid
err := s.ChunkLimitPerVuid.Acquire(limitKey)
if err != nil {
span.Errorf("vuid(%v) status concurry conflict", args.Vuid)
span.Errorf("readwrite vuid(%v) status concurry conflict", args.Vuid)
c.RespondError(bloberr.ErrOverload)
return
}
Expand All @@ -304,14 +298,14 @@ func (s *Service) ChunkReadwrite(c *rpc.Context) {
ds, exist := s.Disks[args.DiskID]
s.lock.RUnlock()
if !exist {
span.Errorf("disk:%v not found", args.DiskID)
span.Errorf("readwrite disk:%v not found", args.DiskID)
c.RespondError(bloberr.ErrNoSuchDisk)
return
}

cs, exist := ds.GetChunkStorage(args.Vuid)
if !exist {
span.Errorf("vuid:%v not found", args.Vuid)
span.Errorf("readwrite vuid:%v not found", args.Vuid)
c.RespondError(bloberr.ErrNoSuchVuid)
return
}
Expand Down Expand Up @@ -356,7 +350,6 @@ func (s *Service) ChunkList(c *rpc.Context) {
span.Infof("chunk list args: %v", args)

if !bnapi.IsValidDiskID(args.DiskID) {
span.Debugf("args:%v", args)
c.RespondError(bloberr.ErrInvalidDiskId)
return
}
Expand Down Expand Up @@ -406,7 +399,6 @@ func (s *Service) ChunkStat(c *rpc.Context) {
span.Infof("chunk stat args:%v", args)

if !bnapi.IsValidDiskID(args.DiskID) {
span.Debugf("args:%v", args)
c.RespondError(bloberr.ErrInvalidDiskId)
return
}
Expand All @@ -415,7 +407,7 @@ func (s *Service) ChunkStat(c *rpc.Context) {
ds, exist := s.Disks[args.DiskID]
s.lock.RUnlock()
if !exist {
span.Errorf("disk:%v not found", args.DiskID)
span.Errorf("stat disk:%v not found", args.DiskID)
c.RespondError(bloberr.ErrNoSuchDisk)
return
}
Expand Down
2 changes: 1 addition & 1 deletion blobstore/blobnode/iostat.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *Service) cleanExpiredStatFile() {

info, err := os.Stat(path)
if err != nil {
span.Errorf("path:%v, err:%v", path, err)
span.Errorf("stat path:%v, err:%v", path, err)
return err
}

Expand Down
6 changes: 3 additions & 3 deletions blobstore/cli/access/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func showClusters(c *grumble.Context) error {
path := cmapi.GetConsulClusterPath(region)
pairs, _, err := cli.KV().List(path, nil)
if err != nil {
fmt.Println("\terror:", err)
fmt.Println("\tlist error:", err)
continue
}

Expand All @@ -82,7 +82,7 @@ func showClusters(c *grumble.Context) error {
clusterInfo := &cmapi.ClusterInfo{}
err := common.Unmarshal(pair.Value, clusterInfo)
if err != nil {
fmt.Println("\terror:", err)
fmt.Println("\tjson error:", err)
continue
}

Expand Down Expand Up @@ -111,7 +111,7 @@ func showClusterWithConfig() error {
client := config.NewCluster(clusterID, nil, "")
stat, err := client.Stat(context.Background())
if err != nil {
fmt.Println("\terror:", err)
fmt.Println("\tstat error:", err)
continue
}

Expand Down
6 changes: 3 additions & 3 deletions blobstore/cli/blobnode/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func addCmdChunk(cmd *grumble.Command) {
Help: "show stat of chunk",
Flags: func(f *grumble.Flags) {
blobnodeFlags(f)
f.UintL("diskid", 1, "disk id")
f.UintL("diskid", 1, "disk id to stat")
f.UintL("vuid", 1, "vuid")
},
Run: func(c *grumble.Context) error {
Expand All @@ -77,7 +77,7 @@ func addCmdChunk(cmd *grumble.Command) {
Help: "list of chunks",
Flags: func(f *grumble.Flags) {
blobnodeFlags(f)
f.UintL("diskid", 1, "disk id")
f.UintL("diskid", 1, "disk id to list")
},
Run: func(c *grumble.Context) error {
cli := blobnode.New(&blobnode.Config{})
Expand All @@ -97,7 +97,7 @@ func addCmdChunk(cmd *grumble.Command) {
Help: "create chunk",
Flags: func(f *grumble.Flags) {
blobnodeFlags(f)
f.UintL("diskid", 1, "disk id")
f.UintL("diskid", 1, "disk id to create")
f.UintL("vuid", 101, "vuid")
f.Int64L("chunksize", 1024, "chunk size")
},
Expand Down
6 changes: 3 additions & 3 deletions blobstore/cli/blobnode/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func addCmdShard(cmd *grumble.Command) {
Help: "shard stat",
Flags: func(f *grumble.Flags) {
blobnodeFlags(f)
f.UintL("diskid", 1, "disk id")
f.UintL("diskid", 1, "disk id to stat")
f.UintL("vuid", 1, "vuid")
f.UintL("bid", 1, "bid")
},
Expand All @@ -62,7 +62,7 @@ func addCmdShard(cmd *grumble.Command) {
Help: "get shard",
Flags: func(f *grumble.Flags) {
blobnodeFlags(f)
f.UintL("diskid", 1, "disk id")
f.UintL("diskid", 1, "disk id to get")
f.UintL("vuid", 1, "vuid")
f.UintL("bid", 1, "bid")
},
Expand Down Expand Up @@ -91,7 +91,7 @@ func addCmdShard(cmd *grumble.Command) {
blobnodeFlags(f)
},
Args: func(c *grumble.Args) {
c.Uint64("diskid", "disk id")
c.Uint64("diskid", "disk id to mark")
c.Uint64("vuid", "vuid")
c.Uint64("bid", "bid")
},
Expand Down
6 changes: 3 additions & 3 deletions blobstore/cli/clustermgr/background.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func addCmdBackground(cmd *grumble.Command) {
Help: "show status of a background task switch",
LongHelp: "Show status of a specific background task type, currently supported: " + BackgroundTaskTypeString,
Args: func(a *grumble.Args) {
a.String("task", "background task type")
a.String("task", "background task type to status")
},
Run: cmdListBackgroundStatus,
Flags: func(f *grumble.Flags) {
Expand All @@ -69,7 +69,7 @@ func addCmdBackground(cmd *grumble.Command) {
Help: "enable background task",
LongHelp: "Enable a specific background task type, currently supported: " + BackgroundTaskTypeString,
Args: func(a *grumble.Args) {
a.String("task", "background task type")
a.String("task", "background task type to enable")
},
Flags: clusterFlags,
Run: func(c *grumble.Context) error {
Expand All @@ -81,7 +81,7 @@ func addCmdBackground(cmd *grumble.Command) {
Help: "disable background task",
LongHelp: "Disable a specific background task type, currently supported: " + BackgroundTaskTypeString,
Args: func(a *grumble.Args) {
a.String("task", "background task type")
a.String("task", "background task type to disable")
},
Flags: clusterFlags,
Run: func(c *grumble.Context) error {
Expand Down
10 changes: 7 additions & 3 deletions blobstore/cli/clustermgr/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import (
"github.com/cubefs/cubefs/blobstore/util/log"
)

const (
timeFormat = "2006-01-02"
)

const (
volumeDBPathName = "snapshot-volumedb"
normalDBPathName = "snapshot-normaldb"
Expand Down Expand Up @@ -159,7 +163,7 @@ func cmdDumpSnapshot(c *grumble.Context) error {
log.Fatalf("parse snapshot index failed: %s", err.Error())
}

date := time.Now().Format("2006-01-02")
date := time.Now().Format(timeFormat)
tmpNormalDBPath := dbPath + "/" + date + "/" + normalDBPathName
tmpVolumeDBPath := dbPath + "/" + date + "/" + volumeDBPathName
tmpRaftDBPath := dbPath + "/" + date + "/" + raftDBPathName
Expand Down Expand Up @@ -244,7 +248,7 @@ func cmdDumpSnapshot(c *grumble.Context) error {
}
backups := make([]string, 0)
for i := range backupDirFiless {
if _, err := time.Parse("2006-01-02", backupDirFiless[i].Name()); err == nil {
if _, err := time.Parse(timeFormat, backupDirFiless[i].Name()); err == nil {
log.Infof("name: %s", backupDirFiless[i].Name())
backups = append(backups, backupDirFiless[i].Name())
}
Expand All @@ -255,7 +259,7 @@ func cmdDumpSnapshot(c *grumble.Context) error {
oldestT := time.Now()
oldestBackup := ""
for i := range backups {
t, err := time.Parse("2006-01-02", backups[i])
t, err := time.Parse(timeFormat, backups[i])
if err == nil && t.Before(oldestT) {
oldestT = t
oldestBackup = backups[i]
Expand Down
Loading

0 comments on commit 71eddc4

Please sign in to comment.