-
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
✨Update APIVersion for bootstrap references for Machine* resources #1852 #1938
✨Update APIVersion for bootstrap references for Machine* resources #1852 #1938
Conversation
Hi @neeleshkorade. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
/ok-to-test Thanks for the PR! Also need to do this for MachineSets. |
api/v1alpha2/conversion.go
Outdated
@@ -155,6 +155,10 @@ func (dst *MachineDeploymentList) ConvertFrom(srcRaw conversion.Hub) error { | |||
} | |||
|
|||
func Convert_v1alpha2_MachineSpec_To_v1alpha3_MachineSpec(in *MachineSpec, out *v1alpha3.MachineSpec, s apiconversion.Scope) error { | |||
if out.Bootstrap.ConfigRef.Kind == "KubeadmConfig" || out.Bootstrap.ConfigRef.Kind == "KubeadmConfigTemplate" { |
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 would also confirm the .Group matches bootstrap.kubeadm.api.v1alpha2.GroupVersion.Group
(you can alias the package import to bootstrapv1
).
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.
@ncdc for matching Group, this is what I have done-
out.Template.Spec.Bootstrap.ConfigRef.APIVersion = in.Template.Spec.Bootstrap.ConfigRef.GroupVersionKind().Group + "/" + "v1alpha3"
Please let me know if I am mistaken.
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 meant this:
inGV, err := schema.ParseGroupVersion(in.Boostrap.ConfigRef.APIVersion)
if err != nil {
return err
}
if inGV.Group == bootstrapv1.GroupVersion.Group && (in.Bootstrap.ConfigRef.Kind == "KubeadmConfig" || in.Bootstrap.ConfigRef.Kind == "KubeadmConfigTemplate") {
out.Bootstrap.ConfigRef.APIVersion = bootstrapv1.GroupVersion.String()
}
// ...
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.
Get it. However, bootstrapv1.GroupVersion.String()
would return v1alpha2
for the APIVersion
and not v1alpha3
, isn't it?
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.
It's fine to import the v1alpha3 package as bootstrapv1
- both v1alpha2 and v1alpha3 have the same API group.
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. Updated the PR with the changes.
api/v1alpha2/conversion.go
Outdated
@@ -164,6 +168,14 @@ func Convert_v1alpha2_MachineSpec_To_v1alpha3_MachineSpec(in *MachineSpec, out * | |||
return nil | |||
} | |||
|
|||
func Convert_v1alpha2_MachineDeploymentSpec_To_v1alpha3_MachineDeploymentSpec(in *MachineDeploymentSpec, out *v1alpha3.MachineDeploymentSpec, s apiconversion.Scope) error { | |||
if out.Template.Spec.Bootstrap.ConfigRef.Kind == "KubeadmConfig" || out.Template.Spec.Bootstrap.ConfigRef.Kind == "KubeadmConfigTemplate" { |
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.
Same comment re group match
Added changes to include |
Looking into the test failures. |
@ncdc also, one of the test cases is failing due to
Trying to understand what's the best way to fix this. I don't particularly like declaring |
You can put const (
kubeadmConfigKind = "KubeadmConfig"
kubeadmConfigTemplateKind = "KubeadmConfigTemplate"
) in this file if you'd like |
Thanks! Would you mind adding unit tests that test the changes are correct when converting from alpha2 to alpha3? @detiber the way this change is implemented, it doesn't guarantee that the resources stored in etcd are modified. It just handles the on the fly conversion if the storage version is alpha2. Although because we do use the deferred PatchHelper for all our resources, they'd all get processed and patched the first time a v1alpha3 pod ran... When the MachineDeployments and MachineSets have their KubeadmConfig refs changed, is that going to trigger a rolling update? |
70cd688
to
aa9fd8d
Compare
@ncdc added unit tests for the three new conversion functions. Please note-
Please let me know if anything else is missing. |
a9f33fd
to
165d00a
Compare
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.
A couple of nits around how the API group replacement is being done for MachineSets and MachineDeployments, otherwise lgtm
api/v1alpha2/conversion.go
Outdated
} | ||
|
||
if inGV.Group == bootstrapv1a3.GroupVersion.Group && (out.Template.Spec.Bootstrap.ConfigRef.Kind == kubeadmConfigKind || out.Template.Spec.Bootstrap.ConfigRef.Kind == kubeadmConfigTemplateKind) { | ||
out.Template.Spec.Bootstrap.ConfigRef.APIVersion = in.Template.Spec.Bootstrap.ConfigRef.GroupVersionKind().Group + "/" + "v1alpha3" |
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.
Shouldn't this use bootstrapv1a3.GroupVersion.String()
like line 175 above?
api/v1alpha2/conversion.go
Outdated
} | ||
|
||
if inGV.Group == bootstrapv1a3.GroupVersion.Group && (out.Template.Spec.Bootstrap.ConfigRef.Kind == kubeadmConfigKind || out.Template.Spec.Bootstrap.ConfigRef.Kind == kubeadmConfigTemplateKind) { | ||
out.Template.Spec.Bootstrap.ConfigRef.APIVersion = in.Template.Spec.Bootstrap.ConfigRef.GroupVersionKind().Group + "/" + "v1alpha3" |
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.
Shouldn't this use bootstrapv1a3.GroupVersion.String() like line 175 above?
@detiber did you see my question above? |
It should, however I do wonder if we should also suggest the use of the Storage Version Migrator utility as mentioned here: https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definition-versioning/#upgrade-existing-objects-to-a-new-stored-version |
api/v1alpha2/conversion_test.go
Outdated
@@ -192,7 +216,7 @@ func TestConvertMachineSet(t *testing.T) { | |||
}) | |||
} | |||
|
|||
func TestConvertMachineDeployment(t *testing.T) { | |||
func TestConvertMachineDeploymentSpec(t *testing.T) { |
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.
Please undo this change
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.
Done
api/v1alpha2/conversion_test.go
Outdated
@@ -242,4 +279,4 @@ func TestConvertMachineDeployment(t *testing.T) { | |||
g.Expect(restored.Spec.Template.Spec.ClusterName).To(Equal(src.Spec.Template.Spec.ClusterName)) | |||
}) | |||
}) | |||
} | |||
} |
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.
Please don't remove the newline at the end of the file. Thanks.
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.
Done
hack/tools/go.mod
Outdated
@@ -6,6 +6,7 @@ require ( | |||
github.com/blang/semver v3.5.1+incompatible | |||
github.com/golangci/golangci-lint v1.21.0 | |||
github.com/jteeuwen/go-bindata v3.0.7+incompatible | |||
golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495 // indirect |
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.
Do you know where this is coming from? cc @vincepri
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.
Looks like you need to run make modules
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'm not totally sure, we shouldn't be using anything from the experimental go package afaik, unless we mistakenly updated some deps
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.
Ran make verify-modules
and it removed the redundant module. Pushed the change, waiting for the build to go through.
2734064
to
1bdee48
Compare
@neeleshkorade there are still outstanding comments - will you be able to address them? |
1bdee48
to
6f654e1
Compare
Please squash and rebase on top of master - thanks! |
6f654e1
to
bd936c5
Compare
@ncdc running into this issue- Here's a snippet from the
|
2278298
to
ddefb05
Compare
@neeleshkorade: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
/retest |
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.
/approve
/assign @detiber
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: neeleshkorade, vincepri 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 |
api/v1alpha2/conversion.go
Outdated
if gvk.Group == bootstrapv1a3.GroupVersion.Group && gvk.Kind == kubeadmConfigTemplateKind { | ||
out.Template.Spec.Bootstrap.ConfigRef.APIVersion = bootstrapv1a3.GroupVersion.String() | ||
} | ||
} |
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'm actually wondering if this is strictly needed here, the autoConvert_v1alpha2_MachineSetSpec_To_v1alpha3_MachineSetSpec
method will cause Convert_v1alpha2_MachineSpec_To_v1alpha3_MachineSpec
to be called.
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.
It should be easy to check by removing this block, the test cases should still pass
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 works for Convert_v1alpha2_MachineSetSpec_To_v1alpha3_MachineSetSpec
but not for Convert_v1alpha2_MachineDeploymentSpec_To_v1alpha3_MachineDeploymentSpec
(the test TestConvertMachineDeployment
fails).
Looks like the reason is from here. We updated the if
condition to exclude kubeadmConfigTemplateKind
so now it fails for MachineDeploymentSpec
objects. Updating the if
condition makes the test pass.
I added the or
condition back in the if
statement. Also, as a result, it appeared to me that Convert_v1alpha2_MachineSetSpec_To_v1alpha3_MachineSetSpec
and Convert_v1alpha2_MachineDeploymentSpec_To_v1alpha3_MachineDeploymentSpec
functions becamse redundant. Have removed those as well. Let me know your feedback.
api/v1alpha2/conversion.go
Outdated
if gvk.Group == bootstrapv1a3.GroupVersion.Group && gvk.Kind == kubeadmConfigTemplateKind { | ||
out.Template.Spec.Bootstrap.ConfigRef.APIVersion = bootstrapv1a3.GroupVersion.String() | ||
} | ||
} |
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'm actually wondering if this is strictly needed here, the autoConvert_v1alpha2_MachineSetSpec_To_v1alpha3_MachineSetSpec method will cause Convert_v1alpha2_MachineSpec_To_v1alpha3_MachineSpec to be called.
…n v2 to v3 conversion
ddefb05
to
fcc777c
Compare
@neeleshkorade Thinking more about this problem, it seems that this approach might not be what we want. Going forward, we'll have support to understand contracts with:
|
Thanks @vincepri I went through the referenced issues and get what you are saying. Let me know if you would like me to close this PR. |
Thanks again for understanding! /close |
@vincepri: Closed this PR. In response to this:
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. |
What this PR does / why we need it:
APIVersion
for references toKubeadmConfig
andKubeadmConfigTemplate
for Machine* resources.Note- Skimming through the code, it appeared to me that it comprised of only two resources-
Machine
andMachineDeployment
. Please let me know if I have missed out any other resources that need to get this change.Which issue(s) this PR fixes:
Fixes #1852