Skip to content

Commit

Permalink
Merge 98a7be5 into 7fb78c7
Browse files Browse the repository at this point in the history
  • Loading branch information
27149chen committed Mar 14, 2019
2 parents 7fb78c7 + 98a7be5 commit 0b9e576
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var _ = Describe("block_device_mounter_utils_test", func() {
err error
callErr error = errors.New("error")
)
volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)}
volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1}

BeforeEach(func() {
fakeBlockDeviceUtils = new(fakes.FakeBlockDeviceUtils)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _ = Describe("block_device_utils_test", func() {
err error
cmdErr error = errors.New("command error")
)
volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)}
volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1}

BeforeEach(func() {
fakeExec = new(fakes.FakeExecutor)
Expand Down
2 changes: 1 addition & 1 deletion remote/mounter/initiator/connectors/fibre_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = Describe("Test Fibre Channel Connector", func() {
fakeInitiator *fakeinitiator.FakeInitiator
fcConnector initiator.Connector
)
volumeMountProperties := &resources.VolumeMountProperties{WWN: fakeWwn, LunNumber: float64(1)}
volumeMountProperties := &resources.VolumeMountProperties{WWN: fakeWwn, LunNumber: 1}

BeforeEach(func() {
fakeExec = new(fakes.FakeExecutor)
Expand Down
5 changes: 2 additions & 3 deletions remote/mounter/initiator/linuxfc.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ func (lfc *linuxFibreChannel) hasFCSupport() bool {
// may be '-' wildcards if unable to determine them.
func (lfc *linuxFibreChannel) getHBAChannelScsiTarget(volumeMountProperties *resources.VolumeMountProperties) string {
//TODO: get channel and target
if volumeMountProperties.LunNumber == float64(-1) {
if volumeMountProperties.LunNumber == -1 {
return "- - -"
}
// use %g to print a float64 to int
return fmt.Sprintf("- - %g", volumeMountProperties.LunNumber)
return fmt.Sprintf("- - %d", volumeMountProperties.LunNumber)
}

// GetHBAs return all the FC HBAs in the system
Expand Down
4 changes: 2 additions & 2 deletions remote/mounter/initiator/linuxfc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var _ = Describe("Test FC Initiator", func() {
realSysBlockPath string
cmdErr error = errors.New("command error")
)
volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)}
volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1}

BeforeEach(func() {
err := os.MkdirAll(FAKE_FC_HOST_SYSFS_PATH, os.ModePerm)
Expand Down Expand Up @@ -187,7 +187,7 @@ var _ = Describe("Test FC Initiator", func() {
Ω(err).ShouldNot(HaveOccurred())
data, err := ioutil.ReadFile(scanFile)
Ω(err).ShouldNot(HaveOccurred())
Expect(string(data)).To(Equal(fmt.Sprintf("- - %g", volumeMountProperties.LunNumber)))
Expect(string(data)).To(Equal(fmt.Sprintf("- - %d", volumeMountProperties.LunNumber)))
})

It("should write '1' to the hba lip file", func() {
Expand Down
8 changes: 6 additions & 2 deletions remote/mounter/scbe.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ func NewScbeMounterWithExecuter(blockDeviceMounterUtils block_device_mounter_uti
func (s *scbeMounter) prepareVolumeMountProperties(vcGetter resources.VolumeConfigGetter) *resources.VolumeMountProperties {
volumeConfig := vcGetter.GetVolumeConfig()
volumeWWN := volumeConfig["Wwn"].(string)
volumeLunNumber := float64(-1)
volumeLunNumber := -1
if volumeLunNumberInterface, exists := volumeConfig[resources.ScbeKeyVolAttachLunNumToHost]; exists {
volumeLunNumber = volumeLunNumberInterface.(float64)

// LunNumber is int, but after json.Marshal and json.UNmarshal it will become float64.
// see https://stackoverflow.com/questions/39152481/unmarshaling-a-json-integer-to-an-empty-interface-results-in-wrong-type-assertio
// but LunNumber should be int, so convert it here.
volumeLunNumber = int(volumeLunNumberInterface.(float64))
}
return &resources.VolumeMountProperties{WWN: volumeWWN, LunNumber: volumeLunNumber}
}
Expand Down
2 changes: 1 addition & 1 deletion remote/mounter/scbe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _ = Describe("scbe_mounter_test", func() {
"LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2706", "fstype": "ext4"}}
mountRequestForDS8kLun2 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity,
"Profile": fakeProfile, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1",
"LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}}
"LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1074741264), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}}
mountRequestForDS8kLun3 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity,
"Profile": fakeProfile, "StorageType": fakeDS8kStoragetType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1",
"LogicalCapacity": fakeLogicalCapacity, "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}}
Expand Down
2 changes: 1 addition & 1 deletion resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,5 @@ type RequestContext struct {

type VolumeMountProperties struct {
WWN string
LunNumber float64
LunNumber int
}

0 comments on commit 0b9e576

Please sign in to comment.