-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Implementation of dynamic USB device allocation in a cluster using the Kubernetes DRA mechanism. #1696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| 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 | ||
|
|
||
| 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 ./cmd/usb/dra/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 /app/virtualization-dra-usb | ||
| 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", "--"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # A list of pre-created mount points for containerd strict mode. | ||
|
|
||
| dirs: | ||
| # Default dir for Container Device Interface | ||
| - /var/run/cdi | ||
| # Default dir for registration kubelet plugins | ||
| - /var/lib/kubelet/plugins_registry | ||
| # Default dir where DRA plugin stores sockets | ||
| - /var/lib/kubelet/plugins | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| to: /app/virtualization-dra-usb | ||
| after: install | ||
| {{- if eq $.DEBUG_COMPONENT "delve/virtualization-dra-usb" }} | ||
| - 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" }} | ||
| 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", "--"] | ||
| {{- else }} | ||
| entrypoint: ["/app/virtualization-dra-usb"] | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| run: | ||
| concurrency: 4 | ||
| timeout: 10m | ||
| issues: | ||
| # Show all errors. | ||
| max-issues-per-linter: 0 | ||
| max-same-issues: 0 | ||
| exclude: | ||
| - "don't use an underscore in package name" | ||
| output: | ||
| sort-results: true | ||
|
|
||
| exclude-files: | ||
| - "^zz_generated.*" | ||
|
|
||
| linters-settings: | ||
| gofumpt: | ||
| extra-rules: true | ||
| gci: | ||
| sections: | ||
| - standard | ||
| - default | ||
| - prefix(github.com/deckhouse/) | ||
| goimports: | ||
| local-prefixes: github.com/deckhouse/ | ||
| errcheck: | ||
| exclude-functions: fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy | ||
| revive: | ||
| rules: | ||
| - name: dot-imports | ||
| disabled: true | ||
| nolintlint: | ||
| # Exclude following linters from requiring an explanation. | ||
| # Default: [] | ||
| allow-no-explanation: [funlen, gocognit, lll] | ||
| # Enable to require an explanation of nonzero length after each nolint directive. | ||
| # Default: false | ||
| require-explanation: true | ||
| # Enable to require nolint directives to mention the specific linter being suppressed. | ||
| # Default: false | ||
| require-specific: true | ||
| importas: | ||
| # Do not allow unaliased imports of aliased packages. | ||
| # Default: false | ||
| no-unaliased: true | ||
| # Do not allow non-required aliases. | ||
| # Default: false | ||
| no-extra-aliases: false | ||
| # List of aliases | ||
| # Default: [] | ||
| alias: | ||
| - pkg: github.com/deckhouse/virtualization/api/core/v1alpha2 | ||
| alias: "" | ||
| - pkg: github.com/deckhouse/virtualization/api/subresources/v1alpha2 | ||
| alias: subv1alpha2 | ||
| - pkg: kubevirt.io/api/core/v1 | ||
| alias: virtv1 | ||
| - pkg: k8s.io/api/core/v1 | ||
| alias: corev1 | ||
| - pkg: k8s.io/api/authentication/v1 | ||
| alias: authnv1 | ||
| - pkg: k8s.io/api/storage/v1 | ||
| alias: storagev1 | ||
| - pkg: k8s.io/api/networking/v1 | ||
| alias: netv1 | ||
| - pkg: k8s.io/api/policy/v1 | ||
| alias: policyv1 | ||
| - pkg: k8s.io/apimachinery/pkg/apis/meta/v1 | ||
| alias: metav1 | ||
| - pkg: k8s.io/api/resource/v1 | ||
| alias: resourcev1 | ||
|
|
||
| linters: | ||
| disable-all: true | ||
| enable: | ||
| - asciicheck # checks that your code does not contain non-ASCII identifiers | ||
| - bidichk # checks for dangerous unicode character sequences | ||
| - bodyclose # checks whether HTTP response body is closed successfully | ||
| - contextcheck # [maby too many false positives] checks the function whether use a non-inherited context | ||
| - dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) | ||
| - errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases | ||
| - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error | ||
| - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 | ||
| - copyloopvar # detects places where loop variables are copied (Go 1.22+) | ||
| - gci # controls golang package import order and makes it always deterministic | ||
| - gocritic # provides diagnostics that check for bugs, performance and style issues | ||
| - gofmt # [replaced by goimports] checks whether code was gofmt-ed | ||
| - gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed | ||
| - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt | ||
| - gosimple # specializes in simplifying a code | ||
| - govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string | ||
| - ineffassign # detects when assignments to existing variables are not used | ||
| - misspell # finds commonly misspelled English words in comments | ||
| - nolintlint # reports ill-formed or insufficient nolint directives | ||
| - reassign # Checks that package variables are not reassigned. | ||
| - revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint | ||
| - stylecheck # is a replacement for golint | ||
| - staticcheck # is a go vet on steroids, applying a ton of static analysis checks | ||
| - typecheck # like the front-end of a Go compiler, parses and type-checks Go code | ||
| - testifylint # checks usage of github.com/stretchr/testify | ||
| - unconvert # removes unnecessary type conversions | ||
| - unparam # reports unused function parameters | ||
| - unused # checks for unused constants, variables, functions and types | ||
| - usetesting # reports uses of functions with replacement inside the testing package | ||
| - testableexamples # checks if examples are testable (have an expected output) | ||
| - thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers | ||
| - tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes | ||
| - whitespace # detects leading and trailing whitespace | ||
| - wastedassign # Finds wasted assignment statements. | ||
| - importas # checks import aliases against the configured convention |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| version: "3" | ||
|
|
||
| silent: true | ||
|
|
||
| tasks: | ||
| fmt: | ||
| desc: "Run formatters locally" | ||
| cmds: | ||
| - task: fmt:gci | ||
| - task: fmt:gofumpt | ||
|
|
||
| fmt:gci: | ||
| desc: "Format code with gci, important vars: paths." | ||
| cmds: | ||
| - | | ||
| gci write --skip-generated -s standard,default,prefix\(github.com/deckhouse/\) {{.CLI_ARGS}} {{.paths | default "pkg/ cmd/"}} | ||
|
|
||
| fmt:gofumpt: | ||
| desc: "Format code with gofumpt, important vars: paths" | ||
| cmds: | ||
| - | | ||
| gofumpt -extra -w {{.CLI_ARGS}} {{.paths | default "cmd/ pkg/"}} | ||
|
|
||
| dev:gogenerate: | ||
| desc: |- | ||
| Run go generate for all packages. | ||
| cmds: | ||
| - | | ||
| go generate ./... | ||
|
|
||
| dev:addlicense: | ||
| desc: |- | ||
| Add Flant CE license to files sh,go,py. Default directory is root of project, custom directory path can be passed like: "task dev:addlicense -- <somedir>" | ||
| cmds: | ||
| - | | ||
| {{if .CLI_ARGS}} | ||
| go run ../../tools/addlicense/{main,variables,msg,utils}.go -directory {{ .CLI_ARGS }} | ||
| {{else}} | ||
| go run ../../tools/addlicense/{main,variables,msg,utils}.go -directory ./ | ||
| {{end}} | ||
|
|
||
| test:unit: | ||
| desc: "Run go unit tests" | ||
| cmds: | ||
| - | | ||
| go tool ginkgo -v -r pkg/ | ||
|
|
||
| lint: | ||
| desc: "Run linters locally" | ||
| cmds: | ||
| - task: lint:go | ||
|
|
||
| lint:go: | ||
| desc: "Run golangci-lint" | ||
| deps: | ||
| - _ensure:golangci-lint | ||
| cmds: | ||
| - | | ||
| golangci-lint run |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.