Skip to content
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

Enable backwards-compatibility with controller-runtime v0.15 #364

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

annasong20
Copy link
Contributor

@annasong20 annasong20 commented Nov 30, 2023

What this PR does / why we need it:

This PR makes the code backwards-compatible with versions of controller-runtime before 0.16, which introduced the metrics/server package that kdp now uses. The PR uses //go:build to segregate handling of the metrics configuration depending on the version of controller-runtime.

Special notes for your reviewer:

N/A

Additional documentation:

The following links may be useful references

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 30, 2023
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 30, 2023
@annasong20 annasong20 marked this pull request as ready for review November 30, 2023 17:15
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 30, 2023
@annasong20
Copy link
Contributor Author

/cc @yuwenma @haiyanmeng

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 30, 2023
Copy link
Contributor Author

@annasong20 annasong20 left a comment

Choose a reason for hiding this comment

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

/cc @justinsb

HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "c3cffa1a.example.org",
})
}
err := commonclient.SetMetricsBindAddress(&mgrOpt, "0")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that before controller-runtime 0.16, the manager options were

  • metrics bind address: metricsAddr
  • port: 9443

Reference: https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/pull/352/files#diff-866b8d47f82ed6ee8e23e1c3edd6657660b0edb465412ad315ce74e780793a11

Let me know if we want to replicate that behavior here.

LeaderElection: false,

// MapperProvider provides the rest mapper used to map go types to Kubernetes APIs
MapperProvider: restmapper.NewControllerRESTMapper,

Logger: logger,
})
}
err = commonclient.SetMetricsBindAddress(&mgrOpt, "0")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that before controller-runtime 0.16, the manager options were

  • metrics bind address: empty
  • port: 0

Reference: https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/pull/352/files#diff-62091d2b32c6b6c94aaed7ea3055732f56d47b34c5f66f31079a61a3908c3689L71

Let me know if we want to replicate that behavior here.

commonclient/manager_cr11.go Outdated Show resolved Hide resolved
Make kdp backwards-compatible with versions of controller-runtime before
v0.16, which introduced the metrics/server package.
@yuwenma
Copy link
Contributor

yuwenma commented Nov 30, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 30, 2023
@justinsb
Copy link
Contributor

justinsb commented Dec 4, 2023

Thanks @annasong20 - this is nice!

/approve
/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: annasong20, justinsb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 4, 2023
@k8s-ci-robot k8s-ci-robot merged commit 6f37936 into kubernetes-sigs:master Dec 4, 2023
6 checks passed
@annasong20 annasong20 deleted the add-go-build-16 branch December 4, 2023 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants