Skip to content

chore(module): migrate to go.work#2626

Open
danilrwx wants to merge 18 commits into
mainfrom
chore/go-work
Open

chore(module): migrate to go.work#2626
danilrwx wants to merge 18 commits into
mainfrom
chore/go-work

Conversation

@danilrwx

@danilrwx danilrwx commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a go.work workspace at the repository root covering the Go modules that share the current Kubernetes 0.34 / KubeVirt v50 stack (api, virtualization-artifact, hooks, virtualization-dra, pvc-artifact, vm-route-forge, kube-api-rewriter, kubevirt-rules, vlctl, cli, e2e and tooling modules). With the workspace, cross-module changes (e.g. editing api/ and immediately using it from the controller) build without hand-editing replace directives.

Conflicting third-party pins across the member modules are unified in go.work via a minimal set of replace overrides (k8s core → v0.34.2, controller-runtime → v0.22.5, kube-openapi, kubevirt.io/api → v50, k8s.io/kubelet). The set was trimmed by removing dead/inherited replace directives from member go.mod files (notably ~20 unused k8s.io/* pins in vlctl and a malformed dynamic-resource-allocation replace in pvc-artifact).

To make the members share one dependency set, a few modules were aligned to newer versions:

  • deckhouse/log bumped to v0.2.0 (functional options API) in artifact, dra and hooks;
  • module-sdk bumped to v0.11.1 in hooks, which pulls controller-runtime v0.22.5; the artifact cluster (artifact, e2e, shatal, kube-api-rewriter) was moved onto the same controller-runtime / k8s 0.34 stack accordingly, and one removed SDK symbol (pkg.ReconcileFunc) was replaced.

The workspace files are not copied into any werf image build context, so isolated image builds keep using each module's own go.mod; every member was verified to build both in isolation (GOWORK=off, including -tags EE) and inside the workspace.

Why do we need it, and what problem does it solve?

The repository has many independent Go modules with cross-replace links. Without a workspace, working on a change that spans several of them (for example the shared api module and its consumers) requires manually pointing replace directives at local paths and reverting them before commit. The go.work file makes the whole set resolve locally out of the box, which simplifies day-to-day development and IDE/gopls setup. This is a developer-facing change; it does not affect the module's runtime behaviour.

What is the expected result?

  • go build ./... works from any member module with the workspace active.
  • Each image still builds in isolation (werf), unaffected by go.work.
  • CI validations (generated files up-to-date, go lint) and hooks unit tests pass.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: core
type: chore
summary: "Introduce a go.work workspace covering the repository Go modules to simplify local development."

@danilrwx danilrwx marked this pull request as ready for review July 9, 2026 18:04
@danilrwx danilrwx added this to the v1.10.0 milestone Jul 9, 2026
danilrwx added 15 commits July 9, 2026 20:19
module-sdk v0.11.1 pulls controller-runtime v0.22.x, which requires the
k8s 0.34 API stack and deckhouse/log v0.2.0. Bump the k8s.io replaces to
v0.34.2 and kube-openapi to a structured-merge-diff/v6 compatible pseudo.
Adapt tests to the renamed mock constructor
(NewPatchableValuesCollectorMock -> NewOutputPatchableValuesCollectorMock)
and to the functional log options API.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Move virtualization-artifact and virtualization-dra to deckhouse/log
v0.2.0 and its functional options API (WithLevel/WithOutput).

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Add a Go workspace over the modules sharing the k8s 0.34 / kubevirt v48
stack. Conflicting third-party pins (k8s.io/*, golang.org/x/oauth2,
k8s.io/kube-openapi) are unified via go.work replace so every member
builds against a single dependency set.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
controller-runtime v0.22 adds Apply to client.Client/Writer; regenerate
the moq client mock so it satisfies the interface.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Add images/hooks, images/virt-launcher/vlctl and images/dvcr-artifact to
the workspace. Their older k8s.io/*, openshift and controller-runtime
pins are unified via go.work replace (k8s 0.34.2, controller-runtime
v0.22.5, kubevirt v48). Drop images/cdi-cloner/cloner-startup, removed
from the repo by #2394.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Trim redundant/dead replace directives and unify shared versions so the
go.work workspace needs a minimal set of overrides:
- vlctl: drop ~20 dead k8s.io/* subpackage replaces (not in the require
  graph, inherited from the kubevirt template) and bump k8s core to 0.34.2
- pvc-artifact: fix a malformed k8s.io/dynamic-resource-allocation replace
  (missing module domain), bump golang.org/x/crypto to v0.52.0
- unify k8s.io/kube-openapi to the structured-merge-diff/v6 compatible
  pseudo-version across kube-api-rewriter, e2e, kubevirt-rules, shatal
- unify github.com/openshift/{api,client-go} between vlctl and pvc
- virtualization-artifact: bump golang.org/x/oauth2 to v0.34.0

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Replace dvcr-artifact with pvc-artifact in the workspace (both provide
module kubevirt.io/containerized-data-importer; only one can be a
workspace member). After aligning module deps, the go.work replace set
shrinks from 30 to 9: k8s core (6) at v0.34.2, kubevirt v50,
controller-runtime v0.22.5 and k8s.io/kubelet v0.34.2.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
pvc-artifact pinned k8s.io/code-generator to v0.30.2 via a replace but
does not require it. In the workspace this leaked into api code
generation, resolving code-generator to a version mismatched with the
tool binary and breaking 'task generate'. Drop the dead replace so the
workspace uses a single code-generator (v0.34.2).

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
The workspace hid incomplete per-module go.sum entries (covered by
go.work.sum), but werf builds each image in isolation without go.work.
Run go mod tidy for virtualization-dra (missing deckhouse/log v0.2.0 sum)
and kube-api-rewriter so their go.sum are self-contained.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
module-sdk v0.11.1 (hooks) requires controller-runtime v0.22.5, whose
client.Client API is incompatible with the v0.21 used by the rest of the
workspace. Align the whole artifact cluster on the newer stack so builds
are consistent both in isolation (werf) and in the workspace:
- virtualization-artifact: controller-runtime v0.22.5, regenerate client
  mock (client.Client gained Apply)
- e2e, shatal, kube-api-rewriter: bump k8s.io/* to v0.34.2,
  controller-runtime v0.22.5 and kube-openapi to the smd/v6 pseudo

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
module-sdk v0.11.1 removed pkg.ReconcileFunc. The EE-only
tls-certificates-audit hook used it; switch to pkg.HookFunc[*pkg.HookInput]
(same func(ctx, input) error signature). Only surfaced under -tags EE,
which werf builds use.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
…/slices

staticcheck (SA1019) flags k8s.io/utils/strings/slices as deprecated in
favor of the standard library slices package.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
controller-runtime v0.22 clears TypeMeta on objects returned by the
typed client, so the owner reference built for the population snapshot
had an empty APIVersion/Kind. Set the PVC GVK explicitly before
constructing the reference.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
…me v0.21

module-sdk v0.11.1 pulls controller-runtime v0.22, whose fake client
runs objects through structured-merge-diff on create/update/patch. That
panics on KubeVirt's uint64 VolumeStatus.Size (unsupported by SMD) in
many artifact unit tests. Use module-sdk v0.10.13 (same public API,
requires controller-runtime v0.20) and unify the workspace on
controller-runtime v0.21, which the artifact cluster already used.
Revert the artifact cluster (artifact, e2e, shatal, kube-api-rewriter)
to their native stacks and restore the original client mock.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx added the e2e/run Run e2e test on cluster of PR author label Jul 9, 2026
@deckhouse-BOaTswain

deckhouse-BOaTswain commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: failure.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Jul 9, 2026
The rootCA Secret template inlined the raw PEM cert/key into the data
field, which requires base64; the multi-line PEM broke chart rendering.
Encode with b64enc, matching the other tls secret templates.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx added the e2e/run Run e2e test on cluster of PR author label Jul 9, 2026
@deckhouse-BOaTswain

deckhouse-BOaTswain commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: failure.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Jul 9, 2026
danilrwx added 2 commits July 10, 2026 01:37
The rootCA cert in values is raw PEM; running b64dec on it produced an
'illegal base64 data' string as the ca-bundle, so virt-api could not
load the CA (TLS handshake failures, pods flapping). Use the PEM as-is.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
CASecret.Crt/Key are []byte, so setting the struct into values
re-encoded them to base64 (Go's []byte JSON convention). The TLS
certificate hooks then read an unparsable CA from values
("parse certificate: block not found"), treated it as outdated and
regenerated the CA on every reconcile — an endless module redeploy loop
that left virt-api unable to load the CA. Set the crt/key as plain PEM
strings instead.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx added the e2e/run Run e2e test on cluster of PR author label Jul 10, 2026
@deckhouse-BOaTswain

deckhouse-BOaTswain commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: failure.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants