Skip to content

Replaced deprecated pointer pkg with new ptr pkg on src/apimachinery #132413

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PatrickLaabs
Copy link
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This Pull Request replaces the deprecated package k8s.io/utils/pointer with the new k8s.io/utils/ptr on the components-helper for the apimachinery.

Which issue(s) this PR is related to:

As this is a long on-going effort, this PR does not closes a specific issue.
But it's related to #132086

Fixes #

Special notes for your reviewer:

In actually modified file there has already been migration happening from the old to the new package.
LeaseDurationSeconds: ptr.To[int32](10),

I choosed to follow this convention, as instead using the other option as
LeaseDurationSeconds: ptr.To(int32(10)),

We should think about using the variation : ptr.To(int32(10)).

Does this PR introduce a user-facing change?

Replaced deprecated package 'k8s.io/utils/pointer' with 'k8s.io/utils/ptr' for the components-helper of the apimachinery. 

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

NONE

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 20, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jun 20, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @PatrickLaabs. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jun 20, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: PatrickLaabs
Once this PR has been reviewed and has the lgtm label, please assign deads2k for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 requested review from deads2k and jpbetz June 20, 2025 05:15
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 20, 2025
Copy link
Contributor

@Octopusjust Octopusjust left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 23, 2025
Copy link

@dcq01 dcq01 left a comment

Choose a reason for hiding this comment

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

Hi! I'm a grad student working on a research project about using large language models to automate code review. Based on your commit d6ba9e1 and the changes in staging/src/k8s.io/component-helpers/apimachinery/lease/controller_test.go, my tool generated this comment:

  1. Verify that the new ptr.To function behaves identically to the previous pointer creation functions, especially in handling nil values or types.
    1. Implement error handling for operations that lead to the creation of the LeaseSpec to handle scenarios where node is not properly initialized.
    1. Validate LeaseDurationSeconds to ensure it falls within an acceptable range (e.g., greater than zero).
    1. Confirm that the logic of the test cases remains unchanged and that the new pointer functions do not introduce side effects.
    1. Run the tests after making these changes to ensure they still pass and that the behavior of the code remains consistent.
    1. Ensure that the ptr package is compatible with the existing codebase and provides the same functionality as the previous pointer package.
    1. Ensure that the removal of the pointer import is consistent throughout the codebase.
    1. Consider adding tests for edge cases, such as when node.Name is an empty string or when LeaseDurationSeconds is set to zero or a negative value.
    1. Create a helper function to generate the LeaseSpec to avoid repeating the same code block for HolderIdentity and LeaseDurationSeconds.
    1. Consider using a table-driven test approach to consolidate similar test cases into a single function.
    1. The explicit type specification in ptr.To[int32](10) improves code clarity and should be consistently applied wherever type-specific pointers are created.
    1. Ensure that the tests associated with this functionality are comprehensive and cover potential future scenarios.
    1. Review the entire file for any other potential unused imports or code that can be cleaned up.
    1. Ensure that the ptr package is correctly imported and supports the syntax ptr.To[int32](10).

As part of my research, I'm trying to understand how useful these comments are in real-world development. If you have a moment, I'd be super grateful if you could quickly reply to these two yes/no questions:

  1. Does this comment provide suggestions from a dimension you hadn’t considered?
    1. Do you find this comment helpful?

Thanks a lot for your time and feedback! And sorry again if this message is a bother.

@jpbetz
Copy link
Contributor

jpbetz commented Jun 25, 2025

@dcq01 when using tools (AI or otherwise) to provide automated responses. Would you please link to the tool(s) used? If we're going to invest time in providing training/refinement feedback, it seems appropriate we benefit in some way, presumably ideally vai access to to the tools used.

Most of this is particularly useful. This is part of a larger migration. We already know the functions are compatible. We also have linters for things like 13 and 14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants