shwstppr commented on code in PR #11327: URL: https://github.com/apache/cloudstack/pull/11327#discussion_r2299756090
########## server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java: ########## @@ -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]", ""); Review Comment: @DaanHoogland I don't think this case can happen. The only user-defined part in the VM name is the name of the autoscale group, and we've checks for that to only contain letters, numbers and hyphen. checkAutoScaleVmGroupName` does that -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org