Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7642de0
add dra usbip
yaroslavborbat Dec 18, 2025
e0cef85
add
yaroslavborbat Dec 29, 2025
ed014f3
fix templates
yaroslavborbat Jan 13, 2026
01c21fc
fix json patch
yaroslavborbat Jan 13, 2026
190430c
fix load modules
yaroslavborbat Jan 13, 2026
fbd1e03
fix map nil panic
yaroslavborbat Jan 13, 2026
ecbe61c
fix loading modules for fresh kernels
yaroslavborbat Jan 13, 2026
1e84009
fix loading modules for fresh kernels
yaroslavborbat Jan 13, 2026
07864fc
fix loading modules for fresh kernels
yaroslavborbat Jan 13, 2026
cb37f84
go tidy
yaroslavborbat Jan 13, 2026
696ff19
fix pointer resourceSlice
yaroslavborbat Jan 13, 2026
d40f7e8
enable USBGateway featureGate
yaroslavborbat Jan 13, 2026
e395de6
fix dra feature-gates flags
yaroslavborbat Jan 13, 2026
71b9c97
support NodeSelector in ResourceSlice
yaroslavborbat Jan 13, 2026
3b01c50
fix nodeSelector operator
yaroslavborbat Jan 13, 2026
78b0d9c
fix poolname
yaroslavborbat Jan 13, 2026
afa9271
add new publisher
yaroslavborbat Jan 13, 2026
3327c70
fix usb gateway status
yaroslavborbat Jan 14, 2026
718c8fc
fix dra usbgateway devices
yaroslavborbat Jan 14, 2026
3f60748
improve attach
yaroslavborbat Jan 14, 2026
6468943
fix store empty record
yaroslavborbat Jan 14, 2026
0088a0b
fix recordManager panic
yaroslavborbat Jan 14, 2026
4028a21
refactor attach
yaroslavborbat Jan 14, 2026
e22875a
use sets util
yaroslavborbat Jan 15, 2026
53b15f7
add bindinfo
yaroslavborbat Jan 15, 2026
85b66bb
add license
yaroslavborbat Jan 15, 2026
bd67d7e
fix long
yaroslavborbat Jan 15, 2026
c269003
impl detach unbound
yaroslavborbat Jan 15, 2026
8cd2b0c
add info subcommands
yaroslavborbat Jan 15, 2026
43868dc
fix waiting attach
yaroslavborbat Jan 15, 2026
e2d62f7
add usb monitor
yaroslavborbat Jan 23, 2026
e2a88d1
add inital sync
yaroslavborbat Jan 23, 2026
25aa169
add set host namespace for monitor
yaroslavborbat Jan 23, 2026
29b3c91
refactor monitor usb
yaroslavborbat Jan 23, 2026
c5005b7
add patch package
yaroslavborbat Jan 23, 2026
5881eb9
add inotify monitor
yaroslavborbat Jan 23, 2026
8e6edd9
reduce deckhouse version requirement (test: delete me)
yaroslavborbat Jan 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,39 @@ tasks:
}
}
}'
kubectl -n d8-virtualization port-forward deploy/virtualization-dra 2345:2345
kubectl -n d8-virtualization port-forward pod/<virtualization-dra-pod> 2345:2345
EOF

dlv:virtualization-dra-usb-gateway:build:
desc: "Build image virtualization-dra-usb-gateway with dlv"
cmds:
- docker build --build-arg BRANCH=$BRANCH -f ./images/virtualization-dra-usb-gateway/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" --platform linux/amd64 .

dlv:virtualization-dra-usb-gateway:build-push:
desc: "Build and Push image virtualization-dra-usb-gateway with dlv"
cmds:
- task: dlv:virtualization-dra-usb-gateway:build
- docker push "{{ .DLV_IMAGE }}"
- task: dlv:virtualization-dra-usb-gateway:print

dlv:virtualization-dra-usb-gateway:print:
desc: "Print commands for debug"
env:
IMAGE: "{{ .DLV_IMAGE }}"
cmd: |
cat <<EOF
kubectl -n d8-virtualization patch ds virtualization-dra-usb-gateway --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [ {
"name": "virtualization-dra-usb-gateway",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ]
}]
}
}
}
}'
kubectl -n d8-virtualization port-forward pod/<virtualization-dra-usb-gateway-pod> 2345:2345
EOF
16 changes: 4 additions & 12 deletions images/virtualization-artifact/pkg/common/patch/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package patch
import (
"encoding/json"
"fmt"
"slices"
"strings"
)

Expand Down Expand Up @@ -74,18 +75,9 @@ func (jp *JSONPatch) Append(patches ...JSONPatchOperation) {
}

func (jp *JSONPatch) Delete(op, path string) {
var idx int
var found bool
for i, o := range jp.operations {
if o.Op == op && o.Path == path {
idx = i
found = true
break
}
}
if found {
jp.operations = append(jp.operations[:idx], jp.operations[idx+1:]...)
}
slices.DeleteFunc(jp.operations, func(o JSONPatchOperation) bool {
return o.Op == op && o.Path == path
})
}

func (jp *JSONPatch) Len() int {
Expand Down
5 changes: 3 additions & 2 deletions images/virtualization-dra-plugin/debug/dlv.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.24.7-bookworm@sha256:2c5f7a0c252a17cf6aa30ddee15caa0f485ee29410a6ea64cddb62eea2b07bdf AS builder
FROM golang:1.25-bookworm@sha256:019c22232e57fda8ded2b10a8f201989e839f3d3f962d4931375069bbb927e03 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand All @@ -13,13 +13,14 @@ RUN go mod download
COPY ./images/virtualization-dra/cmd /app/images/virtualization-dra/cmd
COPY ./images/virtualization-dra/internal /app/images/virtualization-dra/internal
COPY ./images/virtualization-dra/pkg /app/images/virtualization-dra/pkg
COPY ./images/virtualization-dra/api /app/images/virtualization-dra/api

ENV GO111MODULE=on
ENV GOOS=${TARGETOS:-linux}
ENV GOARCH=${TARGETARCH:-amd64}
ENV CGO_ENABLED=0

RUN go build -tags EE -gcflags "all=-N -l" -a -o virtualization-dra-plugin ./cmd/virtualization-dra-plugin
RUN go build -gcflags "all=-N -l" -a -o virtualization-dra-plugin ./cmd/virtualization-dra-plugin/main.go

FROM busybox:1.36.1-glibc

Expand Down
10 changes: 5 additions & 5 deletions images/virtualization-dra-plugin/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import:
to: /app/virtualization-dra-plugin
after: install
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-dra-plugin" }}
- image: debugger
add: /app/dlv
to: /app/dlv
after: install
- image: debugger
add: /app/dlv
to: /app/dlv
after: install
{{- end }}
imageSpec:
config:
Expand All @@ -22,7 +22,7 @@ imageSpec:
env:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/dlv"
XDG_CONFIG_HOME: "/tmp"
entrypoint: ["/app/dlv", "--listen=:2345", "--headless=true", "--continue", "--log=true", "--log-output=debugger,debuglineerr,gdbwire,lldbout,rpc", "--accept-multiclient", "--api-version=2", "exec", "/app/virtualization-dra-plugin", "--", "--leader-election=false"]
entrypoint: ["/app/dlv", "--listen=:2345", "--headless=true", "--continue", "--log=true", "--log-output=debugger,debuglineerr,gdbwire,lldbout,rpc", "--accept-multiclient", "--api-version=2", "exec", "/app/virtualization-dra-plugin", "--"]
{{- else }}
entrypoint: ["/app/virtualization-dra-plugin"]
{{- end }}
32 changes: 32 additions & 0 deletions images/virtualization-dra-usb-gateway/debug/dlv.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM golang:1.25-bookworm@sha256:019c22232e57fda8ded2b10a8f201989e839f3d3f962d4931375069bbb927e03 AS builder
ARG TARGETOS
ARG TARGETARCH

WORKDIR /app/images/virtualization-dra
RUN go install github.com/go-delve/delve/cmd/dlv@latest

COPY ./images/virtualization-dra/go.mod /app/images/virtualization-dra/
COPY ./images/virtualization-dra/go.sum /app/images/virtualization-dra/

RUN go mod download

COPY ./images/virtualization-dra/cmd /app/images/virtualization-dra/cmd
COPY ./images/virtualization-dra/internal /app/images/virtualization-dra/internal
COPY ./images/virtualization-dra/pkg /app/images/virtualization-dra/pkg
COPY ./images/virtualization-dra/api /app/images/virtualization-dra/api

ENV GO111MODULE=on
ENV GOOS=${TARGETOS:-linux}
ENV GOARCH=${TARGETARCH:-amd64}
ENV CGO_ENABLED=0

RUN go build -gcflags "all=-N -l" -a -o virtualization-dra-usb-gateway ./cmd/usb-gateway/main.go

FROM busybox:1.36.1-glibc

WORKDIR /app
COPY --from=builder /go/bin/dlv /app/dlv
COPY --from=builder /app/images/virtualization-dra/virtualization-dra-usb-gateway /app/virtualization-dra-usb-gateway
USER 65532:65532

ENTRYPOINT ["./dlv", "--listen=:2345", "--headless=true", "--continue", "--log=true", "--log-output=debugger,debuglineerr,gdbwire,lldbout,rpc", "--accept-multiclient", "--api-version=2", "exec", "./virtualization-dra-usb-gateway", "--"]
5 changes: 5 additions & 0 deletions images/virtualization-dra-usb-gateway/mount-points.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# A list of pre-created mount points for containerd strict mode.

dirs:
- /var/run/usb-gateway

28 changes: 28 additions & 0 deletions images/virtualization-dra-usb-gateway/werf.inc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
image: {{ .ModuleNamePrefix }}{{ .ImageName }}
fromImage: {{ .ModuleNamePrefix }}distroless
git:
{{- include "image mount points" . }}
import:
- image: {{ .ModuleNamePrefix }}virtualization-dra-builder
add: /out/virtualization-dra-usb-gateway
to: /app/virtualization-dra-usb-gateway
after: install
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-dra-usb-gateway" }}
- image: debugger
add: /app/dlv
to: /app/dlv
after: install
{{- end }}
imageSpec:
config:
user: 64535
workingDir: "/app"
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-dra-usb-gateway" }}
env:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/dlv"
XDG_CONFIG_HOME: "/tmp"
entrypoint: ["/app/dlv", "--listen=:2345", "--headless=true", "--continue", "--log=true", "--log-output=debugger,debuglineerr,gdbwire,lldbout,rpc", "--accept-multiclient", "--api-version=2", "exec", "/app/virtualization-dra-usb-gateway", "--"]
{{- else }}
entrypoint: ["/app/virtualization-dra-usb-gateway"]
{{- end }}
10 changes: 10 additions & 0 deletions images/virtualization-dra/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,13 @@ tasks:
cmds:
- |
golangci-lint run

build:go-usbip:
desc: "Build go-usbip binary"
cmds:
- go build -o bin/go-usbip cmd/go-usbip/main.go

api:generate:
desc: "Generate API code"
cmds:
- hack/update-codegen.sh
20 changes: 20 additions & 0 deletions images/virtualization-dra/api/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright 2025 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package
// +groupName=dra.virtualization.deckhouse.io

package api
52 changes: 52 additions & 0 deletions images/virtualization-dra/api/sheme.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright 2026 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package api

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)

