Skip to content

chore: remove replace directives from go.mod#7821

Open
linkvt wants to merge 1 commit into
kedacore:mainfrom
linkvt:remove-replace-directives
Open

chore: remove replace directives from go.mod#7821
linkvt wants to merge 1 commit into
kedacore:mainfrom
linkvt:remove-replace-directives

Conversation

@linkvt

@linkvt linkvt commented Jun 2, 2026

Copy link
Copy Markdown
Member

replace directives in the go.mod are not transitive in Go, they only apply to the main module, not to downstream consumers like the HTTP Add-on and other projects (there seem to be quite a few based on reactions in #6660 or the recent comment in #7513).
This means any project that depends on github.com/kedacore/keda/v2 does not inherit these pins and gets different (incompatible) dependency versions resolved by Go's MVS.
Each of these projects needs to add replace directives on their own and their dependents also need to do that afterwards.

From what I know there is no reason at all to require both on higher versions and replace them with lower ones, we can just require the actual versions we support from the start.

keda should IMO consider the effect of its dependency tree on downstream projects as we have to depend on keda to implement the external scaler interface.

Happy to discuss these things, creating the PR also to check if all tests in CI pass.

Summary

  • Downgrade sigs.k8s.io/controller-tools from v0.21.0 to v0.20.1
  • Downgrade setup-envtest as it also requires apimachinery v0.36
  • Remove all 17 replace directives from go.mod
  • Pin k8s.io/* packages to v0.35.5 directly in require

More infos

controller-tools v0.21.0 declares k8s.io/* v0.36.0 in its go.mod, which forces Go's MVS to resolve k8s.io/client-go to v0.36.0. This is incompatible with controller-runtime v0.23.3. The replace directives were a workaround to force v0.35.5.

Instead, downgrade controller-tools to v0.20.1 (which uses k8s.io v0.35.0) so MVS naturally resolves to v0.35.5. This eliminates the need for all 17 replace directives and fixes downstream consumers that don't inherit replace directives.

The setup-envtest required apimachinery 0.36.0 so I also downgraded it to the latest pseudo version that is compatible with 0.35.

Checklist

  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

@linkvt linkvt requested a review from a team as a code owner June 2, 2026 12:58
@keda-automation keda-automation requested a review from a team June 2, 2026 12:58
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

Thank you for your contribution! 🙏

Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected.

While you are waiting, make sure to:

  • Add an entry in our changelog in alphabetical order and link related issue
  • Update the documentation, if needed
  • Add unit & e2e tests for your changes
  • GitHub checks are passing
  • Is the DCO check failing? Here is how you can fix DCO issues

Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient.

Learn more about our contribution guide.

@snyk-io

snyk-io Bot commented Jun 2, 2026

Copy link
Copy Markdown

⚠️ Snyk checks are incomplete.

Status Scan Engine Critical High Medium Low Total (0)
⚠️ Open Source Security 0 0 0 0 See details

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@linkvt linkvt marked this pull request as draft June 2, 2026 13:06
@linkvt linkvt force-pushed the remove-replace-directives branch from b6e9f96 to 075a87d Compare June 2, 2026 13:08
@linkvt

linkvt commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

I can't rerun the validate jobs, not sure if this was a flake or not.

Edit: was a flake, forcepush fixed it

@linkvt linkvt marked this pull request as ready for review June 2, 2026 15:23
controller-tools v0.21.0 declares k8s.io/* v0.36.0 in its go.mod,
which forces Go's MVS to resolve k8s.io/client-go to v0.36.0. This is
incompatible with controller-runtime v0.23.3 (missing HasSyncedChecker
method). The replace directives were a workaround to force v0.35.5.

Instead, downgrade controller-tools to v0.20.1 (which uses k8s.io
v0.35.0) so MVS naturally resolves to v0.35.5. This eliminates the
need for all 17 replace directives and fixes downstream consumers
like http-add-on that don't inherit replace directives.

Changes:
- Downgrade sigs.k8s.io/controller-tools from v0.21.0 to v0.20.1
- Remove all replace directives pinning k8s.io, prometheus, and cel-go
- Set k8s.io packages to v0.35.5 directly in require
- Update vendored dependencies to match

Signed-off-by: Vincent Link <vlink@redhat.com>
@linkvt linkvt force-pushed the remove-replace-directives branch from 075a87d to 6524a02 Compare June 3, 2026 10:02
@linkvt linkvt changed the title chore(deps): remove replace directives from go.mod chore: remove replace directives from go.mod Jun 3, 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.

1 participant