mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
feat: improve naming
I fixed naming to recommended by Golang.
This commit is contained in:
parent
27110bd821
commit
5494b30ce5
@ -50,7 +50,7 @@ type endpointImpl struct {
|
|||||||
// This is to be used during normal device plugin registration.
|
// This is to be used during normal device plugin registration.
|
||||||
func newEndpointImpl(p plugin.DevicePlugin) *endpointImpl {
|
func newEndpointImpl(p plugin.DevicePlugin) *endpointImpl {
|
||||||
return &endpointImpl{
|
return &endpointImpl{
|
||||||
api: p.Api(),
|
api: p.API(),
|
||||||
resourceName: p.Resource(),
|
resourceName: p.Resource(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ func (m *ManagerImpl) CleanupPluginDirectory(dir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *ManagerImpl) PluginConnected(resourceName string, p plugin.DevicePlugin) error {
|
func (m *ManagerImpl) PluginConnected(resourceName string, p plugin.DevicePlugin) error {
|
||||||
options, err := p.Api().GetDevicePluginOptions(context.Background(), &pluginapi.Empty{})
|
options, err := p.API().GetDevicePluginOptions(context.Background(), &pluginapi.Empty{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get device plugin options: %v", err)
|
return fmt.Errorf("failed to get device plugin options: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type DevicePlugin interface {
|
type DevicePlugin interface {
|
||||||
Api() api.DevicePluginClient
|
API() api.DevicePluginClient
|
||||||
Resource() string
|
Resource() string
|
||||||
SocketPath() string
|
SocketPath() string
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ func (c *client) Resource() string {
|
|||||||
return c.resource
|
return c.resource
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) Api() api.DevicePluginClient {
|
func (c *client) API() api.DevicePluginClient {
|
||||||
return c.client
|
return c.client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,11 +343,11 @@ func (pdev *podDevices) getContainerDevices(podUID, contName string) ResourceDev
|
|||||||
}
|
}
|
||||||
devicePluginMap := make(map[string]pluginapi.Device)
|
devicePluginMap := make(map[string]pluginapi.Device)
|
||||||
for numaid, devlist := range allocateInfo.deviceIds {
|
for numaid, devlist := range allocateInfo.deviceIds {
|
||||||
for _, devId := range devlist {
|
for _, devID := range devlist {
|
||||||
var topology *pluginapi.TopologyInfo
|
var topology *pluginapi.TopologyInfo
|
||||||
if numaid != nodeWithoutTopology {
|
if numaid != nodeWithoutTopology {
|
||||||
NUMANodes := []*pluginapi.NUMANode{{ID: numaid}}
|
NUMANodes := []*pluginapi.NUMANode{{ID: numaid}}
|
||||||
if pDev, ok := devicePluginMap[devId]; ok && pDev.Topology != nil {
|
if pDev, ok := devicePluginMap[devID]; ok && pDev.Topology != nil {
|
||||||
if nodes := pDev.Topology.GetNodes(); nodes != nil {
|
if nodes := pDev.Topology.GetNodes(); nodes != nil {
|
||||||
NUMANodes = append(NUMANodes, nodes...)
|
NUMANodes = append(NUMANodes, nodes...)
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ func (pdev *podDevices) getContainerDevices(podUID, contName string) ResourceDev
|
|||||||
// ID and Healthy are not relevant here.
|
// ID and Healthy are not relevant here.
|
||||||
topology = &pluginapi.TopologyInfo{Nodes: NUMANodes}
|
topology = &pluginapi.TopologyInfo{Nodes: NUMANodes}
|
||||||
}
|
}
|
||||||
devicePluginMap[devId] = pluginapi.Device{
|
devicePluginMap[devID] = pluginapi.Device{
|
||||||
Topology: topology,
|
Topology: topology,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,14 @@ func TestGetContainerDevices(t *testing.T) {
|
|||||||
contDevices, ok := resContDevices[resourceName1]
|
contDevices, ok := resContDevices[resourceName1]
|
||||||
require.True(t, ok, "resource %q not present", resourceName1)
|
require.True(t, ok, "resource %q not present", resourceName1)
|
||||||
|
|
||||||
for devId, plugInfo := range contDevices {
|
for devID, plugInfo := range contDevices {
|
||||||
nodes := plugInfo.GetTopology().GetNodes()
|
nodes := plugInfo.GetTopology().GetNodes()
|
||||||
require.Equal(t, len(nodes), len(devices), "Incorrect container devices: %v - %v (nodes %v)", devices, contDevices, nodes)
|
require.Equal(t, len(nodes), len(devices), "Incorrect container devices: %v - %v (nodes %v)", devices, contDevices, nodes)
|
||||||
|
|
||||||
for _, node := range plugInfo.GetTopology().GetNodes() {
|
for _, node := range plugInfo.GetTopology().GetNodes() {
|
||||||
dev, ok := devices[node.ID]
|
dev, ok := devices[node.ID]
|
||||||
require.True(t, ok, "NUMA id %v doesn't exist in result", node.ID)
|
require.True(t, ok, "NUMA id %v doesn't exist in result", node.ID)
|
||||||
require.Equal(t, devId, dev[0], "Can't find device %s in result", dev[0])
|
require.Equal(t, devID, dev[0], "Can't find device %s in result", dev[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,11 @@ type ResourceConfig struct {
|
|||||||
// Memory limit (in bytes).
|
// Memory limit (in bytes).
|
||||||
Memory *int64
|
Memory *int64
|
||||||
// CPU shares (relative weight vs. other containers).
|
// CPU shares (relative weight vs. other containers).
|
||||||
CpuShares *uint64
|
CPUShares *uint64
|
||||||
// CPU hardcap limit (in usecs). Allowed cpu time in a given period.
|
// CPU hardcap limit (in usecs). Allowed cpu time in a given period.
|
||||||
CpuQuota *int64
|
CPUQuota *int64
|
||||||
// CPU quota period.
|
// CPU quota period.
|
||||||
CpuPeriod *uint64
|
CPUPeriod *uint64
|
||||||
// HugePageLimit map from page size (in bytes) to limit (in bytes)
|
// HugePageLimit map from page size (in bytes) to limit (in bytes)
|
||||||
HugePageLimit map[int64]int64
|
HugePageLimit map[int64]int64
|
||||||
// Maximum number of pids
|
// Maximum number of pids
|
||||||
|
@ -495,7 +495,7 @@ func parseCPUToInt64(res string) int64 {
|
|||||||
return (&r).MilliValue()
|
return (&r).MilliValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseNonCpuResourceToInt64(res string) int64 {
|
func parseNonCPUResourceToInt64(res string) int64 {
|
||||||
r := resource.MustParse(res)
|
r := resource.MustParse(res)
|
||||||
return (&r).Value()
|
return (&r).Value()
|
||||||
}
|
}
|
||||||
@ -511,7 +511,7 @@ func getAdmissionRequirementList(cpu, memory, pods int) admissionRequirementList
|
|||||||
if memory > 0 {
|
if memory > 0 {
|
||||||
reqs = append(reqs, &admissionRequirement{
|
reqs = append(reqs, &admissionRequirement{
|
||||||
resourceName: v1.ResourceMemory,
|
resourceName: v1.ResourceMemory,
|
||||||
quantity: parseNonCpuResourceToInt64(fmt.Sprintf("%dMi", memory)),
|
quantity: parseNonCPUResourceToInt64(fmt.Sprintf("%dMi", memory)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if pods > 0 {
|
if pods > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user