diff options
| author | chrislusf <chris.lu@gmail.com> | 2025-12-06 12:02:18 -0800 |
|---|---|---|
| committer | Chris Lu <chrislusf@users.noreply.github.com> | 2025-12-06 18:53:22 -0800 |
| commit | 70ad54f12e2e1bbf0a841b2604f150464fab1e8f (patch) | |
| tree | 8737109aaa604a9f8daea493d814f23404d92b7b /pkg | |
| parent | 8888825ea9999fd07ce8a3d9bbce039c98694e4d (diff) | |
| download | seaweedfs-csi-driver-70ad54f12e2e1bbf0a841b2604f150464fab1e8f.tar.xz seaweedfs-csi-driver-70ad54f12e2e1bbf0a841b2604f150464fab1e8f.zip | |
fix: address PR review comments
- Set localSocket in rebuildVolumeFromStaging to fix invalid gRPC target
- Use SHA256 hash (16 hex chars) in LocalSocketPath to minimize collision risk
- Update GitHub Actions to latest versions (checkout@v4, metadata-action@v5, etc.)
- Fix volumeMounts/volumes conditional mismatch in helm templates
- Add documentation for mountService defaults in values.yaml
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/driver/nodeserver.go | 8 | ||||
| -rw-r--r-- | pkg/mountmanager/socket.go | 13 |
2 files changed, 11 insertions, 10 deletions
diff --git a/pkg/driver/nodeserver.go b/pkg/driver/nodeserver.go index 9371d09..96ed31d 100644 --- a/pkg/driver/nodeserver.go +++ b/pkg/driver/nodeserver.go @@ -8,6 +8,7 @@ import ( "github.com/container-storage-interface/spec/lib/go/csi" "github.com/seaweedfs/seaweedfs-csi-driver/pkg/k8s" + "github.com/seaweedfs/seaweedfs-csi-driver/pkg/mountmanager" "github.com/seaweedfs/seaweedfs/weed/glog" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -185,9 +186,10 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis // Note: The returned Volume won't have an unmounter, so Unstage will need special handling. func (ns *NodeServer) rebuildVolumeFromStaging(volumeID string, stagingPath string) *Volume { return &Volume{ - VolumeId: volumeID, - StagedPath: stagingPath, - driver: ns.Driver, + VolumeId: volumeID, + StagedPath: stagingPath, + driver: ns.Driver, + localSocket: mountmanager.LocalSocketPath(ns.Driver.volumeSocketDir, volumeID), // mounter and unmounter are nil - this is intentional // The FUSE process is already running, we just need to track the volume // The mount service will have the mount tracked if it's still alive diff --git a/pkg/mountmanager/socket.go b/pkg/mountmanager/socket.go index f327dcb..95d63c0 100644 --- a/pkg/mountmanager/socket.go +++ b/pkg/mountmanager/socket.go @@ -1,10 +1,10 @@ package mountmanager import ( + "crypto/sha256" + "encoding/hex" "fmt" "path/filepath" - - "github.com/seaweedfs/seaweedfs/weed/util" ) // DefaultSocketDir is the default directory for volume sockets. @@ -12,13 +12,12 @@ const DefaultSocketDir = "/var/lib/seaweedfs-mount" // LocalSocketPath returns the unix socket path used to communicate with the weed mount process. // The baseDir parameter should be the directory where sockets are stored (e.g., derived from mountEndpoint). +// Uses SHA256 hash (first 16 hex chars = 64 bits) to minimize collision risk. func LocalSocketPath(baseDir, volumeID string) string { if baseDir == "" { baseDir = DefaultSocketDir } - hash := util.HashToInt32([]byte(volumeID)) - if hash < 0 { - hash = -hash - } - return filepath.Join(baseDir, fmt.Sprintf("seaweedfs-mount-%d.sock", hash)) + h := sha256.Sum256([]byte(volumeID)) + hashStr := hex.EncodeToString(h[:8]) // 16 hex chars = 64 bits + return filepath.Join(baseDir, fmt.Sprintf("seaweedfs-mount-%s.sock", hashStr)) } |