const Version = "v1alpha2"
const Group = "usb-gateway.virtualization.deckhouse.io"

var SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version}

var (
Scheme = runtime.NewScheme()
Codecs = serializer.NewCodecFactory(Scheme)
)

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&USBGatewayStatus{},
)
return nil
}

func init() {
metav1.AddToGroupVersion(Scheme, SchemeGroupVersion)
utilruntime.Must(AddToScheme(Scheme))
}
73 changes: 73 additions & 0 deletions images/virtualization-dra/api/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Copyright 2025 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package api

import (
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

const USBGatewayStatusKind = "USBGatewayStatus"

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type USBGatewayStatus struct {
metav1.TypeMeta `json:",inline"`

BusID string `json:"busID"`

RemoteIP string `json:"remoteIP"`
RemotePort int `json:"remotePort"`

Bound bool `json:"bound"`
Attached bool `json:"attached"`
}

func FromData(data *runtime.RawExtension) (*USBGatewayStatus, error) {
if data == nil {
return nil, nil
}

obj, err := runtime.Decode(Codecs.UniversalDecoder(SchemeGroupVersion), data.Raw)
if err != nil {
return nil, fmt.Errorf("failed to decode USBGatewayStatus: %w", err)
}
status, ok := obj.(*USBGatewayStatus)
if !ok {
return nil, fmt.Errorf("failed to decode USBGatewayStatus: unexpected object type: %T", obj)
}

return status, nil
}

func ToData(status *USBGatewayStatus) (*runtime.RawExtension, error) {
if status == nil {
return nil, nil
}

raw, err := runtime.Encode(Codecs.LegacyCodec(SchemeGroupVersion), status)
if err != nil {
return nil, fmt.Errorf("failed to encode USBGatewayStatus: %w", err)
}

return &runtime.RawExtension{
Raw: raw,
Object: status,
}, nil
}
51 changes: 51 additions & 0 deletions images/virtualization-dra/api/zz_generated.deepcopy.go

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

Loading
Loading