-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 Stop relying on GVK being set on regular typed objects #9956
Conversation
@@ -416,7 +416,7 @@ func (r *KubeadmConfigReconciler) handleClusterNotInitialized(ctx context.Contex | |||
if scope.Config.Spec.InitConfiguration == nil { | |||
scope.Config.Spec.InitConfiguration = &bootstrapv1.InitConfiguration{ | |||
TypeMeta: metav1.TypeMeta{ | |||
APIVersion: "kubeadm.k8s.io/v1beta1", | |||
APIVersion: "kubeadm.k8s.io/v1beta3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriziopandini I guess this wasn't a problem because this code was never actually used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to dig into this, I will follow up ASAP (eventually we can drop this from this PR if you want to move forward)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the PR doesn't change it for the worse
@@ -193,7 +193,7 @@ func addVariablesForPatch(blueprint *scope.ClusterBlueprint, desired *scope.Clus | |||
if item.HolderReference.Kind == "MachineDeployment" { | |||
md, ok := mdStateIndex[item.HolderReference.Name] | |||
if !ok { | |||
return errors.Errorf("could not find desired state for MachineDeployment %s", klog.KObj(md.Object)) | |||
return errors.Errorf("could not find desired state for MachineDeployment %s", klog.KRef(item.HolderReference.Namespace, item.HolderReference.Name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This panic'ed previously if we actually hit this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
/test pull-cluster-api-e2e-full-main |
/lgtm |
LGTM label has been added. Git tree hash: 2f2609fd5a6c83cc5228ddac2174f21b59ba7782
|
Signed-off-by: Stefan Büringer buringerst@vmware.com
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
LGTM label has been added. Git tree hash: 17bbc8d6dff53dad0bde996c8f0ee540cd0d9bdc
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this change, only few nits from my side
@@ -193,7 +193,7 @@ func addVariablesForPatch(blueprint *scope.ClusterBlueprint, desired *scope.Clus | |||
if item.HolderReference.Kind == "MachineDeployment" { | |||
md, ok := mdStateIndex[item.HolderReference.Name] | |||
if !ok { | |||
return errors.Errorf("could not find desired state for MachineDeployment %s", klog.KObj(md.Object)) | |||
return errors.Errorf("could not find desired state for MachineDeployment %s", klog.KRef(item.HolderReference.Namespace, item.HolderReference.Name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini 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 |
…7468) * fix(deps): update module sigs.k8s.io/controller-runtime to v0.17.0 * make generate * Stop relying on GVK being set on SCP object TestReconcileStackConfigPolicy_Reconcile fails because with kubernetes-sigs/controller-runtime#2633 the fakeClient does not set the TypeMeta of the StackConfigPolicy object, so its typeMeta.Kind becomes empty but CanBeOwnedBy depends on it. The behavior change to not populate TypeMeta for regular object is to be aligned with the behavior of the real client, see kubernetes-sigs/cluster-api#9956: - APIReader does not set GVK on regular typed objects - Cached reader does not set GVK on regular typed objects (if disableDeepCopy = false, which is NOT default). We could just set the Kind of the StackConfigPolicy object in the tests but it's better to stop relying on GVK being set on the StackConfigPolicy object. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Thibault Richard <thb.krkr@gmail.com>
Signed-off-by: Stefan Büringer buringerst@vmware.com
What this PR does / why we need it:
Today controller-runtime doesn't set the GVKs of objects in all cases.
The current state is:
Because of these inconsistencies (that cannot be easily changed upstream) and because it's hard to tell across entire call stacks where objects come from I would suggest to only rely on GVK being set on Unstructured objects. For Unstructured objects GVK has to be always set to be able to identify the object, for regular typed objects this is not the case.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #