aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--k8s/seaweedfs/Chart.yaml4
-rw-r--r--k8s/seaweedfs/values.yaml2
-rw-r--r--weed/shell/command_fs_configure.go38
-rw-r--r--weed/shell/command_fs_mkdir.go54
-rw-r--r--weed/shell/command_volume_fsck.go2
-rw-r--r--weed/shell/command_volume_tier_move.go26
-rw-r--r--weed/util/constants.go2
7 files changed, 101 insertions, 27 deletions
diff --git a/k8s/seaweedfs/Chart.yaml b/k8s/seaweedfs/Chart.yaml
index c5805d99c..cc8e4bdca 100644
--- a/k8s/seaweedfs/Chart.yaml
+++ b/k8s/seaweedfs/Chart.yaml
@@ -1,5 +1,5 @@
apiVersion: v1
description: SeaweedFS
name: seaweedfs
-appVersion: "2.59"
-version: "2.59"
+appVersion: "2.60"
+version: "2.60"
diff --git a/k8s/seaweedfs/values.yaml b/k8s/seaweedfs/values.yaml
index 08cb9fddd..3f1c6da1c 100644
--- a/k8s/seaweedfs/values.yaml
+++ b/k8s/seaweedfs/values.yaml
@@ -4,7 +4,7 @@ global:
registry: ""
repository: ""
imageName: chrislusf/seaweedfs
- # imageTag: "2.59" - started using {.Chart.appVersion}
+ # imageTag: "2.60" - started using {.Chart.appVersion}
imagePullPolicy: IfNotPresent
imagePullSecrets: imagepullsecret
restartPolicy: Always
diff --git a/weed/shell/command_fs_configure.go b/weed/shell/command_fs_configure.go
index 29cc54792..0aae51d74 100644
--- a/weed/shell/command_fs_configure.go
+++ b/weed/shell/command_fs_configure.go
@@ -62,20 +62,11 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io
return nil
}
- var buf bytes.Buffer
- if err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
- return filer.ReadEntry(commandEnv.MasterClient, client, filer.DirectoryEtcSeaweedFS, filer.FilerConfName, &buf)
- }); err != nil && err != filer_pb.ErrNotFound {
+ fc, err := readFilerConf(commandEnv)
+ if err != nil {
return err
}
- fc := filer.NewFilerConf()
- if buf.Len() > 0 {
- if err = fc.LoadFromBytes(buf.Bytes()); err != nil {
- return err
- }
- }
-
if *locationPrefix != "" {
locConf := &filer_pb.FilerConf_PathConf{
LocationPrefix: *locationPrefix,
@@ -112,16 +103,16 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io
}
}
- buf.Reset()
- fc.ToText(&buf)
+ var buf2 bytes.Buffer
+ fc.ToText(&buf2)
- fmt.Fprintf(writer, string(buf.Bytes()))
+ fmt.Fprintf(writer, string(buf2.Bytes()))
fmt.Fprintln(writer)
if *apply {
if err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
- return filer.SaveInsideFiler(client, filer.DirectoryEtcSeaweedFS, filer.FilerConfName, buf.Bytes())
+ return filer.SaveInsideFiler(client, filer.DirectoryEtcSeaweedFS, filer.FilerConfName, buf2.Bytes())
}); err != nil && err != filer_pb.ErrNotFound {
return err
}
@@ -131,3 +122,20 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io
return nil
}
+
+func readFilerConf(commandEnv *CommandEnv) (*filer.FilerConf, error) {
+ var buf bytes.Buffer
+ if err := commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
+ return filer.ReadEntry(commandEnv.MasterClient, client, filer.DirectoryEtcSeaweedFS, filer.FilerConfName, &buf)
+ }); err != nil && err != filer_pb.ErrNotFound {
+ return nil, fmt.Errorf("read %s/%s: %v", filer.DirectoryEtcSeaweedFS, filer.FilerConfName, err)
+ }
+
+ fc := filer.NewFilerConf()
+ if buf.Len() > 0 {
+ if err := fc.LoadFromBytes(buf.Bytes()); err != nil {
+ return nil, fmt.Errorf("parse %s/%s: %v", filer.DirectoryEtcSeaweedFS, filer.FilerConfName, err)
+ }
+ }
+ return fc, nil
+}
diff --git a/weed/shell/command_fs_mkdir.go b/weed/shell/command_fs_mkdir.go
new file mode 100644
index 000000000..71a9daece
--- /dev/null
+++ b/weed/shell/command_fs_mkdir.go
@@ -0,0 +1,54 @@
+package shell
+
+import (
+ "context"
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ "github.com/chrislusf/seaweedfs/weed/util"
+ "io"
+ "os"
+)
+
+func init() {
+ Commands = append(Commands, &commandFsMkdir{})
+}
+
+type commandFsMkdir struct {
+}
+
+func (c *commandFsMkdir) Name() string {
+ return "fs.mkdir"
+}
+
+func (c *commandFsMkdir) Help() string {
+ return `create a directory
+
+ fs.mkdir path/to/dir
+`
+}
+
+func (c *commandFsMkdir) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
+
+ path, err := commandEnv.parseUrl(findInputDirectory(args))
+ if err != nil {
+ return err
+ }
+
+ dir, name := util.FullPath(path).DirAndName()
+
+ err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
+
+ _, createErr := client.CreateEntry(context.Background(), &filer_pb.CreateEntryRequest{
+ Directory: dir,
+ Entry: &filer_pb.Entry{
+ Name: name,
+ IsDirectory: true,
+ Attributes: &filer_pb.FuseAttributes{
+ FileMode: uint32(0777 | os.ModeDir),
+ },
+ },
+ })
+ return createErr
+ })
+
+ return
+}
diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go
index bd3be4d89..27c253209 100644
--- a/weed/shell/command_volume_fsck.go
+++ b/weed/shell/command_volume_fsck.go
@@ -103,7 +103,7 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io.
}
// for each volume, check filer file ids
if err = c.findFilerChunksMissingInVolumeServers(volumeIdToVInfo, tempFolder, writer, *verbose, applyPurging); err != nil {
- return fmt.Errorf("findExtraChunksInVolumeServers: %v", err)
+ return fmt.Errorf("findFilerChunksMissingInVolumeServers: %v", err)
}
} else {
// collect all filer file ids
diff --git a/weed/shell/command_volume_tier_move.go b/weed/shell/command_volume_tier_move.go
index d6a49d6e1..9e38c936d 100644
--- a/weed/shell/command_volume_tier_move.go
+++ b/weed/shell/command_volume_tier_move.go
@@ -7,6 +7,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/storage/types"
"github.com/chrislusf/seaweedfs/weed/wdclient"
"io"
+ "path/filepath"
"time"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
@@ -26,7 +27,7 @@ func (c *commandVolumeTierMove) Name() string {
func (c *commandVolumeTierMove) Help() string {
return `change a volume from one disk type to another
- volume.tier.move -fromDiskType=hdd -toDiskType=ssd [-collection=""] [-fullPercent=95] [-quietFor=1h]
+ volume.tier.move -fromDiskType=hdd -toDiskType=ssd [-collectionPattern=""] [-fullPercent=95] [-quietFor=1h]
Even if the volume is replicated, only one replica will be changed and the rest replicas will be dropped.
So "volume.fix.replication" and "volume.balance" should be followed.
@@ -41,7 +42,7 @@ func (c *commandVolumeTierMove) Do(args []string, commandEnv *CommandEnv, writer
}
tierCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- collection := tierCommand.String("collection", "", "the collection name")
+ collectionPattern := tierCommand.String("collectionPattern", "", "match with wildcard characters '*' and '?'")
fullPercentage := tierCommand.Float64("fullPercent", 95, "the volume reaches the percentage of max volume size")
quietPeriod := tierCommand.Duration("quietFor", 24*time.Hour, "select volumes without no writes for this period")
source := tierCommand.String("fromDiskType", "", "the source disk type")
@@ -65,7 +66,7 @@ func (c *commandVolumeTierMove) Do(args []string, commandEnv *CommandEnv, writer
}
// collect all volumes that should change
- volumeIds, err := collectVolumeIdsForTierChange(commandEnv, topologyInfo, volumeSizeLimitMb, fromDiskType, *collection, *fullPercentage, *quietPeriod)
+ volumeIds, err := collectVolumeIdsForTierChange(commandEnv, topologyInfo, volumeSizeLimitMb, fromDiskType, *collectionPattern, *fullPercentage, *quietPeriod)
if err != nil {
return err
}
@@ -73,7 +74,7 @@ func (c *commandVolumeTierMove) Do(args []string, commandEnv *CommandEnv, writer
_, allLocations := collectVolumeReplicaLocations(topologyInfo)
for _, vid := range volumeIds {
- if err = doVolumeTierMove(commandEnv, writer, *collection, vid, toDiskType, allLocations, *applyChange); err != nil {
+ if err = doVolumeTierMove(commandEnv, writer, vid, toDiskType, allLocations, *applyChange); err != nil {
fmt.Printf("tier move volume %d: %v\n", vid, err)
}
}
@@ -90,7 +91,7 @@ func isOneOf(server string, locations []wdclient.Location) bool {
return false
}
-func doVolumeTierMove(commandEnv *CommandEnv, writer io.Writer, collection string, vid needle.VolumeId, toDiskType types.DiskType, allLocations []location, applyChanges bool) (err error) {
+func doVolumeTierMove(commandEnv *CommandEnv, writer io.Writer, vid needle.VolumeId, toDiskType types.DiskType, allLocations []location, applyChanges bool) (err error) {
// find volume location
locations, found := commandEnv.MasterClient.GetLocations(uint32(vid))
if !found {
@@ -149,7 +150,7 @@ func doVolumeTierMove(commandEnv *CommandEnv, writer io.Writer, collection strin
return nil
}
-func collectVolumeIdsForTierChange(commandEnv *CommandEnv, topologyInfo *master_pb.TopologyInfo, volumeSizeLimitMb uint64, sourceTier types.DiskType, selectedCollection string, fullPercentage float64, quietPeriod time.Duration) (vids []needle.VolumeId, err error) {
+func collectVolumeIdsForTierChange(commandEnv *CommandEnv, topologyInfo *master_pb.TopologyInfo, volumeSizeLimitMb uint64, sourceTier types.DiskType, collectionPattern string, fullPercentage float64, quietPeriod time.Duration) (vids []needle.VolumeId, err error) {
quietSeconds := int64(quietPeriod / time.Second)
nowUnixSeconds := time.Now().Unix()
@@ -160,7 +161,18 @@ func collectVolumeIdsForTierChange(commandEnv *CommandEnv, topologyInfo *master_
eachDataNode(topologyInfo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) {
for _, diskInfo := range dn.DiskInfos {
for _, v := range diskInfo.VolumeInfos {
- if v.Collection == selectedCollection && v.ModifiedAtSecond+quietSeconds < nowUnixSeconds && types.ToDiskType(v.DiskType) == sourceTier {
+ // check collection name pattern
+ if collectionPattern != "" {
+ matched, err := filepath.Match(collectionPattern, v.Collection)
+ if err != nil {
+ return
+ }
+ if !matched {
+ continue
+ }
+ }
+
+ if v.ModifiedAtSecond+quietSeconds < nowUnixSeconds && types.ToDiskType(v.DiskType) == sourceTier {
if float64(v.Size) > fullPercentage/100*float64(volumeSizeLimitMb)*1024*1024 {
vidMap[v.Id] = true
}
diff --git a/weed/util/constants.go b/weed/util/constants.go
index 00774a83e..2636adf45 100644
--- a/weed/util/constants.go
+++ b/weed/util/constants.go
@@ -5,7 +5,7 @@ import (
)
var (
- VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 59)
+ VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 60)
COMMIT = ""
)