Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,37 @@ tasks:
}'
kubectl -n d8-virtualization port-forward deploy/virt-api 2345:2345
EOF

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

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

dlv:virtualization-dra-plugin:print:
desc: "Print commands for debug"
env:
IMAGE: "{{ .DLV_IMAGE }}"
cmd: |
cat <<EOF
kubectl -n d8-virtualization patch ds virtualization-dra --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [ {
"name": "virtualization-dra",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ]
}]
}
}
}
}'
kubectl -n d8-virtualization port-forward deploy/virtualization-dra 2345:2345
EOF
2 changes: 1 addition & 1 deletion build/components/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ firmware:
libvirt: v10.9.0
edk2: stable202411
core:
3p-kubevirt: v1.6.2-v12n.3
3p-kubevirt: feat/add-dra-usb-support # v1.6.2-v12n.3
3p-containerized-data-importer: v1.60.3-v12n.12
distribution: 2.8.3
package:
Expand Down
17 changes: 17 additions & 0 deletions crds/embedded/virtualmachineinstances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3594,6 +3594,7 @@ spec:
pciAddress:
description: PCIe bus address of the allocated device.
type: string
type: object
type: object
name:
description: Name of actual device on the host provisioned by the driver as reflected in `resourceclaim.status`.
Expand Down Expand Up @@ -3631,6 +3632,22 @@ spec:
pciAddress:
description: PCIe bus address of the allocated device.
type: string
usbAddress:
description: USBAddress is the USB bus address
of the allocated device
properties:
bus:
description: Bus is the bus of the allocated device
format: int64
type: integer
deviceNumber:
description: DeviceNumber is the device number of the allocated device
format: int64
type: integer
required:
- bus
- deviceNumber
type: object
type: object
name:
description: Name of actual device on the host provisioned by the driver as reflected in `resourceclaim.status`.
Expand Down
1 change: 1 addition & 0 deletions images/virt-artifact/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
image: {{ .ModuleNamePrefix }}{{ .ImageName }}-src-artifact
final: false
fromImage: builder/src
fromCacheVersion: "0002" # TODO: remove this
secrets:
- id: SOURCE_REPO
value: {{ $.SOURCE_REPO }}
Expand Down
6 changes: 3 additions & 3 deletions images/virt-controller/debug/dlv.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM golang:1.23 AS builder
FROM golang:1.23.0 AS builder

RUN go install github.com/go-delve/delve/cmd/dlv@latest

ARG BRANCH="v1.6.1-virtualization"
ENV VERSION="1.6.1"
ARG BRANCH="1.6.2-virtualization"
ENV VERSION="1.6.2"
ENV GOVERSION="1.23.0"

# Copy the git commits for rebuilding the image if the branch changes
Expand Down
2 changes: 2 additions & 0 deletions images/virt-launcher/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ altLibs:
- libvirglrenderer-devel
- libdbus
- libusb-devel
- libusb
- libbpf-devel
- libspice-server-devel
- ceph-devel
Expand Down Expand Up @@ -284,6 +285,7 @@ shell:
LIBS+=" /usr/lib64/libtpms* /usr/lib64/libjson* /usr/lib64/libfuse*"
LIBS+=" /usr/lib64/libxml2.s* /usr/lib64/libgcc_s* /usr/lib64/libaudit*"
LIBS+=" /usr/lib64/libisoburn.s* /usr/lib64/libacl.s*"
LIBS+=" /usr/lib64/libusb-*"

echo "Relocate additional libs for files in /VBINS"
./relocate_binaries.sh -i "$FILES" -o /VBINS
Expand Down
38 changes: 38 additions & 0 deletions images/virtualization-artifact/pkg/logger/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
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 logger

import (
"github.com/deckhouse/deckhouse/pkg/log"
"github.com/spf13/pflag"
)

type Options struct {
Level string
Output string
DebugVerbosity int
}

func (o *Options) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.Level, "log-level", o.Level, "Log level")
fs.StringVar(&o.Output, "log-output", o.Output, "Log output")
fs.IntVar(&o.DebugVerbosity, "log-debug-verbosity", o.DebugVerbosity, "Log debug verbosity")
}

func (o *Options) Complete() *log.Logger {
return NewLogger(o.Level, o.Output, o.DebugVerbosity)
}
31 changes: 31 additions & 0 deletions images/virtualization-dra-plugin/debug/dlv.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM golang:1.24.7-bookworm@sha256:2c5f7a0c252a17cf6aa30ddee15caa0f485ee29410a6ea64cddb62eea2b07bdf 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 -tags EE -gcflags "all=-N -l" -a -o virtualization-dra-plugin ./cmd/virtualization-dra-plugin

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-plugin /app/virtualization-dra-plugin
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-plugin", "--"]
8 changes: 8 additions & 0 deletions images/virtualization-dra-plugin/mount-points.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# A list of pre-created mount points for containerd strict mode.

dirs:
- /var/run/dbus
- /var/run/cdi
# - /sys/bus/usb/devices
- /var/lib/kubelet/plugins_registry
- /var/lib/kubelet/plugins
28 changes: 28 additions & 0 deletions images/virtualization-dra-plugin/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-plugin
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
{{- end }}
imageSpec:
config:
user: 64535
workingDir: "/app"
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-dra-plugin" }}
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"]
{{- else }}
entrypoint: ["/app/virtualization-dra-plugin"]
{{- end }}
108 changes: 108 additions & 0 deletions images/virtualization-dra/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
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

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
59 changes: 59 additions & 0 deletions images/virtualization-dra/Taskfile.yaml
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
Loading
Loading