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

Panic (invalid memory address or nil pointer dereference) when --component=node receives ControllerGetCapabilities #136

Open
n9 opened this issue Aug 11, 2023 · 0 comments

Comments

@n9
Copy link

n9 commented Aug 11, 2023

I have misconfigured the driver: set --component=node for a controller.

And the container failed:

I0811 15:11:20.922168 main.go:72 will run node: true, controller: false, attacher: true
I0811 15:11:20.922220 main.go:78 connect to filer http://filer.seaweed:80
I0811 15:11:20.922228 driver.go:57 Driver: seaweedfs-csi-driver version: 1.0.0
I0811 15:11:20.924703 config.go:46 Reading : Config File "security" Not Found in "[/ /root/.seaweedfs /usr/local/etc/seaweedfs /etc/seaweedfs]"
I0811 15:11:20.924845 driver.go:131 Enabling volume access mode: MULTI_NODE_MULTI_WRITER
I0811 15:11:20.924853 driver.go:131 Enabling volume access mode: SINGLE_NODE_WRITER
I0811 15:11:20.924856 driver.go:131 Enabling volume access mode: SINGLE_NODE_MULTI_WRITER
I0811 15:11:20.924859 driver.go:131 Enabling volume access mode: SINGLE_NODE_SINGLE_WRITER
I0811 15:11:20.924882 driver.go:138 Enabling controller service capability: CREATE_DELETE_VOLUME
I0811 15:11:20.924886 driver.go:138 Enabling controller service capability: SINGLE_NODE_MULTI_WRITER
I0811 15:11:20.924889 driver.go:138 Enabling controller service capability: EXPAND_VOLUME
I0811 15:11:20.924892 driver.go:138 Enabling controller service capability: PUBLISH_UNPUBLISH_VOLUME
I0811 15:11:20.924896 driver.go:94 starting
I0811 15:11:20.925373 server.go:92 Listening for connections on address: &net.UnixAddr{Name:"/csi-socket/csi.sock", Net:"unix"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb297be]

goroutine 55 [running]:
github.com/seaweedfs/seaweedfs-csi-driver/pkg/driver.(*ControllerServer).ControllerGetCapabilities(0x0, {0xc0000bb940?, 0x40da07?}, 0x10?)
	/go/src/github.com/seaweedfs/seaweedfs-csi-driver/pkg/driver/controllerserver.go:179 +0x5e
github.com/container-storage-interface/spec/lib/go/csi._Controller_ControllerGetCapabilities_Handler.func1({0xe08db0, 0xc00026a0c0}, {0xc784c0?, 0xc000074920})
	/go/pkg/mod/github.com/container-storage-interface/[email protected]/lib/go/csi/csi.pb.go:6546 +0x78
github.com/seaweedfs/seaweedfs-csi-driver/pkg/driver.logGRPC({0xe08db0, 0xc00026a0c0}, {0xc784c0, 0xc000074920}, 0xc000074940, 0xc000268108)
	/go/src/github.com/seaweedfs/seaweedfs-csi-driver/pkg/driver/utils.go:64 +0x132
github.com/container-storage-interface/spec/lib/go/csi._Controller_ControllerGetCapabilities_Handler({0xca5680?, 0x0}, {0xe08db0, 0xc00026a0c0}, 0xc000226d90, 0xd3fc50)
	/go/pkg/mod/github.com/container-storage-interface/[email protected]/lib/go/csi/csi.pb.go:6548 +0x138
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001523c0, {0xe0d1a0, 0xc0002421a0}, 0xc000206360, 0xc00032c6c0, 0x1350aa8, 0x0)
	/go/pkg/mod/google.golang.org/[email protected]/server.go:1360 +0xe23
google.golang.org/grpc.(*Server).handleStream(0xc0001523c0, {0xe0d1a0, 0xc0002421a0}, 0xc000206360, 0x0)
	/go/pkg/mod/google.golang.org/[email protected]/server.go:1737 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	/go/pkg/mod/google.golang.org/[email protected]/server.go:982 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/go/pkg/mod/google.golang.org/[email protected]/server.go:980 +0x18c

I assume from the log that the provisioner sidecar called ControllerGetCapabilities. And the call failed on nil pointer dereference.
Line controllerserver.go:179 contains:

Capabilities: cs.Driver.cscap,

The log contains 0x0:

github.com/seaweedfs/seaweedfs-csi-driver/pkg/driver.(*ControllerServer).ControllerGetCapabilities(0x0, {0xc0000bb940?, 0x40da07?}, 0x10?)

The first "argument" is cs:

func (cs *ControllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) {

Therefore, it seems to me that cs is nil.

But as I used just --component=node (without --component=controller) this service should not be registered:

if cs != nil {
csi.RegisterControllerServer(server, cs)
}
if ns != nil {
csi.RegisterNodeServer(server, ns)
}

(I am not a real golang dev, but I would expect that it should fail with unknown gRPC method and not panic on invalid memory address or nil pointer dereference.)

Are the conditions above correct?

Or why gRPC called this method even if it has {not⁉} been registered?

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

No branches or pull requests

1 participant