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

[OCPCLOUD-1349] Add Machine Deletion Hook consts to machine API #1050

Merged
merged 2 commits into from
Nov 22, 2021

Conversation

JoelSpeed
Copy link
Contributor

@JoelSpeed JoelSpeed commented Nov 4, 2021

This is to implement openshift/enhancements#862 as it currently stands.

This adds the concept of lifecycle hooks to the machine to allow consumers to pause the machine removal process at either the draining or termination phases.

The condition constants will be used to add reporting on the Machines themselves as to the state of the hooks, see the enhancement for further details on this.

Copy link
Contributor

@alexander-demicev alexander-demicev left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 4, 2021
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 17, 2021
// This could be the name of a controller (e.g. clusteroperator/etcd)
// or an administrator managing the hook.
// +required
Owner string `json:"owner"`
Copy link
Contributor

Choose a reason for hiding this comment

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

can this value be empty? if not can we add validation for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Value cannot be empty, it is expected to always be populated in each entry, though with what we don't specify. I think this can be free form text. Not sure what validation you had in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe some minimal length if it makes sense here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think a minimum length is hard to quantify, we could put 5 characters, but then what if the owner is etcd, or something equivalently short. I think we should trust operators to put something useful within this field

Copy link
Contributor

@deads2k deads2k Nov 22, 2021

Choose a reason for hiding this comment

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

how about min==3 max==512? otherwise it becomes a paragraph.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we typically have a maximum length for Condition Types? Since the name becomes part of the condition type, perhaps it's sensible to even limit at 256

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we typically have a maximum length for Condition Types? Since the name becomes part of the condition type, perhaps it's sensible to even limit at 256

We do, see comment below.

// LifecycleHook represents a single instance of a lifecycle hook
type LifecycleHook struct {
// Name defines a unique name for the lifcycle hook.
// The name should be unique and descriptive, ideally 1-3 words, in camelCase with no spaces.
Copy link
Contributor

Choose a reason for hiding this comment

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

is "camelCase" specified by the upstream? If not, we normally use CamelCase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be a typo, I had intended (from the examples I've created) that this be CamelCase, good catch, will update

// Name defines a unique name for the lifcycle hook.
// The name should be unique and descriptive, ideally 1-3 words, in camelCase with no spaces.
// Names must be unique and should only be managed by a single entity.
// +kubebuilder:validation:Pattern:="[A-Za-z]+"
Copy link
Contributor

Choose a reason for hiding this comment

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

no numbers, no slashes, no dots is intentional? I'm ok with it if that is your preference. Finalizers were envisioned as structured as, "foo.domain.name/item".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the name becomes part of the Condtion Type, I had originally limited it so that it would just be standard alpha CamelCase as this is typically what I've seen in Condition Types. I'm not against extending it to be more but then it might conflict with the Name forming part of the Condition Type and having those fit to conventions

Copy link
Contributor

Choose a reason for hiding this comment

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

From Condition in meta/v1

	// type of condition in CamelCase or in foo.example.com/CamelCase.
	// ---
	// Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be
	// useful (see .node.status.conditions), the ability to deconflict is important.
	// The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
	// +required
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$`
	// +kubebuilder:validation:MaxLength=316
	Type string `json:"type" protobuf:"bytes,1,opt,name=type"`

if you want to line it up to match.

@deads2k
Copy link
Contributor

deads2k commented Nov 22, 2021

/approve

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 22, 2021
Copy link
Contributor

@alexander-demicev alexander-demicev left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 22, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexander-demichev, deads2k, JoelSpeed

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

@openshift-merge-robot openshift-merge-robot merged commit bc2d3cf into openshift:master Nov 22, 2021
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants