mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-21 02:37:58 +08:00

Some checks are pending
go: build dev binaries / cleanup (push) Waiting to run
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Blocked by required conditions
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Blocked by required conditions
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Blocked by required conditions
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Blocked by required conditions
docker: build dev containers / build-dev-containers (push) Waiting to run
End to End / FUSE Mount (push) Waiting to run
go: build binary / Build (push) Waiting to run
Ceph S3 tests / Ceph S3 tests (push) Waiting to run
* fix(volume): don't persist RO state in specific cases * fix(volume): writable always persist
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package shell
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
|
)
|
|
|
|
func init() {
|
|
Commands = append(Commands, &commandVolumeMark{})
|
|
}
|
|
|
|
type commandVolumeMark struct {
|
|
}
|
|
|
|
func (c *commandVolumeMark) Name() string {
|
|
return "volume.mark"
|
|
}
|
|
|
|
func (c *commandVolumeMark) Help() string {
|
|
return `Mark volume writable or readonly from one volume server
|
|
|
|
volume.mark -node <volume server host:port> -volumeId <volume id> -writable or -readonly
|
|
`
|
|
}
|
|
|
|
func (c *commandVolumeMark) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
|
|
|
|
volMarkCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
|
|
volumeIdInt := volMarkCommand.Int("volumeId", 0, "the volume id")
|
|
nodeStr := volMarkCommand.String("node", "", "the volume server <host>:<port>")
|
|
writable := volMarkCommand.Bool("writable", false, "volume mark writable")
|
|
readonly := volMarkCommand.Bool("readonly", false, "volume mark readonly")
|
|
if err = volMarkCommand.Parse(args); err != nil {
|
|
return nil
|
|
}
|
|
markWritable := false
|
|
if (*writable && *readonly) || (!*writable && !*readonly) {
|
|
return fmt.Errorf("use -readonly or -writable")
|
|
} else if *writable {
|
|
markWritable = true
|
|
}
|
|
|
|
if err = commandEnv.confirmIsLocked(args); err != nil {
|
|
return
|
|
}
|
|
|
|
sourceVolumeServer := pb.ServerAddress(*nodeStr)
|
|
|
|
volumeId := needle.VolumeId(*volumeIdInt)
|
|
|
|
return markVolumeWritable(commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer, markWritable, true)
|
|
}
|