Skip to content

Commit

Permalink
update network interface func and plugin version
Browse files Browse the repository at this point in the history
  • Loading branch information
carmark authored and hustcat committed Mar 8, 2018
1 parent e57d735 commit a055554
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
13 changes: 7 additions & 6 deletions glide.lock

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

5 changes: 2 additions & 3 deletions glide.yaml
Expand Up @@ -6,8 +6,7 @@ import:
subpackages:
- context
- package: google.golang.org/grpc
version: v1.3.0
- package: k8s.io/kubernetes
version: v1.8.3
version: v1.9.3
subpackages:
- pkg/kubelet/apis/deviceplugin/v1alpha1
- pkg/kubelet/apis/deviceplugin/v1alpha
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -7,7 +7,7 @@ import (

log "github.com/Sirupsen/logrus"
"github.com/fsnotify/fsnotify"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1alpha1"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1alpha"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions rdma.go
Expand Up @@ -6,7 +6,7 @@ import (
"io/ioutil"

"golang.org/x/net/context"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1alpha1"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1alpha"

"github.com/hustcat/k8s-rdma-device-plugin/ibverbs"
)
Expand Down Expand Up @@ -34,7 +34,6 @@ func getAllRdmaDeivces() ([]Device, error) {
if err != nil {
return nil, err
}

for _, d := range ibvDevList {
for _, n := range netDevList {
dResource, err := getRdmaDeviceResoure(d.Name)
Expand Down
7 changes: 3 additions & 4 deletions server.go
Expand Up @@ -10,7 +10,7 @@ import (
log "github.com/Sirupsen/logrus"
"golang.org/x/net/context"
"google.golang.org/grpc"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1alpha1"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1alpha"
)

const (
Expand Down Expand Up @@ -94,7 +94,7 @@ func (m *RdmaDevicePlugin) Start() error {

go m.server.Serve(sock)

// Wait for server to start by launching a blocking connexion
// Wait for server to start by launching a blocking connection
conn, err := dial(m.socket, 5*time.Second)
if err != nil {
return err
Expand Down Expand Up @@ -187,8 +187,7 @@ func (m *RdmaDevicePlugin) Allocate(ctx context.Context, r *pluginapi.AllocateRe
devicesList = append(devicesList, ds)
}

spec := &pluginapi.DeviceRuntimeSpec{Devices: devicesList}
response.Spec = []*pluginapi.DeviceRuntimeSpec{spec}
response.Devices = devicesList

return &response, nil
}
Expand Down
27 changes: 25 additions & 2 deletions sriov.go
Expand Up @@ -3,9 +3,12 @@ package main
import (
"fmt"
"io/ioutil"
"net"
"os"
"strconv"
"strings"

log "github.com/Sirupsen/logrus"
)

const VfNetDevicePath = "/sys/class/net/%s/device/virtfn%d/net"
Expand Down Expand Up @@ -50,8 +53,28 @@ func GetVfNetDevice(master string) ([]string, error) {
}

func GetAllNetDevice() ([]string, error) {
// TODO:
return nil, nil
var res = []string{}
ifaces, err := net.Interfaces()
if err != nil {
log.Errorf("localAddresses: %+v\n", err)
return nil, err
}
for _, iface := range ifaces {
if iface.Flags&(1<<uint(0)) == 0 {
continue
}
if iface.Flags&(1<<uint(1)) == 0 {
continue
}
if iface.Flags&(1<<uint(2)) != 0 {
continue
}
if strings.HasPrefix(iface.Name, "docker") || strings.HasPrefix(iface.Name, "cali") {
continue
}
res = append(res, iface.Name)
}
return res, nil
}

func getVFDeviceName(master string, vf int) (string, error) {
Expand Down

0 comments on commit a055554

Please sign in to comment.