Skip to content

Unset optional fields in config panics #172

@tdmanv

Description

@tdmanv

Overview

According to https://github.com/IBM/ibmcloud-storage-volume-lib/blob/master/config/config.go#L35, all fields except for Server are optional.

When one of these optional fields is unset, GenerateContextCredentials will panic here: https://github.com/IBM/ibmcloud-storage-volume-lib/blob/master/provider/utils/init_provider.go#L141

Empty optional values are correctly handled elsewhere in the same file: https://github.com/IBM/ibmcloud-storage-volume-lib/blob/master/provider/utils/init_provider.go#L69

Repro

Any calls to GenerateContextCredentials with unset optional values will reproduce this issue.

Related Issues

Example

We see this panic when using the kanister library and a nil VPC

[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x1474e32]
goroutine 11 [running]:
vendor/github.com/IBM/ibmcloud-storage-volume-lib/provider/utils.GenerateContextCredentials(0xc000b5d320, 0x277004b, 0xe, 0x2bfa2a0, 0xc000b9d0a0, 0xc0007ccb40, 0x0, 0x0, 0x0, 0x0, ...)
    /root/src/github.com/kastenhq/k10/go/src/vendor/github.com/IBM/ibmcloud-storage-volume-lib/provider/utils/init_provider.go:139 +0x232
vendor/github.com/IBM/ibmcloud-storage-volume-lib/provider/utils.OpenProviderSession(0xc000b5d320, 0x2bd7020, 0xc0009261b8, 0x277004b, 0xe, 0xc0007ccb40, 0x0, 0xc0010fef70, 0xc0010fefa0, 0x4a50d3, ...)
    /root/src/github.com/kastenhq/k10/go/src/vendor/github.com/IBM/ibmcloud-storage-volume-lib/provider/utils/init_provider.go:119 +0x358
vendor/github.com/kanisterio/kanister/pkg/blockstorage/ibm.newClient(0x2c0eda0, 0xc000058038, 0xc0010ff280, 0x0, 0x0, 0x0)
    /root/src/github.com/kastenhq/k10/go/src/vendor/github.com/kanisterio/kanister/pkg/blockstorage/ibm/client.go:100 +0x2ad
vendor/github.com/kanisterio/kanister/pkg/blockstorage/ibm.NewProvider(...)
    /root/src/github.com/kastenhq/k10/go/src/vendor/github.com/kanisterio/kanister/pkg/blockstorage/ibm/ibmcloud.go:57

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions