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

Add MachinePhase type and helper functions #1080

Merged
merged 1 commit into from
Jun 27, 2019

Conversation

vincepri
Copy link
Member

Signed-off-by: Vince Prignano vincepri@vmware.com

What this PR does / why we need it:
This PR adds information to v1alpha2 types about Machine Phases as described in the bootstrap proposal.

In addition, it adds some helper methods on MachineStatus to ease the interaction with the Phase (*string) field.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Related to #1036

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 the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 26, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 26, 2019
@k8s-ci-robot k8s-ci-robot requested review from detiber and justinsb June 26, 2019 18:50
@vincepri
Copy link
Member Author

/assign @ncdc

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 26, 2019
@vincepri
Copy link
Member Author

/assign @detiber

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 26, 2019
@vincepri
Copy link
Member Author

@detiber ptal, I think this should be good to go

config/crds/cluster.sigs.k8s.io_machines.yaml Outdated Show resolved Hide resolved
}

// SetTypedPhase sets the Phase field to the string representation of MachinePhase.
func (m *MachineStatus) SetTypedPhase(p MachinePhase) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just Set/GetPhase?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can change it, thinking was that Phase is already a field and I wanted to avoid confusion for users of these methods, wdyt?

Copy link
Contributor

@davidewatson davidewatson Jun 27, 2019

Choose a reason for hiding this comment

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

I thought we agreed that Phase would remain a string: #997 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Since the commits were squashed I can't see the history. Either way, the current proposal makes the state machine explicit so I think it's fair to type it. I'll open an issue suggesting changes to the proposal out-of-band with this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's unchanged from v1alpha1, these methods are helpers to deal with the MachinePhase type (string)

@vincepri vincepri force-pushed the add-typed-phasex branch 2 times, most recently from fc8f51f to 444f83a Compare June 27, 2019 15:15
@vincepri
Copy link
Member Author

@detiber ptal

@@ -711,6 +712,9 @@ spec:
up status from the Node to the Machine. It is entirely optional, but
useful for end-user UX if it’s present.
type: string
required:
Copy link
Member

Choose a reason for hiding this comment

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

These are still showing as required.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm. I did set them as +optional did I miss something else?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it should be a pointer with omitempty?

/cc @ncdc

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so, does the crd definition need to be regenerated?

Copy link
Member

Choose a reason for hiding this comment

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

Pointer should only be needed if you need to differentiate unset from false.

Copy link
Contributor

Choose a reason for hiding this comment

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

Pointer is required for optional fields

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried different combinations, and it seems I need omitempty to be actually optional

Copy link
Member Author

Choose a reason for hiding this comment

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

so pointer and omitempty it is

Copy link
Member Author

Choose a reason for hiding this comment

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

pushed!

@k8s-ci-robot k8s-ci-robot requested a review from ncdc June 27, 2019 18:27
Signed-off-by: Vince Prignano <vincepri@vmware.com>
@detiber
Copy link
Member

detiber commented Jun 27, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 27, 2019
@vincepri
Copy link
Member Author

/test pull-cluster-api-test

@k8s-ci-robot k8s-ci-robot merged commit 5a82701 into kubernetes-sigs:master Jun 27, 2019
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants