Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Fix volume.fsck 401 Unauthorized by adding JWT to HTTP delete requests (#8306)

Chris Lua3136c523f1c
diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go
index 17c553141b..5bf5ada73d 100644
--- a/weed/shell/command_volume_fsck.go
+++ b/weed/shell/command_volume_fsck.go
@@ -25,6 +25,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
+ "github.com/seaweedfs/seaweedfs/weed/security"
"github.com/seaweedfs/seaweedfs/weed/storage"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/needle_map"
@@ -39,7 +40,8 @@ func init() {
}
const (
- readbufferSize = 16
+ readbufferSize = 16
+ jwtFilerTokenExpirationSeconds = 300
)
type commandVolumeFsck struct {
@@ -53,6 +55,7 @@ type commandVolumeFsck struct {
forcePurging *bool
findMissingChunksInFiler *bool
verifyNeedle *bool
+ filerSigningKey string
}
func (c *commandVolumeFsck) Name() string {
@@ -139,6 +142,8 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io.
}
defer os.RemoveAll(c.tempFolder)
+ c.filerSigningKey = util.GetViper().GetString("jwt.filer_signing.key")
+
// collect all volume id locations
dataNodeVolumeIdToVInfo, err := c.collectVolumeIds()
if err != nil {
@@ -556,6 +561,12 @@ func (c *commandVolumeFsck) httpDelete(path util.FullPath) {
Host: c.env.option.FilerAddress.ToHttpAddress(),
Path: string(path),
}
+
+ if c.filerSigningKey != "" {
+ encodedJwt := security.GenJwtForFilerServer(security.SigningKey(c.filerSigningKey), jwtFilerTokenExpirationSeconds)
+ req.Header.Set("Authorization", "BEARER "+string(encodedJwt))
+ }
+
if *c.verbose {
fmt.Fprintf(c.writer, "full HTTP delete request to be sent: %v\n", req)
}