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

Extract GVK more robustly when building applyset parent #368

Merged

Conversation

justinsb
Copy link
Contributor

@justinsb justinsb commented Jan 8, 2024

Include the case when we're using a typed object.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 8, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 8, 2024
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 8, 2024
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 8, 2024
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 8, 2024
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 8, 2024
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 8, 2024
@maqiuyujoyce
Copy link

Thank you so much for the quick fix, @justinsb ! I made a local copy of your change and verified the issue in the CC reconciliation is fixed.

/lgtm

@k8s-ci-robot
Copy link
Contributor

@maqiuyujoyce: changing LGTM is restricted to collaborators

In response to this:

Thank you so much for the quick fix, @justinsb ! I made a local copy of your change and verified the issue in the CC reconciliation is fixed.

/lgtm

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/test-infra repository.

justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 9, 2024
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 9, 2024
if err != nil {
return statusInfo, err
return nil, fmt.Errorf("getting GVK for %T: %w", instance, err)
Copy link

Choose a reason for hiding this comment

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

So this appears to be us returning an error we were never returning (ignoring) before. I believe there is also a difference between object.GetObjectKind().GroupVersionKind() and apiutil.GVKForObject(instance, r.mgr.GetScheme()) such that we things which were not errors for the former (eg 0 length kind or versions) which are errors for the latter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

client.Client uses apiutil.GVKForObject (IIRC), so we really should have been using that all along. We got away with it up until now because the cached client seems to set the GVK in the object. But when the KCC operator turned off the cache, the GVK was no longer set (possibly a bug in controller-runtime), and the difference mattered.

We also blew up immediately in the existing code if the GVK was empty. The first thing NewParentRef does is try to map the GVK to a resource, that gave an error which we weren't ignoring. By returning the error with the verbose message here, we hopefully make it easier to understand what's going wrong (and make it less likely that something is going wrong anyway, as we probably don't make it to this point if we can't make the object to a GVK!)

I did fix from returning nil, fmt.Errorf... to returning statusInfo, fmt.Errorf... ; mostly for consistency but it is more correct also.

Copy link

@maqiuyujoyce maqiuyujoyce Jan 10, 2024

Choose a reason for hiding this comment

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

Just to add some data points: During the upgrade of KDP from v0.13.0-beta to v0.15.0-beta, KCC had to deal with 12+/20+ (depending on how they are counted) breaking changes. Not saying that it is a good thing to have breaking changes, though if it is a fix and is potentially breaking, I think it seems to be aligning with the philosophy of KDP's minor version bump.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maqiuyujoyce I think the majority of those breakages are due to controller-runtime; we are actually starting to build a compatibility layer into kdp to try to smooth these transitions (commonclient). This one though is a bug/regression, although we are also switching the apply method which is why we hit it (and that should be opt-in).

Include the case when we're using a typed object.
@cheftako
Copy link

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 10, 2024
@k8s-ci-robot k8s-ci-robot merged commit d0f7229 into kubernetes-sigs:master Jan 10, 2024
6 checks passed
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 10, 2024
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 10, 2024
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 10, 2024
k8s-ci-robot added a commit that referenced this pull request Jan 12, 2024
…elease-0.15

Automated cherry pick of #368: Extract GVK more robustly when building applyset parent
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 12, 2024
justinsb added a commit to justinsb/k8s-config-connector that referenced this pull request Jan 12, 2024
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/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.

None yet

4 participants