Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed to expand nas loopdevice file system issue #1303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pkg/losetup/losetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
)

type LoopDevice struct {
Name string `json:"name"`
Sizelimit string `json:"sizelimit"`
Offset string `json:"offset"`
Autoclear string `json:"autoclear"`
RO string `json:"ro"`
BackFile string `json:"back-file"`
Dio string `json:"dio"`
LogSec string `json:"log-sec"`
Name string `json:"name"`
Sizelimit json.Number `json:"sizelimit"`
Offset json.Number `json:"offset"`
Autoclear bool `json:"autoclear"`
RO bool `json:"ro"`
BackFile string `json:"back-file"`
Dio bool `json:"dio"`
LogSec json.Number `json:"log-sec"`
}

type option []string
Expand Down
7 changes: 4 additions & 3 deletions pkg/nas/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,11 @@ func (ns *nodeServer) LosetupExpandVolume(req *csi.NodeExpandVolumeRequest) erro
// /mnt/nasplugin.alibabacloud.com/6c690876-74aa-46f6-a301-da7f4353665d/pv-losetup/
nfsPath := filepath.Join(NasMntPoint, podID, pvName)
imgFile := filepath.Join(nfsPath, LoopImgFile)
volSizeBytes := req.GetCapacityRange().GetRequiredBytes()
klog.Infof("NodeExpandVolume: expected expand %q to %vB", imgFile, volSizeBytes)

if utils.IsFileExisting(imgFile) {
volSizeBytes := req.GetCapacityRange().GetRequiredBytes()
err := losetup.TruncateFile(imgFile, volSizeBytes)
if err != nil {
if err := os.Truncate(imgFile, volSizeBytes); err != nil {
klog.Errorf("NodeExpandVolume: nas resize img file error %v", err)
return fmt.Errorf("NodeExpandVolume: nas resize img file error, %v", err)
}
Expand Down