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

OCPBUGS-48260: Update dns1123Subdomain validation message for machineNamePrefix #2147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,25 @@ tests:
machine.openshift.io/cluster-api-cluster: cluster
spec:
providerSpec: {}
expectedError: 'Invalid value: "string": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, ''-'' or ''.'', and must start and end with an alphanumeric character.'
expectedError: 'Invalid value: "string": a lowercase RFC 1123 subdomain must consist of lowercase alphanumeric characters, hyphens (''-''), and periods (''.''). Each block, separated by periods, must start and end with an alphanumeric character. Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted.'
- name: Should reject to create ControlPlaneMachineSet with invalid machineNamePrefix - Consecutive periods are not permitted
initial: |
apiVersion: machine.openshift.io/v1
kind: ControlPlaneMachineSet
spec:
machineNamePrefix: "control..plane"
selector:
matchLabels:
machine.openshift.io/cluster-api-machine-role: master
machine.openshift.io/cluster-api-machine-type: master
template:
machineType: machines_v1beta1_machine_openshift_io
machines_v1beta1_machine_openshift_io:
metadata:
labels:
machine.openshift.io/cluster-api-machine-role: master
machine.openshift.io/cluster-api-machine-type: master
machine.openshift.io/cluster-api-cluster: cluster
spec:
providerSpec: {}
expectedError: 'Invalid value: "string": a lowercase RFC 1123 subdomain must consist of lowercase alphanumeric characters, hyphens (''-''), and periods (''.''). Each block, separated by periods, must start and end with an alphanumeric character. Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted.'
7 changes: 4 additions & 3 deletions machine/v1/types_controlplanemachineset.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ type ControlPlaneMachineSetSpec struct {
// Each machine name will consist of this prefix, followed by
// a randomly generated string of 5 characters, and the index of the machine.
// It must be a lowercase RFC 1123 subdomain, consisting of lowercase
// alphanumeric characters, '-', or '.', and must start and end
// with an alphanumeric character.
// alphanumeric characters, hyphens ('-'), and periods ('.').
// Each block, separated by periods, must start and end with an alphanumeric character.
// Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted.
// The prefix must be between 1 and 245 characters in length.
// For example, if machineNamePrefix is set to 'control-plane',
// and three machines are created, their names might be:
// control-plane-abcde-0, control-plane-fghij-1, control-plane-klmno-2
// +openshift:validation:FeatureGateAwareXValidation:featureGate=CPMSMachineNamePrefix,rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
// +openshift:validation:FeatureGateAwareXValidation:featureGate=CPMSMachineNamePrefix,rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a lowercase RFC 1123 subdomain must consist of lowercase alphanumeric characters, hyphens ('-'), and periods ('.'). Each block, separated by periods, must start and end with an alphanumeric character. Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted."
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 want to also update lines 48 to 50 to be similar?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, updated the API field description to be similar.

// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=245
// +openshift:enable:FeatureGate=CPMSMachineNamePrefix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ spec:
Each machine name will consist of this prefix, followed by
a randomly generated string of 5 characters, and the index of the machine.
It must be a lowercase RFC 1123 subdomain, consisting of lowercase
alphanumeric characters, '-', or '.', and must start and end
with an alphanumeric character.
alphanumeric characters, hyphens ('-'), and periods ('.').
Each block, separated by periods, must start and end with an alphanumeric character.
Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted.
The prefix must be between 1 and 245 characters in length.
For example, if machineNamePrefix is set to 'control-plane',
and three machines are created, their names might be:
Expand All @@ -91,9 +92,11 @@ spec:
minLength: 1
type: string
x-kubernetes-validations:
- message: a lowercase RFC 1123 subdomain must consist of lower case
alphanumeric characters, '-' or '.', and must start and end with
an alphanumeric character.
- message: a lowercase RFC 1123 subdomain must consist of lowercase
alphanumeric characters, hyphens ('-'), and periods ('.'). Each
block, separated by periods, must start and end with an alphanumeric
character. Hyphens are not allowed at the start or end of a block,
and consecutive periods are not permitted.
rule: '!format.dns1123Subdomain().validate(self).hasValue()'
replicas:
default: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ spec:
Each machine name will consist of this prefix, followed by
a randomly generated string of 5 characters, and the index of the machine.
It must be a lowercase RFC 1123 subdomain, consisting of lowercase
alphanumeric characters, '-', or '.', and must start and end
with an alphanumeric character.
alphanumeric characters, hyphens ('-'), and periods ('.').
Each block, separated by periods, must start and end with an alphanumeric character.
Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted.
The prefix must be between 1 and 245 characters in length.
For example, if machineNamePrefix is set to 'control-plane',
and three machines are created, their names might be:
Expand All @@ -91,9 +92,11 @@ spec:
minLength: 1
type: string
x-kubernetes-validations:
- message: a lowercase RFC 1123 subdomain must consist of lower case
alphanumeric characters, '-' or '.', and must start and end with
an alphanumeric character.
- message: a lowercase RFC 1123 subdomain must consist of lowercase
alphanumeric characters, hyphens ('-'), and periods ('.'). Each
block, separated by periods, must start and end with an alphanumeric
character. Hyphens are not allowed at the start or end of a block,
and consecutive periods are not permitted.
rule: '!format.dns1123Subdomain().validate(self).hasValue()'
replicas:
default: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ spec:
Each machine name will consist of this prefix, followed by
a randomly generated string of 5 characters, and the index of the machine.
It must be a lowercase RFC 1123 subdomain, consisting of lowercase
alphanumeric characters, '-', or '.', and must start and end
with an alphanumeric character.
alphanumeric characters, hyphens ('-'), and periods ('.').
Each block, separated by periods, must start and end with an alphanumeric character.
Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted.
The prefix must be between 1 and 245 characters in length.
For example, if machineNamePrefix is set to 'control-plane',
and three machines are created, their names might be:
Expand All @@ -91,9 +92,11 @@ spec:
minLength: 1
type: string
x-kubernetes-validations:
- message: a lowercase RFC 1123 subdomain must consist of lower case
alphanumeric characters, '-' or '.', and must start and end with
an alphanumeric character.
- message: a lowercase RFC 1123 subdomain must consist of lowercase
alphanumeric characters, hyphens ('-'), and periods ('.'). Each
block, separated by periods, must start and end with an alphanumeric
character. Hyphens are not allowed at the start or end of a block,
and consecutive periods are not permitted.
rule: '!format.dns1123Subdomain().validate(self).hasValue()'
replicas:
default: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ spec:
Each machine name will consist of this prefix, followed by
a randomly generated string of 5 characters, and the index of the machine.
It must be a lowercase RFC 1123 subdomain, consisting of lowercase
alphanumeric characters, '-', or '.', and must start and end
with an alphanumeric character.
alphanumeric characters, hyphens ('-'), and periods ('.').
Each block, separated by periods, must start and end with an alphanumeric character.
Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted.
The prefix must be between 1 and 245 characters in length.
For example, if machineNamePrefix is set to 'control-plane',
and three machines are created, their names might be:
Expand All @@ -93,9 +94,11 @@ spec:
minLength: 1
type: string
x-kubernetes-validations:
- message: a lowercase RFC 1123 subdomain must consist of lower case
alphanumeric characters, '-' or '.', and must start and end with
an alphanumeric character.
- message: a lowercase RFC 1123 subdomain must consist of lowercase
alphanumeric characters, hyphens ('-'), and periods ('.'). Each
block, separated by periods, must start and end with an alphanumeric
character. Hyphens are not allowed at the start or end of a block,
and consecutive periods are not permitted.
rule: '!format.dns1123Subdomain().validate(self).hasValue()'
replicas:
default: 3
Expand Down
2 changes: 1 addition & 1 deletion machine/v1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion openapi/generated_openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -18878,7 +18878,7 @@
],
"properties": {
"machineNamePrefix": {
"description": "machineNamePrefix is the prefix used when creating machine names. Each machine name will consist of this prefix, followed by a randomly generated string of 5 characters, and the index of the machine. It must be a lowercase RFC 1123 subdomain, consisting of lowercase alphanumeric characters, '-', or '.', and must start and end with an alphanumeric character. The prefix must be between 1 and 245 characters in length. For example, if machineNamePrefix is set to 'control-plane', and three machines are created, their names might be: control-plane-abcde-0, control-plane-fghij-1, control-plane-klmno-2",
"description": "machineNamePrefix is the prefix used when creating machine names. Each machine name will consist of this prefix, followed by a randomly generated string of 5 characters, and the index of the machine. It must be a lowercase RFC 1123 subdomain, consisting of lowercase alphanumeric characters, hyphens ('-'), and periods ('.'). Each block, separated by periods, must start and end with an alphanumeric character. Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted. The prefix must be between 1 and 245 characters in length. For example, if machineNamePrefix is set to 'control-plane', and three machines are created, their names might be: control-plane-abcde-0, control-plane-fghij-1, control-plane-klmno-2",
"type": "string"
},
"replicas": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ spec:
Each machine name will consist of this prefix, followed by
a randomly generated string of 5 characters, and the index of the machine.
It must be a lowercase RFC 1123 subdomain, consisting of lowercase
alphanumeric characters, '-', or '.', and must start and end
with an alphanumeric character.
alphanumeric characters, hyphens ('-'), and periods ('.').
Each block, separated by periods, must start and end with an alphanumeric character.
Hyphens are not allowed at the start or end of a block, and consecutive periods are not permitted.
The prefix must be between 1 and 245 characters in length.
For example, if machineNamePrefix is set to 'control-plane',
and three machines are created, their names might be:
Expand All @@ -91,9 +92,11 @@ spec:
minLength: 1
type: string
x-kubernetes-validations:
- message: a lowercase RFC 1123 subdomain must consist of lower case
alphanumeric characters, '-' or '.', and must start and end with
an alphanumeric character.
- message: a lowercase RFC 1123 subdomain must consist of lowercase
alphanumeric characters, hyphens ('-'), and periods ('.'). Each
block, separated by periods, must start and end with an alphanumeric
character. Hyphens are not allowed at the start or end of a block,
and consecutive periods are not permitted.
rule: '!format.dns1123Subdomain().validate(self).hasValue()'
replicas:
default: 3
Expand Down
Loading