Skip to content

Commit

Permalink
update to uinput-device-plugin deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Isla authored and danisla committed Jan 26, 2022
1 parent c8c1a3d commit 5a88fa4
Show file tree
Hide file tree
Showing 8 changed files with 1,015 additions and 52 deletions.
20 changes: 11 additions & 9 deletions images/uinput-device-plugin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.12 as builder
FROM golang:1.17 as builder

RUN apt-get update && \
apt-get install -y \
unzip && \
rm -rf /var/lib/apt/lists/*

WORKDIR /go/src/github.com/danisla/uinput-device-plugin
COPY . .
ENV GO111MODULE=on

# Get forked version of fsnotify that supports Open and CloseWrite operations.
RUN go get github.com/nsaway/fsnotify@f133d1d12072765250420b923155a2222f2b0d2c

# Install protoc
ENV PATH=${PATH}:/go/bin
RUN go get github.com/golang/protobuf/protoc-gen-go@v1.4.2
RUN cd /tmp && curl -sLO https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-linux-x86_64.zip && \
python -m zipfile -e protoc-3.13.0-linux-x86_64.zip . && \
RUN go get github.com/golang/protobuf/protoc-gen-go@v1.5.2
RUN cd /tmp && curl -sLO https://github.com/protocolbuffers/protobuf/releases/download/v3.19.0/protoc-3.19.0-linux-x86_64.zip && \
unzip protoc-3.19.0-linux-x86_64.zip && \
mv bin/protoc /go/bin/ && \
chmod +x /go/bin/protoc
RUN protoc -I pkg/uinput --go_out=plugins=grpc:pkg/uinput pkg/uinput/*.proto
RUN protoc -I=pkg/uinput --go_out=plugins=grpc:. pkg/uinput/*.proto

# Build the binaries
RUN go build -o uinput_plugin cmd/uinput_plugin/uinput_plugin.go
Expand Down
37 changes: 25 additions & 12 deletions images/uinput-device-plugin/go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
module github.com/danisla/uinput-device-plugin

go 1.17

require (
github.com/danisla/fsnotify v1.4.3-0.20200226160403-8a959c1a44e3
github.com/docker/docker v20.10.12+incompatible
github.com/golang/glog v1.0.0
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba
google.golang.org/grpc v1.43.0
google.golang.org/protobuf v1.27.1
k8s.io/kubelet v0.19.16
)

require (
github.com/Microsoft/go-winio v0.4.17 // indirect
github.com/containerd/containerd v1.5.9 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v1.13.1
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.4.2
github.com/nsaway/fsnotify v1.4.3-0.20170303152522-f133d1d12072 //indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect
golang.org/x/net v0.0.0-20200904194848-62affa334b73
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 // indirect
google.golang.org/grpc v1.32.0
google.golang.org/protobuf v1.23.0
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect
k8s.io/kubernetes v1.14.0
github.com/sirupsen/logrus v1.8.1 // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2 // indirect
gotest.tools/v3 v3.1.0 // indirect
)
974 changes: 953 additions & 21 deletions images/uinput-device-plugin/go.sum

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions images/uinput-device-plugin/pkg/uinput/api.pb.go

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

2 changes: 2 additions & 0 deletions images/uinput-device-plugin/pkg/uinput/api.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto3";

option go_package = "pkg/uinput";

package uinput;

service HostService {
Expand Down
20 changes: 19 additions & 1 deletion images/uinput-device-plugin/pkg/uinput/beta_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/golang/glog"
"golang.org/x/net/context"
"google.golang.org/grpc"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1beta1"
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
)

type pluginServiceV1Beta1 struct {
Expand Down Expand Up @@ -146,6 +146,24 @@ func (s *pluginServiceV1Beta1) Allocate(ctx context.Context, requests *pluginapi
return resps, nil
}

func (s *pluginServiceV1Beta1) GetPreferredAllocation(ctx context.Context, r *pluginapi.PreferredAllocationRequest) (*pluginapi.PreferredAllocationResponse, error) {
response := &pluginapi.PreferredAllocationResponse{}

ids := make([]string, 0)
for _, req := range r.ContainerRequests {
for _, id := range req.GetAvailableDeviceIDs() {
ids = append(ids, id)
}
}

resp := &pluginapi.ContainerPreferredAllocationResponse{
DeviceIDs: ids,
}
response.ContainerResponses = append(response.ContainerResponses, resp)

return response, nil
}

func (s *pluginServiceV1Beta1) PreStartContainer(ctx context.Context, r *pluginapi.PreStartContainerRequest) (*pluginapi.PreStartContainerResponse, error) {
glog.Errorf("device-plugin: PreStart should NOT be called for GKE uinput device plugin\n")
return &pluginapi.PreStartContainerResponse{}, nil
Expand Down
2 changes: 1 addition & 1 deletion images/uinput-device-plugin/pkg/uinput/fsnotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"path"
"time"

"github.com/danisla/fsnotify"
"github.com/golang/glog"
"github.com/nsaway/fsnotify"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
Expand Down
2 changes: 1 addition & 1 deletion images/uinput-device-plugin/pkg/uinput/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/golang/glog"
"google.golang.org/grpc"

pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1beta1"
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
)

type PluginMode uint32
Expand Down

0 comments on commit 5a88fa4

Please sign in to comment.