util: add nil check to default ControllerGetCapabilities()

Currently default ControllerGetCapabilities function is being
used which throws 'runtime error: invalid memory address or
nil pointer dereference' when `--controllerServer=true` is not
set in provisioner deployment args.
This commit adds a check to prevent it.

Fixes: 1925

Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
Rakshith R 2021-04-09 10:59:04 +05:30 committed by mergify[bot]
parent 10d539efc8
commit ae6a52a84e

View File

@ -60,7 +60,9 @@ func (cs *DefaultControllerServer) GetCapacity(ctx context.Context, req *csi.Get
// Default supports all capabilities.
func (cs *DefaultControllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) {
util.TraceLog(ctx, "Using default ControllerGetCapabilities")
if cs.Driver == nil {
return nil, status.Error(codes.Unimplemented, "Controller server is not enabled")
}
return &csi.ControllerGetCapabilitiesResponse{
Capabilities: cs.Driver.capabilities,
}, nil