mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-16 20:26:45 +00:00
LiveMoveVolume and the copy, tail, delete, mark, replicate, and configure helpers around it issued every RPC on context.Background(), so a caller had no way to bound or abort a move once it started. They now take a context, which the exported LiveMoveVolume in particular needs: callers outside the shell drive long moves and want to stop them. The deferred restore in copyVolume runs on a detached, bounded context rather than the caller's. Marking the source writable again is cleanup, and cancelling the copy must not skip it and leave the volume readonly — the same guard balance_task.go already applies for the same reason. Shell commands pass context.Background(): their Do signature carries no context, and changing it would touch every command in the package. Claude-Session: https://claude.ai/code/session_01Ks16jnt4S7gdDk8cheQ3xu
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package shell
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"io"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
|
)
|
|
|
|
func init() {
|
|
Commands = append(Commands, &commandVolumeDelete{})
|
|
}
|
|
|
|
type commandVolumeDelete struct {
|
|
}
|
|
|
|
func (c *commandVolumeDelete) Name() string {
|
|
return "volume.delete"
|
|
}
|
|
|
|
func (c *commandVolumeDelete) Help() string {
|
|
return `delete a live volume from one volume server
|
|
|
|
volume.delete -node <volume server host:port> -volumeId <volume id>
|
|
|
|
This command deletes a volume from one volume server.
|
|
|
|
`
|
|
}
|
|
|
|
func (c *commandVolumeDelete) HasTag(CommandTag) bool {
|
|
return false
|
|
}
|
|
|
|
func (c *commandVolumeDelete) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
|
|
|
|
volDeleteCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
|
|
volumeIdInt := volDeleteCommand.Int("volumeId", 0, "the volume id")
|
|
nodeStr := volDeleteCommand.String("node", "", "the volume server <host>:<port>")
|
|
if err = volDeleteCommand.Parse(args); err != nil {
|
|
return nil
|
|
}
|
|
|
|
if err = commandEnv.confirmIsLocked(args); err != nil {
|
|
return
|
|
}
|
|
|
|
sourceVolumeServer := pb.ServerAddress(*nodeStr)
|
|
|
|
volumeId := needle.VolumeId(*volumeIdInt)
|
|
|
|
return deleteVolume(context.Background(), commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer, false, false)
|
|
|
|
}
|