Skip to content

Conversation

@scodeman
Copy link

@scodeman scodeman commented Dec 16, 2025

Summary

This PR resolves Go module dependency issues and updates the project to be compatible with Ginkgo v2 test framework.

Issues Encountered

When running the initial commands:

go mod tidy
(cd addons && go run ../hack/addons/syn_addon_package.go ./ https://kubevela.github.io/catalog/official)
(cd experimental/addons && go run ../../hack/addons/syn_addon_package.go ./https://kubevela.github.io/catalog/experimental)

The following errors were encountered:

1. Missing/Deprecated Package Errors

sigs.k8s.io/controller-runtime/pkg/envtest/printer: module sigs.k8s.io/controller-runtime@latest 
found (v0.17.6), but does not contain package sigs.k8s.io/controller-runtime/pkg/envtest/printer

This error occurred in 11 test files that were importing the deprecated envtest/printer package and using the old Ginkgo v1 API. The package was removed in newer versions of controller-runtime as part of the Ginkgo v2 migration.

2. Konnectivity Client Package Errors

sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client/metrics: 
module does not contain package

sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/common/metrics: 
module does not contain package

These packages were moved/restructured in newer versions of the konnectivity-client, requiring proper version constraints via replace directives.

3. Build Compilation Errors (After Initial Fixes)

After attempting initial fixes, additional compatibility issues arose:

# sigs.k8s.io/kustomize/kyaml/openapi
cannot use doc (variable of type *"github.com/google/gnostic-models/openapiv2".Document) 
as *"github.com/google/gnostic/openapiv2".Document value in argument to swagger.FromGnostic

This required adding replace directives for gnostic packages and pinning kustomize versions to resolve the type mismatch between gnostic and gnostic-models packages.

Resolution

All these issues have been systematically resolved through:

  1. Removing deprecated test imports from all 11 test files
  2. Updating to Ginkgo v2 API (RunSpecs instead of RunSpecsWithDefaultAndCustomReporters)
  3. Adding comprehensive replace directives in go.mod for version constraints
  4. Pinning all affected packages to compatible versions

Changes Made

1. Dependency Updates

  • controller-runtime: Updated to v0.14.6 for stability and compatibility
  • k8s.io packages: Pinned to v0.26.3 (api, apimachinery, client-go, apiextensions-apiserver, apiserver, cli-runtime, component-base)
  • kube-openapi: Pinned to v0.0.0-20230202010329-39b3636cbaa3
  • konnectivity-client: Added replace directive for v0.0.37
  • OpenTelemetry packages: Added version constraints for compatibility (v1.10.0)
  • gnostic packages: Added replace directives to resolve version conflicts
  • kustomize packages: Pinned api to v0.12.1 and kyaml to v0.13.9

External Dependency Constraints (kubevela-core-api v1.7.7)
The project depends on kubevela-core-api v1.7.7, which requires:
k8s.io/apimachinery v0.25.3
k8s.io/client-go v0.25.3
sigs.k8s.io/controller-runtime v0.12.3
When we try to use v0.29.2 for k8s packages and v0.17.6 for controller-runtime, this create version conflicts because kubevela-core-api is pulling in older versions.

Compatibility Issues with Dependencies
When using the newer versions, the following errors occur:

  • OpenTelemetry Package Issues:
    go.opentelemetry.io/otel/semconv/v1.17.0: module found (v1.39.0, replaced by v1.10.0), but does not contain package go.opentelemetry.io/otel/semconv/v1.17.0
    The newer k8s versions require OpenTelemetry packages that conflict with what kubevela-core-api expects.
  • The same envtest/printer Issue:
    sigs.k8s.io/controller-runtime/pkg/envtest/printer: module found (v0.22.4), but does not contain package
    This still occurs because kubevela-core-api's test dependencies reference the old package.

The solution is to use a compatible middle ground where we chose v0.26.3 for k8s packages and v0.14.6 for controller-runtime because:
✅ They're newer than what kubevela-core-api requires (v0.25.3 and v0.12.3)
✅ They're compatible with each other and the dependency chain
✅ They work with the replace directives for konnectivity-client and other packages
✅ The build succeeds without conflicts

2. Test Code Migration (Ginkgo v2 Compatibility)

Updated 11 test files to be compatible with Ginkgo v2:

Removed deprecated imports:

  • Removed sigs.k8s.io/controller-runtime/pkg/envtest/printer from all test files

Updated test functions:

  • Changed from RunSpecsWithDefaultAndCustomReporters(t, "Suite Name", []Reporter{printer.NewlineReporter{}})
  • To RunSpecs(t, "Suite Name")

Files modified:

  • test/e2e-test/terraform-test/terraform_test.go
  • legacy/workloads/podspecworkload/controllers/suite_test.go
  • legacy/traits/sidecartrait/controllers/suite_test.go
  • legacy/traits/poddisruptionbudgettrait/controllers/suite_test.go
  • legacy/traits/autoscalertrait/controllers/suite_test.go
  • legacy/traits/cronhpatrait/controllers/suite_test.go
  • legacy/traits/metricstrait/controllers/suite_test.go
  • legacy/traits/routetrait/controllers/suite_test.go
  • legacy/traits/metrichpatrait/controllers/suite_test.go
  • legacy/traits/simplerollouttrait/controllers/suite_test.go
  • legacy/traits/hpatrait/test/suite_test.go

Testing

Build verification: ./hack/build.sh completes successfully
Addon sync (official): Successfully compiles and runs
Addon sync (experimental): Successfully compiles and runs
Test compilation: All test files compile correctly

Known Limitations

The go mod tidy command shows warnings about envtest/printer package from external dependencies (kubevela-core-api@v1.7.7). This is expected and harmless because:

  • These are test dependencies of external packages, not our code
  • We've fixed all our own test files
  • Build and runtime functionality is unaffected
  • We cannot control test dependencies of external packages

Commits

  • fix: update dependencies and resolve Ginkgo v2 compatibility
  • fix: add gnostic and kustomize version constraints for build compatibility

Summary by cubic

Updates Go dependencies and migrates tests to Ginkgo v2 to resolve build and compatibility issues. Builds and addon sync programs compile and run cleanly.

  • Dependencies

    • Pin Kubernetes stack to v0.26.3 and controller-runtime to v0.14.6.
    • Pin kube-openapi, gnostic, and kustomize versions; add konnectivity-client v0.0.37 replace.
    • Set OpenTelemetry packages to v1.10.0.
  • Test Migration

    • Remove envtest/printer imports and switch to RunSpecs across 11 test suites for Ginkgo v2.
    • Note: go mod tidy may show envtest/printer warnings from kubevela-core-api tests; harmless.

Written for commit e014816. Summary will update automatically on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 13 files

- Update controller-runtime to v0.14.6 for compatibility
- Pin k8s.io packages to v0.26.3
- Add replace directives for konnectivity-client (v0.0.37)
- Add OpenTelemetry version constraints for compatibility
- Remove deprecated envtest/printer imports from all test files
- Migrate from RunSpecsWithDefaultAndCustomReporters to RunSpecs

This resolves dependency conflicts and ensures compatibility with
Ginkgo v2 test framework.

Signed-off-by: S Code Man <30977678+scodeman@users.noreply.github.com>
…ility

- Add replace directives for gnostic packages to resolve version conflicts
- Pin kustomize/api to v0.12.1 and kustomize/kyaml to v0.13.9
- Ensures main code and addon sync programs compile successfully

Signed-off-by: S Code Man <30977678+scodeman@users.noreply.github.com>
…rect

- Restore fatih/color, kubevela-core-api, terraform-controller, pkg/errors as direct deps
- Restore k8s.io/apimachinery, k8s.io/client-go, controller-runtime as direct deps
- These are used by test files and should be explicit dependencies

Signed-off-by: S Code Man <30977678+scodeman@users.noreply.github.com>
@scodeman
Copy link
Author

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.

1 participant