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 job name of the osd prepare job further to avoid pod generation failure on K8s 1.22 #9312

Merged
merged 2 commits into from Dec 7, 2021

Conversation

travisn
Copy link
Member

@travisn travisn commented Dec 3, 2021

Description of your changes:

  • In K8s 1.22 there is a bug in the job name generation that the job name is truncated an additional 10 characters. This can cause an issue in the generated pod name if it then ends in a non-alphanumeric character. In that case, we more aggressively generate a hashed job name.
  • The generation of a long node name in the integration tests was being done based on the k8s version. In the past, older K8s versions did not support the changing name. Now it's more maintainable if we generate the long name depending on the test suite.

Which issue is resolved by this Pull Request:
Resolves #9294

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Skip Tests for Docs: Add the flag for skipping the build if this is only a documentation change. See here for the flag.
  • Skip Unrelated Tests: Add a flag to run tests for a specific storage provider. See test options.
  • Reviewed the developer guide on Submitting a Pull Request
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.
  • Pending release notes updated with breaking and/or notable changes, if necessary.
  • Upgrade from previous release is tested and upgrade user guide is updated, if necessary.
  • Code generation (make codegen) has been run to update object specifications, if necessary.


// truncateNodeName takes the max length desired for a string and hashes the value if needed to shorten it.
func truncateNodeName(format, nodeName string, maxLength int) string {
if len(nodeName)+len(fmt.Sprintf(format, "")) > maxLength {
hashed := Hash(nodeName)
logger.Infof("format and nodeName longer than %d chars, nodeName %s will be %s", validation.DNS1035LabelMaxLength, nodeName, hashed)
Copy link
Member

Choose a reason for hiding this comment

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

Should the log info message be updated too with maxLength instead of validation.DNS1035LabelMaxLength?

In K8s 1.22 there is a bug in the job name generation that
the job name is truncated an additional 10 characters. This can cause an issue
in the generated pod name if it then ends in a non-alphanumeric character. In that case,
we more aggressively generate a hashed job name.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
The generation of a long node name in the integration tests was
being done based on the k8s version. In the past, older K8s versions
did not support the changing name. Now it's more maintainable if
we generate the long name depending on the test suite.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
@leseb leseb merged commit 1f33859 into rook:master Dec 7, 2021
@mergify
Copy link

mergify bot commented Dec 7, 2021

This pull request has merge conflicts that must be resolved before it can be merged. @travisn please rebase it. https://rook.io/docs/rook/latest/development-flow.html#updating-your-fork

mergify bot added a commit that referenced this pull request Dec 7, 2021
Truncate job name of the osd prepare job further to avoid pod generation failure on K8s 1.22 (backport #9312)
travisn added a commit that referenced this pull request Dec 7, 2021
Truncate job name of the osd prepare job further to avoid pod generation failure on K8s 1.22 (backport #9312)
@travisn travisn deleted the truncate-job-name branch December 7, 2021 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rook-ceph-osd-prepare job pod name generation fails on kubernetes 1.22.4
2 participants