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 validation enforcing that network subdomain adheres to RFC 1035 #278

Merged
merged 1 commit into from
Sep 13, 2023
Merged
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
5 changes: 5 additions & 0 deletions api/jobset/v1alpha2/jobset_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ func (js *JobSet) ValidateCreate() (admission.Warnings, error) {
for _, errMessage := range validation.IsDNS1123Subdomain(js.Spec.Network.Subdomain) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is RFC 1035 more emcompassing than DNS 1123? ie does validating DNS1035 mean that we also satisfy DNS 1123?

allErrs = append(allErrs, fmt.Errorf(errMessage))
}

// Since subdomain name is also used as service name, it must adhere to RFC 1035 as well.
for _, errMessage := range validation.IsDNS1035Label(js.Spec.Network.Subdomain) {
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
Contributor

Choose a reason for hiding this comment

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

ah, you are trying to validate for service too, sgtm.

/lgtm

allErrs = append(allErrs, fmt.Errorf(errMessage))
}
}

for _, rjob := range js.Spec.ReplicatedJobs {
Expand Down
4 changes: 2 additions & 2 deletions api/jobset/v1alpha2/jobset_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func TestValidateCreate(t *testing.T) {
Spec: JobSetSpec{
Network: &Network{
EnableDNSHostnames: ptr.To(true),
Subdomain: strings.Repeat("a", 257),
Subdomain: strings.Repeat("a", 64),
},
ReplicatedJobs: []ReplicatedJob{
{
Expand All @@ -498,7 +498,7 @@ func TestValidateCreate(t *testing.T) {
},
},
want: errors.Join(
fmt.Errorf("must be no more than 253 characters"),
fmt.Errorf("must be no more than 63 characters"),
),
},
}
Expand Down