-
Notifications
You must be signed in to change notification settings - Fork 1.2k
server: trim autoscale Windows VM hostname #11327
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
36e636a
0c34a76
aa21706
b97ef66
4c9de62
4c9ff4c
16240b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1968,12 +1968,19 @@ protected Pair<String, String> getNextVmHostAndDisplayName(AutoScaleVmGroupVO as | |
RandomStringUtils.random(VM_HOSTNAME_RANDOM_SUFFIX_LENGTH, 0, 0, true, false, (char[])null, new SecureRandom()).toLowerCase(); | ||
// Truncate vm group name because max length of vm name is 63 | ||
int subStringLength = Math.min(asGroup.getName().length(), 63 - VM_HOSTNAME_PREFIX.length() - vmHostNameSuffix.length()); | ||
String displayName = VM_HOSTNAME_PREFIX + asGroup.getName().substring(0, subStringLength) + vmHostNameSuffix; | ||
String hostName = displayName; | ||
if (isWindows) { | ||
hostName = displayName.substring(Math.max(0, displayName.length() - 15)); | ||
String name = VM_HOSTNAME_PREFIX + asGroup.getName().substring(0, subStringLength) + vmHostNameSuffix; | ||
if (!isWindows) { | ||
return new Pair<>(name, name); | ||
} | ||
return new Pair<>(hostName, displayName); | ||
String hostName = name.substring(Math.max(0, name.length() - 15)); | ||
if (Character.isLetterOrDigit(hostName.charAt(0))) { | ||
return new Pair<>(hostName, name); | ||
} | ||
String temp = name.substring(0, Math.max(0, name.length() - 15)).replaceAll("[^a-zA-Z0-9]", ""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. edge case: all of the last 15 chars are special chars or whitespace. I think we better do a replace first and then take the last 15. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DaanHoogland I don't think this case can happen. |
||
if (!temp.isEmpty()) { | ||
return new Pair<>(temp.charAt(temp.length() - 1) + hostName.substring(1), name); | ||
} | ||
return new Pair<>('a' + hostName.substring(1), name); | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems digit it not supported as first char ? @shwstppr
cloudstack/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Lines 4104 to 4109 in 1272b13