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

expand volume fix #142

Merged
merged 2 commits into from
Feb 3, 2021
Merged

expand volume fix #142

merged 2 commits into from
Feb 3, 2021

Conversation

sunpa93
Copy link
Contributor

@sunpa93 sunpa93 commented Dec 8, 2020

**The expand-volume panic (#141) comes from trying to access uninitialized pointer value in flag setting. And this can be resolved by adjusting the expandVolume variable structure fields.

var expandVolume struct {
	reqBytes int64
	limBytes int64
	volCap   *volumeCapabilitySliceArg
}

volCap is currently an uninitialized pointer variable so when cobra tries to parse arguments and set the variable, it ends up dereferencing nill pointer value. That said, the problem can be resolved by changing volCap type to volumeCapabilitySliceArg instead of its pointer type.

var expandVolume struct {
	reqBytes int64
	limBytes int64
	volCap   volumeCapabilitySliceArg
}

And adjusting other functions dependent of this variable.

The same fix can be applied to node_expand_volume.go for the same reason.**

@CLAassistant
Copy link

CLAassistant commented Dec 8, 2020

CLA assistant check
All committers have signed the CLA.

@divyenpatel
Copy link
Contributor

cc: @xing-yang @SandeepPissay

@xing-yang
Copy link

@sunpa93 Can you please list what tests you have done for this fix? Thanks.

@dr0pdb
Copy link

dr0pdb commented Dec 8, 2020

This worked fine for me. Nope it didn't. It works with the --cap flag

┌[satiwa☮MININT-UMBS8MU]-(/mnt/c/Users/satiwa)
└> csc controller new --endpoint tcp://127.0.0.1:10000 --cap 1,block CSIVolumeName  --req-bytes 2147483648 --params skuname=Standard_LRS
"k8s#fusec2151e57321d480c8f7#csivolumename"     2147483648      "containername"="csivolumename" "skuname"="Standard_LRS"

┌[satiwa☮MININT-UMBS8MU]-(/mnt/c/Users/satiwa)
└> csc controller expand-volume --endpoint tcp://127.0.0.1:10000 --cap 1,block  --req-bytes 2147483650 "k8s#fusec2151e57321d480c8f7#csivolumename"
2147483650

Without the --cap, it panics.

┌[satiwa☮MININT-UMBS8MU]-(/mnt/c/Users/satiwa)
└> csc controller expand-volume --endpoint tcp://127.0.0.1:10000 --req-bytes 2147483650 "k8s#fusec2151e57321d480c8f7#csivolumename"
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/rexray/gocsi/csc/cmd.glob..func6(0xba7d20, 0xc000134690, 0x1, 0x5, 0x0, 0x0)
        /home/satiwa/.gvm/pkgsets/go1.15/global/src/github.com/rexray/gocsi/csc/cmd/controller_expand_volume.go:33 +0x458
github.com/spf13/cobra.(*Command).execute(0xba7d20, 0xc000134640, 0x5, 0x5, 0xba7d20, 0xc000134640)
        /home/satiwa/.gvm/pkgsets/go1.15/global/pkg/mod/github.com/spf13/[email protected]/command.go:698 +0x44c
github.com/spf13/cobra.(*Command).ExecuteC(0xbaa9c0, 0x1, 0x8bb848, 0x13b)
        /home/satiwa/.gvm/pkgsets/go1.15/global/pkg/mod/github.com/spf13/[email protected]/command.go:783 +0x2d1
github.com/spf13/cobra.(*Command).Execute(...)
        /home/satiwa/.gvm/pkgsets/go1.15/global/pkg/mod/github.com/spf13/[email protected]/command.go:736
github.com/rexray/gocsi/csc/cmd.Execute()
        /home/satiwa/.gvm/pkgsets/go1.15/global/src/github.com/rexray/gocsi/csc/cmd/root.go:165 +0x3f
main.main()
        /home/satiwa/.gvm/pkgsets/go1.15/global/src/github.com/rexray/gocsi/csc/main.go:6 +0x25

@dr0pdb
Copy link

dr0pdb commented Dec 8, 2020

@sunpa93 You might have to revert to a pointer and do null checks.

@sunpa93
Copy link
Contributor Author

sunpa93 commented Dec 8, 2020

@xing-yang I have run test-utils and test-idempotent. Other than that, I have run csc with azure disk csi driver and tested expand-volume command with and without --cap flag. Are there other tests that you suggest that I run?

@dr0pdb Thank you for pointing that out. I did not think about the cases when the command is run without the --cap flag. I have added an additional check statement in controller_expand_volume.go and node_expand_volume.go to check whether the data array is empty or not before ExpandVolumeRequest is set. I have tested the command with and without --cap flag.

@dr0pdb
Copy link

dr0pdb commented Dec 9, 2020

This works now both with and without --cap.

┌[satiwa☮MININT-UMBS8MU]-(~/.gvm/pkgsets/go1.15/global/src/github.com/rexray/gocsi)-[git://expand-volume-fix ✔]-
└> csc controller new --endpoint tcp://127.0.0.1:10000 --cap 1,block CSIVolumeName  --req-bytes 2147483648 --params skuname=Standard_LRS
"k8s#fusec2151e57321d480c8f7#csivolumename"     2147483648      "containername"="csivolumename" "skuname"="Standard_LRS"
┌[satiwa☮MININT-UMBS8MU]-(~/.gvm/pkgsets/go1.15/global/src/github.com/rexray/gocsi)-[git://expand-volume-fix ✔]-
└> csc controller expand-volume --endpoint tcp://127.0.0.1:10000 --cap 1,block  --req-bytes 2147483650
 "k8s#fusec2151e57321d480c8f7#csivolumename"
2147483650
┌[satiwa☮MININT-UMBS8MU]-(~/.gvm/pkgsets/go1.15/global/src/github.com/rexray/gocsi)-[git://expand-volume-fix ✔]-
└> csc controller expand-volume --endpoint tcp://127.0.0.1:10000 --req-bytes 2147483651 "k8s#fusec2151e57321d480c8f7#csivolumename"
2147483651

@dr0pdb
Copy link

dr0pdb commented Dec 9, 2020

@sunpa93 Feel free to mark it as ready for review so that it can be accepted. Thanks.

@xing-yang
Copy link

LGTM

@dr0pdb
Copy link

dr0pdb commented Dec 10, 2020

I don't have write access. Can this PR be merged now please?

@xing-yang
Copy link

/assign @codenrhoden

@sunpa93
Copy link
Contributor Author

sunpa93 commented Dec 17, 2020

@codenrhoden just wanted to follow up on this 👍

@andyzhangx
Copy link

hi @codenrhoden could you help approve this PR?

@andyzhangx
Copy link

andyzhangx commented Feb 3, 2021

@akutz could you approve? thanks.

@akutz
Copy link
Member

akutz commented Feb 3, 2021

Hi @andyzhangx ,

This looks good to me; thank you!

@akutz akutz merged commit b3dfd21 into rexray:master Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants