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

Truncate UI service name if over 63 characters #2311

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jacobsalway
Copy link
Member

Purpose of this PR

Truncate the UI service name while appending a hash to ensure uniqueness if longer than 63 characters.

Close #2300

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

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.

@jacobsalway jacobsalway marked this pull request as ready for review November 5, 2024 10:23
@jacobsalway
Copy link
Member Author

/assign @ChenYi015 @ImpSy


// Truncate the name and append a hash to ensure uniqueness while staying below the limit
hash := fmt.Sprintf("%x", md5.Sum([]byte(preferredName)))
return fmt.Sprintf("%s-%s-ui-svc", app.Name[:47], hash[:8])
}

func GetDefaultUIIngressName(app *v1beta2.SparkApplication) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should do the same for this function

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

}

// Truncate the name and append a hash to ensure uniqueness while staying below the limit
hash := fmt.Sprintf("%x", md5.Sum([]byte(preferredName)))
Copy link
Contributor

Choose a reason for hiding this comment

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

wdyt about reusing the first 8 character from the submissionID (app.Status.SubmissionID) instead ?

Copy link
Member Author

@jacobsalway jacobsalway Nov 7, 2024

Choose a reason for hiding this comment

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

Not a bad idea either as that's a UUID. Truncating the name and appending its hash was the first approach that came to mind as I've seen it in other systems/software for truncation.

https://github.com/kubeflow/spark-operator/blob/master/internal/controller/sparkapplication/controller.go#L649

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 ask for approval from chenyi015. 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

Signed-off-by: Jacob Salway <[email protected]>
@google-oss-prow google-oss-prow bot added size/M and removed size/S labels Nov 7, 2024
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.

[FEATURE] Truncate Webui Service name
3 participants