Skip to content

Conversation

aagumin
Copy link
Contributor

@aagumin aagumin commented Aug 18, 2025

Purpose of this PR

Proposed changes:

it's fix for #2509

  • length of the sparkapp name is validated through a mutation webhook.
  • length of the sceduledsparkapp name is validated through a mutation webhook.
  • Add unit and e2e tests.

Change Category

  • Bugfix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that could affect existing functionality)
  • Documentation update

Rationale

Checklist

  • I have conducted a self-review of my own code.
  • I have updated documentation accordingly.
  • I have added tests that prove my changes are effective or that my feature works.
  • Existing unit tests pass locally with my changes.

Additional Notes

@google-oss-prow google-oss-prow bot requested review from ImpSy and nabuskey August 18, 2025 20:36
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign andreyvelich for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@aagumin
Copy link
Contributor Author

aagumin commented Aug 19, 2025

@ChenYi015, Hi! Check my PR pls

var allErrs field.ErrorList
if len(appMeta.Name) > maxAppNameLength {
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata", "name"), appMeta.Name,
fmt.Sprintf("name must be no more than %d characters to allow for resource suffixes", maxAppNameLength)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fmt.Sprintf("name must be no more than %d characters to allow for resource suffixes", maxAppNameLength)))
fmt.Sprintf("name length must not exceed %d characters to allow for resource suffixes", maxAppNameLength)))

A bit easier to read this way imo

return nil, nil
}

if err := v.validateMetadata(ctx, newApp); err != nil {
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 need this for updates?

@ChenYi015 ChenYi015 linked an issue Aug 20, 2025 that may be closed by this pull request
1 task
Copy link
Member

@ChenYi015 ChenYi015 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! I have left some comments.

Comment on lines 20 to 23
"context"
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
Copy link
Member

Choose a reason for hiding this comment

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

Add a blank line between std and third-party imports to pass the golangci-lint check.

Suggested change
"context"
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
"context"
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"

Comment on lines 205 to 209
err := validateNameLength(ctx, meta)
if err != nil {
return err
}
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Can be simplified as:

Suggested change
err := validateNameLength(ctx, meta)
if err != nil {
return err
}
return nil
if err := validateNameLength(ctx, meta); err != nil {
return err
}
return nil

// and early error message.
func validateNameLength(_ context.Context, appMeta metav1.ObjectMeta) error {
var allErrs field.ErrorList
if len(appMeta.Name) > maxAppNameLength {
Copy link
Member

Choose a reason for hiding this comment

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

We only need to make sure the length of name is up to 63, see #2509 (comment).

Suggested change
if len(appMeta.Name) > maxAppNameLength {
if len(appMeta.Name) > validation.LabelValueMaxLength {

Copy link
Member

Choose a reason for hiding this comment

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

We also need to check the web UI service name is a DNS-1035 label name when enabled:

svcName := util.GetDefaultUIServiceName(app)
if !validation.IsDNS1035Label(svcName)) {
    ...
}

version: 4.0.0
instances: 1
cores: 1
memory: 512m No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

Add a new line at the end of file.

@aagumin aagumin force-pushed the bugfix/issue-2509/sparkapp-name-len-check branch from 6082bbc to 344a2c4 Compare September 18, 2025 20:37
@aagumin
Copy link
Contributor Author

aagumin commented Sep 26, 2025

Hi! Please look my PR again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resource creation can fail if the application name is over 63 characters

3 participants