1
0
mirror of https://github.com/rancher/os.git synced 2025-06-30 16:51:47 +00:00

Fix naming of external services (e.g. specified by rancher.services_include)

Add container_name key to service configuration.
This commit is contained in:
Ivan Mikushin 2015-12-17 18:30:16 +05:00
parent 0fc5fcca09
commit f4f59e97cc
5 changed files with 23 additions and 4 deletions

View File

@ -94,6 +94,19 @@ func addServices(p *project.Project, enabled map[interface{}]interface{}, config
return enabled return enabled
} }
func adjustContainerNames(m map[interface{}]interface{}) map[interface{}]interface{} {
for k, v := range m {
if k, ok := k.(string); ok {
if v, ok := v.(map[interface{}]interface{}); ok {
if _, ok := v["container_name"]; !ok {
v["container_name"] = k
}
}
}
}
return m
}
func newCoreServiceProject(cfg *config.CloudConfig, network bool) (*project.Project, error) { func newCoreServiceProject(cfg *config.CloudConfig, network bool) (*project.Project, error) {
projectEvents := make(chan project.Event) projectEvents := make(chan project.Event)
enabled := map[interface{}]interface{}{} enabled := map[interface{}]interface{}{}
@ -135,7 +148,7 @@ func newCoreServiceProject(cfg *config.CloudConfig, network bool) (*project.Proj
log.Errorf("Failed to parse YAML configuration: %s : %v", service, err) log.Errorf("Failed to parse YAML configuration: %s : %v", service, err)
continue continue
} }
bytes, err = yaml.Marshal(config.StringifyValues(m)) bytes, err = yaml.Marshal(adjustContainerNames(config.StringifyValues(m)))
if err != nil { if err != nil {
log.Errorf("Failed to marshal YAML configuration: %s : %v", service, err) log.Errorf("Failed to marshal YAML configuration: %s : %v", service, err)
continue continue

View File

@ -194,7 +194,6 @@ func amendContainerNames(c *CloudConfig) (*CloudConfig, error) {
c.Rancher.Services, c.Rancher.Services,
} { } {
for k, v := range scm { for k, v := range scm {
v.Name = k
v.ContainerName = k v.ContainerName = k
} }
} }

View File

@ -3,6 +3,8 @@ rancher:
environment: environment:
ETCD_DISCOVERY: https://discovery.etcd.io/c2c219023108cda9529364d6d983fe13 ETCD_DISCOVERY: https://discovery.etcd.io/c2c219023108cda9529364d6d983fe13
FLANNEL_NETWORK: 10.244.0.0/16 FLANNEL_NETWORK: 10.244.0.0/16
services_include:
kernel-headers: true
network: network:
interfaces: interfaces:
eth1: eth1:

View File

@ -63,6 +63,11 @@ def test_dhcpcd(qemu, cloud_config):
assert v.find('dhcpcd -M') != -1 assert v.find('dhcpcd -M') != -1
@pytest.mark.timeout(40)
def test_services_include(qemu, cloud_config):
u.wait_for_ssh(qemu, ssh_command, ['docker inspect kernel-headers >/dev/null 2>&1'])
@pytest.mark.timeout(40) @pytest.mark.timeout(40)
def test_docker_tls_args(qemu, cloud_config): def test_docker_tls_args(qemu, cloud_config):
u.wait_for_ssh(qemu, ssh_command) u.wait_for_ssh(qemu, ssh_command)

View File

@ -76,11 +76,11 @@ def flush_out(stdout, substr='RancherOS '):
@pytest.mark.timeout(10) @pytest.mark.timeout(10)
def wait_for_ssh(qemu, ssh_command=['./scripts/ssh', '--qemu']): def wait_for_ssh(qemu, ssh_command=['./scripts/ssh', '--qemu'], command=['docker version >/dev/null 2>&1']):
i = 0 i = 0
assert qemu.returncode is None assert qemu.returncode is None
print('\nWaiting for ssh and docker... ' + str(i)) print('\nWaiting for ssh and docker... ' + str(i))
while subprocess.call(ssh_command + ['docker version >/dev/null 2>&1']) != 0: while subprocess.call(ssh_command + command) != 0:
i += 1 i += 1
print('\nWaiting for ssh and docker... ' + str(i)) print('\nWaiting for ssh and docker... ' + str(i))
time.sleep(1) time.sleep(1)