IBM / ibmcloud-storage-volume-lib

A helper ibm cloud storage client library to assist in interacting with IBM Cloud storage. Provides access to key volume lifecycle operations
Apache License 2.0
6 stars 20 forks source link

library is using panic intead of retuning error #33

Open depohmel opened 5 years ago

depohmel commented 5 years ago

there are many places when the library is panicking this is not the desired approach. example

 value *errors.fundamental = Failed to create volume. {Code:E0011, Description:Failed to find the storage with storage id %!d(string=Volume order failed). Description: %!s(MISSING) [Backend Error:SoftLayer_Exception_Order_AccountDiscount: As an active participant of the Technology Incubator Program, you may only place one order at a time. Currently you have a pending order that needs final disposition before you can place another order. (HTTP 500)], Type:StorageFindFailed, RC:500} ("Failed to create volume. {Code:E0011, Description:Failed to find the storage with storage id %!d(string=Volume order failed). Description: %!s(MISSING) [Backend Error:SoftLayer_Exception_Order_AccountDiscount: As an active participant of the Technology Incubator Program, you may only place one order at a time. Currently you have a pending order that needs final disposition before you can place another order. (HTTP 500)], Type:StorageFindFailed, RC:500}")

The ideal behavior would be to return an error.

arahamad-zz commented 5 years ago

@depohmel , Can you please point out the place, do you mean this is newly added ?

I agree that we should return error instead panicking.

I think this is your a/c issue and its old issue . we will fix this

depohmel commented 5 years ago

This is an old issue. Here is a stack trace:

"stacktrace":"
github.com/IBM/ibmcloud-storage-volume-lib/volume-providers/softlayer/block.(*SLBlockSession).VolumeCreateFromSnapshot
github.com/IBM/ibmcloud-storage-volume-lib/volume-providers/softlayer/block/block_volume_manager.go:333
github.com/kanisterio/kanister/pkg/blockstorage/ibm.(*ibmCloud).VolumeCreateFromSnapshot
github.com/kanisterio/kanister/pkg/blockstorage/ibm/ibmcloud.go:280
github.com/kanisterio/kanister/pkg/blockstorage/ibm.TestIBMCloudBlock.TestVolRestore
github.com/kanisterio/kanister/pkg/blockstorage/ibm/ibmcloud_test.go:111
runtime.call32
/usr/local/go/src/runtime/asm_amd64.s:522
reflect.Value.call
/usr/local/go/src/reflect/value.go:447
reflect.Value.Call
/usr/local/go/src/reflect/value.go:308
narkarum commented 5 years ago

Snapshot behavior is not yet ready from backend.

narkarum commented 5 years ago

Can you test with latest code?

aru-robin commented 5 years ago

I am still seeing this.

To repro: Place 3 volume orders consecutively

`[root@centos-60-204 ~]# ibmcloud sl block volume-order --storage-type performance --size 300 --iops 6000 --os-type LINUX --datacenter dal10 This action will incur charges on your account. Continue?> y OK Order 46169688 was placed.

Storage as a Service

Block Storage

300 GBs

6000 IOPS

You may run 'bx sl block volume-list --order 46169688' to find this block volume after it is ready. [root@centos-60-204 ~]# ibmcloud sl block volume-order --storage-type performance --size 300 --iops 6000 --os-type LINUX --datacenter dal10 This action will incur charges on your account. Continue?> y OK Order 46172466 was placed.

Storage as a Service

You may run 'bx sl block volume-list --order 46172466' to find this block volume after it is ready. [root@centos-60-204 ~]# ibmcloud sl block volume-order --storage-type performance --size 300 --iops 6000 --os-type LINUX --datacenter dal10 This action will incur charges on your account. Continue?> y Failed to order block volume.Please verify your options and try again. SoftLayer_Exception_Order_AccountDiscount: As an active participant of the Technology Incubator Program, you may only place one order at a time. Currently you have a pending order that needs final disposition before you can place another order. (HTTP 500)`

As you can see below, 1st order got approved and a block storage was created. For the 2nd order, the block storage was not created and this was blocking to provision another volume-order. Is there a way to get the status of the volume-order ???

[root@centos-60-204 ~]# bx sl block volume-list --order 46169688 id username datacenter storage_type capacity_gb bytes_used ip_addr lunId active_transactions 95246678 SL02SL1954062-14 dal10 performance_block_storage 300 - 161.26.98.111 11 0 [root@centos-60-204 ~]# bx sl block volume-list --order 46172466 id username datacenter storage_type capacity_gb bytes_used ip_addr lunId active_transactions

narkarum commented 5 years ago

The above PR would resolve the issue. https://github.com/IBM/ibmcloud-storage-volume-lib/pull/173