Skip to content

Commit

Permalink
Merge pull request #439 from adrianchiris/cleanup-unused
Browse files Browse the repository at this point in the history
Cleanup unused methods
  • Loading branch information
adrianchiris authored Jul 25, 2022
2 parents c1a8c92 + fee24e5 commit faafa1f
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 122 deletions.
4 changes: 0 additions & 4 deletions pkg/accelerator/accelDevice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ var _ = Describe("Accelerator", func() {
Expect(out.GetEnvVal()).To(Equal("0000:00:00.1"))
Expect(out.GetDeviceSpecs()).To(HaveLen(2)) // /dev/vfio/vfio0 and default /dev/vfio/vfio
Expect(out.GetAPIDevice().Topology.Nodes[0].ID).To(Equal(int64(0)))
Expect(out.GetNumaInfo()).To(Equal("0"))
Expect(err).NotTo(HaveOccurred())
})
It("should not populate topology due to negative numa_node", func() {
Expand All @@ -82,7 +81,6 @@ var _ = Describe("Accelerator", func() {
out, err := accelerator.NewAccelDevice(in, f, config)

Expect(out.GetAPIDevice().Topology).To(BeNil())
Expect(out.GetNumaInfo()).To(Equal(""))
Expect(err).NotTo(HaveOccurred())
})
It("should not populate topology due to missing numa_node", func() {
Expand All @@ -107,7 +105,6 @@ var _ = Describe("Accelerator", func() {
out, err := accelerator.NewAccelDevice(in, f, config)

Expect(out.GetAPIDevice().Topology).To(BeNil())
Expect(out.GetNumaInfo()).To(Equal(""))
Expect(err).NotTo(HaveOccurred())
})
It("should not populate topology due to config excluding topology being set", func() {
Expand All @@ -133,7 +130,6 @@ var _ = Describe("Accelerator", func() {
out, err := accelerator.NewAccelDevice(in, f, config)

Expect(out.GetAPIDevice().Topology).To(BeNil())
Expect(out.GetNumaInfo()).To(Equal(""))
Expect(err).NotTo(HaveOccurred())
})
})
Expand Down
11 changes: 0 additions & 11 deletions pkg/netdevice/pciNetDevice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ var _ = Describe("PciNetDevice", func() {
Expect(dev.GetRdmaSpec().GetRdmaDeviceSpec()).To(HaveLen(0))
Expect(dev.GetLinkType()).To(Equal("fakeLinkType"))
Expect(dev.GetAPIDevice().Topology.Nodes[0].ID).To(Equal(int64(0)))
Expect(dev.GetNumaInfo()).To(Equal("0"))
Expect(err).NotTo(HaveOccurred())
})
It("should not populate topology due to negative numa_node", func() {
Expand All @@ -95,7 +94,6 @@ var _ = Describe("PciNetDevice", func() {
dev, err := netdevice.NewPciNetDevice(in, f, rc)

Expect(dev.GetAPIDevice().Topology).To(BeNil())
Expect(dev.GetNumaInfo()).To(Equal(""))
Expect(err).NotTo(HaveOccurred())
})
It("should not populate topology due to missing numa_node", func() {
Expand All @@ -120,7 +118,6 @@ var _ = Describe("PciNetDevice", func() {
dev, err := netdevice.NewPciNetDevice(in, f, rc)

Expect(dev.GetAPIDevice().Topology).To(BeNil())
Expect(dev.GetNumaInfo()).To(Equal(""))
Expect(err).NotTo(HaveOccurred())
})
It("should not populate topology due to config option being set", func() {
Expand All @@ -146,7 +143,6 @@ var _ = Describe("PciNetDevice", func() {
dev, err := netdevice.NewPciNetDevice(in, f, rc)

Expect(dev.GetAPIDevice().Topology).To(BeNil())
Expect(dev.GetNumaInfo()).To(Equal(""))
Expect(err).NotTo(HaveOccurred())
})
})
Expand Down Expand Up @@ -218,7 +214,6 @@ var _ = Describe("PciNetDevice", func() {
Expect(dev.GetDeviceSpecs()).To(HaveLen(2)) // 2x Rdma devs
Expect(dev.GetMounts()).To(HaveLen(0))
Expect(dev.GetAPIDevice().Topology.Nodes[0].ID).To(Equal(int64(0)))
Expect(dev.GetNumaInfo()).To(Equal("0"))
Expect(err).NotTo(HaveOccurred())
mockInfo1.AssertExpectations(t)
})
Expand All @@ -234,7 +229,6 @@ var _ = Describe("PciNetDevice", func() {
Expect(dev.GetMounts()).To(HaveLen(0))
Expect(dev.GetLinkType()).To(Equal("fakeLinkType"))
Expect(dev.GetAPIDevice().Topology.Nodes[0].ID).To(Equal(int64(0)))
Expect(dev.GetNumaInfo()).To(Equal("0"))
Expect(err).NotTo(HaveOccurred())
mockInfo2.AssertExpectations(t)
})
Expand Down Expand Up @@ -278,7 +272,6 @@ var _ = Describe("PciNetDevice", func() {
Expect(dev.GetRdmaSpec().GetRdmaDeviceSpec()).To(HaveLen(0))
Expect(dev.GetLinkType()).To(Equal(""))
Expect(dev.GetAPIDevice().Topology.Nodes[0].ID).To(Equal(int64(0)))
Expect(dev.GetNumaInfo()).To(Equal("0"))
Expect(err).NotTo(HaveOccurred())
})
})
Expand Down Expand Up @@ -409,15 +402,13 @@ var _ = Describe("PciNetDevice", func() {
}}))
Expect(dev1.GetAPIDevice().Topology.Nodes[0].ID).To(Equal(int64(0)))
Expect(dev1.GetVdpaDevice()).To(Equal(fakeVdpaVhost))
Expect(dev1.GetNumaInfo()).To(Equal("0"))
Expect(err1).NotTo(HaveOccurred())

Expect(dev2.GetDriver()).To(Equal("ifcvf"))
Expect(dev2.GetEnvVal()).To(Equal("0000:00:00.2"))
Expect(dev2.GetDeviceSpecs()).To(HaveLen(0))
Expect(dev2.GetAPIDevice().Topology.Nodes[0].ID).To(Equal(int64(0)))
Expect(dev2.GetVdpaDevice()).To(Equal(fakeVdpaVirtio))
Expect(dev2.GetNumaInfo()).To(Equal("0"))
Expect(err2).NotTo(HaveOccurred())
})
It("should generate empty deviceSpecs if ResourceConfig type does not match vdpa driver", func() {
Expand All @@ -429,11 +420,9 @@ var _ = Describe("PciNetDevice", func() {

Expect(dev1.GetEnvVal()).To(Equal("0000:00:00.1"))
Expect(dev1.GetDeviceSpecs()).To(HaveLen(0))
Expect(dev1.GetNumaInfo()).To(Equal("0"))
Expect(err1).NotTo(HaveOccurred())
Expect(dev2.GetEnvVal()).To(Equal("0000:00:00.2"))
Expect(dev2.GetDeviceSpecs()).To(HaveLen(0))
Expect(dev2.GetNumaInfo()).To(Equal("0"))
Expect(err2).NotTo(HaveOccurred())
})
})
Expand Down
21 changes: 0 additions & 21 deletions pkg/resources/pciDevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package resources

import (
"strconv"

"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/types"
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/utils"

Expand All @@ -29,20 +27,10 @@ type pciDevice struct {
pfAddr string
driver string
vfID int
numa string
apiDevice *pluginapi.Device
infoProviders []types.DeviceInfoProvider
}

// Convert NUMA node number to string.
// A node of -1 represents "unknown" and is converted to the empty string.
func nodeToStr(nodeNum int) string {
if nodeNum >= 0 {
return strconv.Itoa(nodeNum)
}
return ""
}

// NewPciDevice returns an instance of PciDevice interface
// A list of DeviceInfoProviders can be set externally.
// If empty, the default driver-based selection provided by ResourceFactory will be used
Expand Down Expand Up @@ -97,7 +85,6 @@ func NewPciDevice(dev *ghw.PCIDevice, rFactory types.ResourceFactory, rc *types.
vfID: vfID,
apiDevice: apiDevice,
infoProviders: infoProviders,
numa: nodeToStr(nodeNum),
}, nil
}

Expand Down Expand Up @@ -125,10 +112,6 @@ func (pd *pciDevice) IsSriovPF() bool {
return false
}

func (pd *pciDevice) GetSubClass() string {
return pd.basePciDevice.Subclass.ID
}

func (pd *pciDevice) GetDeviceSpecs() []*pluginapi.DeviceSpec {
dSpecs := make([]*pluginapi.DeviceSpec, 0)
for _, infoProvider := range pd.infoProviders {
Expand Down Expand Up @@ -160,7 +143,3 @@ func (pd *pciDevice) GetAPIDevice() *pluginapi.Device {
func (pd *pciDevice) GetVFID() int {
return pd.vfID
}

func (pd *pciDevice) GetNumaInfo() string {
return pd.numa
}
28 changes: 0 additions & 28 deletions pkg/types/mocks/AccelDevice.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions pkg/types/mocks/PciDevice.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions pkg/types/mocks/PciNetDevice.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,11 @@ type PciDevice interface {
GetPciAddr() string
GetPfPciAddr() string
IsSriovPF() bool
GetSubClass() string
GetDeviceSpecs() []*pluginapi.DeviceSpec
GetEnvVal() string
GetMounts() []*pluginapi.Mount
GetAPIDevice() *pluginapi.Device
GetVFID() int
GetNumaInfo() string
}

// PciNetDevice extends PciDevice interface
Expand Down

0 comments on commit faafa1f

Please sign in to comment.