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

Convert machineSpec.Versions to a pointer #683

Closed
wants to merge 1 commit into from

Conversation

enxebre
Copy link
Member

@enxebre enxebre commented Jan 16, 2019

What this PR does / why we need it:
Convert machineSpec.Versions to a pointer so omitempty does not actually marshals the field since it's optional consistently with Status.Versions.
For use cases where the machine config aka kubelet is managed orthogonally to the machine infra the field in the spec wouldn't trigger a moving forward reconciliation hence it wouldn't be leveraged.

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 #

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:


@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 16, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @enxebre. Thanks for your PR.

I'm waiting for a kubernetes-sigs or 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 16, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: enxebre
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: krousey

If they are not already assigned, you can assign the PR to them by writing /assign @krousey in a comment when ready.

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

@@ -70,7 +70,7 @@ type MachineSpec struct {
// should populate the values it uses when persisting Machine objects.
// A Machine spec missing this field at runtime is invalid.
// +optional
Versions MachineVersionInfo `json:"versions,omitempty"`
Versions *MachineVersionInfo `json:"versions,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

All consumers of the field will be required to change the field access logic. Their code will start to panic in cases where the Versions field is nil.

Copy link
Member

Choose a reason for hiding this comment

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

such changes are usually more suited in v1alphaX increments.

@ingvagabund
Copy link
Contributor

/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 Jan 16, 2019
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 16, 2019
@ingvagabund
Copy link
Contributor

ingvagabund commented Jan 16, 2019

pkg/controller/machine/machine_controller_test.go:42:			Versions: clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
pkg/controller/machineset/machineset_controller_test.go:46:					Versions: clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
pkg/controller/machinedeployment/machinedeployment_controller_test.go:62:					Versions: clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},

as well

@enxebre
Copy link
Member Author

enxebre commented Jan 16, 2019

/test pull-cluster-api-test

@ingvagabund
Copy link
Contributor

@ingvagabund
Copy link
Contributor

generateTestNodeMachine [1] does not set the Version field. Thus why the IsMaster function fails. It should go like:

func IsMaster(machine *clusterv1.Machine) bool {
	return machine.Spec.Versions != nil && machine.Spec.Versions.ControlPlane != ""
}

[1] https://github.com/kubernetes-sigs/cluster-api/blob/master/cmd/clusterctl/clusterdeployer/clusterdeployer_test.go#L1203-L1209

@davidewatson
Copy link
Contributor

Fixes part of #552

@alvaroaleman
Copy link
Member

Sorry, after closing #552 I saw this Pull.

For use cases where the machine config aka kubelet is managed orthogonally to the machine infra the field in the spec wouldn't trigger a moving forward reconciliation hence it wouldn't be leveraged

So the advantage of this PR is basically that we don't store+transmit a field when its not used?

@enxebre
Copy link
Member Author

enxebre commented Jan 28, 2019

@alvaroaleman yes, so it's actually omitted when empty

@detiber
Copy link
Member

detiber commented Jan 28, 2019

I'm a bit confused why we are replicating the version info between Spec and Status currently? I think the idea of having separate provider implementations that optionally use either the spec and/or the status seems counter-intuitive.

We should probably just standardize on the use of the Spec and then implementations could add their own validating and/or defaulting webhooks to enforce the behavior they expect out of how users and/or controllers interact with the spec field.

@ncdc
Copy link
Contributor

ncdc commented Mar 6, 2019

Could someone please summarize the state of this PR & the thinking about it - do we still want this?

@vincepri
Copy link
Member

vincepri commented Mar 7, 2019

I'm a little concerned on making the field optional for v1alpha1. There are a lot of providers that rely on the versions being populated to check if a node is a control plane or not.

@detiber
Copy link
Member

detiber commented Mar 7, 2019

I'm a little concerned on making the field optional for v1alpha1. There are a lot of providers that rely on the versions being populated to check if a node is a control plane or not.

As does the clusterctl workflow

@enxebre
Copy link
Member Author

enxebre commented Mar 11, 2019

If we agree on the change I'd say the sooner the better for transitioning. Providers should probably rely on the abstraction https://github.com/kubernetes-sigs/cluster-api/pull/683/files#diff-6c6a7fefe37261e2fa8a010cf9e7ae08R120 so changes are transparent. Other than that I don't have strong opinions for pre/post alpha

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 9, 2019
@detiber
Copy link
Member

detiber commented Jun 19, 2019

Closing since the v1alpha1 types shouldn't be changed at this point.
/close

@k8s-ci-robot
Copy link
Contributor

@detiber: Closed this PR.

In response to this:

Closing since the v1alpha1 types shouldn't be changed at this point.
/close

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.

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. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

10 participants