Generate stack name as a valid hostname
Truncate cluster name to 30 characters, map ('_', '.') to '-' and remove non alpha-numeric characters. Change-Id: Ibb2bddc5b602a34d0e2bebd1f6bb197669bf21ec Close-Bug: #1718947
This commit is contained in:
parent
375f44ceda
commit
283c093187
@ -14,6 +14,9 @@ import abc
|
||||
import os
|
||||
import six
|
||||
|
||||
from string import ascii_letters
|
||||
from string import digits
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
@ -109,8 +112,18 @@ class HeatDriver(driver.Driver):
|
||||
env_files)
|
||||
tpl_files.update(env_map)
|
||||
|
||||
# Make sure we end up with a valid hostname
|
||||
valid_chars = set(ascii_letters + digits + '-')
|
||||
|
||||
# valid hostnames are 63 chars long, leaving enough room
|
||||
# to add the random id (for uniqueness)
|
||||
stack_name = cluster.name[:30]
|
||||
stack_name = stack_name.replace('_', '-')
|
||||
stack_name = stack_name.replace('.', '-')
|
||||
stack_name = ''.join(filter(valid_chars.__contains__, stack_name))
|
||||
|
||||
# Make sure no duplicate stack name
|
||||
stack_name = '%s-%s' % (cluster.name, short_id.generate_id())
|
||||
stack_name = '%s-%s' % (stack_name, short_id.generate_id())
|
||||
if cluster_create_timeout:
|
||||
heat_timeout = cluster_create_timeout
|
||||
else:
|
||||
|
@ -755,7 +755,7 @@ class TestClusterConductorWithK8s(base.TestCase):
|
||||
mock_generate_id):
|
||||
|
||||
mock_generate_id.return_value = 'xx-xx-xx-xx'
|
||||
expected_stack_name = 'expected_stack_name-xx-xx-xx-xx'
|
||||
expected_stack_name = 'expected-stack-name-xx-xx-xx-xx'
|
||||
expected_template_contents = 'template_contents'
|
||||
dummy_cluster_name = 'expected_stack_name'
|
||||
expected_timeout = 15
|
||||
@ -796,7 +796,7 @@ class TestClusterConductorWithK8s(base.TestCase):
|
||||
mock_generate_id):
|
||||
|
||||
mock_generate_id.return_value = 'xx-xx-xx-xx'
|
||||
expected_stack_name = 'expected_stack_name-xx-xx-xx-xx'
|
||||
expected_stack_name = 'expected-stack-name-xx-xx-xx-xx'
|
||||
expected_template_contents = 'template_contents'
|
||||
dummy_cluster_name = 'expected_stack_name'
|
||||
expected_timeout = CONF.cluster_heat.create_timeout
|
||||
@ -836,7 +836,7 @@ class TestClusterConductorWithK8s(base.TestCase):
|
||||
mock_generate_id):
|
||||
|
||||
mock_generate_id.return_value = 'xx-xx-xx-xx'
|
||||
expected_stack_name = 'expected_stack_name-xx-xx-xx-xx'
|
||||
expected_stack_name = 'expected-stack-name-xx-xx-xx-xx'
|
||||
expected_template_contents = 'template_contents'
|
||||
dummy_cluster_name = 'expected_stack_name'
|
||||
cluster_timeout = 0
|
||||
|
6
releasenotes/notes/bug-1718947-0d4e67529e2817d7.yaml
Normal file
6
releasenotes/notes/bug-1718947-0d4e67529e2817d7.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
From now on, server names are prefixed with the cluster name.
|
||||
The cluster name is truncated to 30 characters, ('_', '.') are mapped to '-'
|
||||
and non alpha-numeric characters are removed to ensure FQDN compatibility.
|
Loading…
Reference in New Issue
Block a user