mitaka cdh cluster deployments fails due to keytool command

Bug #1646114 reported by Robert Duncan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Sahara
Invalid
Undecided
Unassigned

Bug Description

The error message is:

Creating cluster failed for the following reason(s): An error occurred in thread 'configure-ssl-cert-8e316c93-a275-4abf-ad9a-86cd69ddd35f': RemoteCommandException: Error during command execution: "sudo su - -c "keytool -import -alias sahara-0 -keystore `cut -f2 -d \"=\" /etc/profile.d/99-java.sh | head -1`/lib/security/cacerts -file /tmp/cert.pem -noprompt -storepass changeit"" Return code: 127 STDERR: cut: /etc/profile.d/99-java.sh: No such file or directory stdin: is not a tty -su: keytool: command not found Error ID: 98746eff-e7e9-4ad0-8e14-7cb328b28830 Error ID: 2482697b-5a11-4fac-bcee-f52b09a944cd Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/sahara/context.py", line 172, in _wrapper func(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/sahara/swift/swift_helper.py", line 101, in _install_ssl_certs r.execute_command(register_cmd % idx) File "/usr/lib/python2.7/dist-packages/sahara/utils/ssh_remote.py", line 748, in execute_command get_stderr, raise_when_error) File "/usr/lib/python2.7/dist-packages/sahara/utils/ssh_remote.py", line 820, in _run_s return self._run_with_log(func, timeout, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/sahara/utils/ssh_remote.py", line 671, in _run_with_log return self._run(func, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/sahara/utils/ssh_remote.py", line 816, in _run return procutils.run_in_subprocess(self.proc, func, args, kwargs) File "/usr/lib/python2.7/dist-packages/sahara/utils/procutils.py", line 57, in run_in_subprocess raise exceptions.SubprocessException(result['exception']) SubprocessException: RemoteCommandException: Error during command execution: "sudo su - -c "keytool -import -alias sahara-0 -keystore `cut -f2 -d \"=\" /etc/profile.d/99-java.sh | head -1`/lib/security/cacerts -file /tmp/cert.pem -noprompt -storepass changeit"" Return code: 127 STDERR: cut: /etc/profile.d/99-java.sh: No such file or directory stdin: is not a tty -su: keytool: command not found Error ID: 98746eff-e7e9-4ad0-8e14-7cb328b28830 Error ID: 2482697b-5a11-4fac-bcee-f52b09a944cd Error ID: 5d687d53-707f-4e56-841b-f9b7eab8cc69

due to /etc/profile.d/99-java.sh file not found

using Mitaka branch of sahara-image-elements 00-java-rc sets up JAVA envs

https://github.com/openstack/sahara-image-elements/blob/stable/mitaka/elements/java/environment.d/00-java-rc

export JAVA_RC="/etc/profile.d/99-java.sh"
export JAVA_BIN_RC="/etc/profile.d/98-java-bin.sh"

Sahara built Ubuntu trusty image for cdh 5.5 - but there is no 99-java.sh in /etc/profile.d/
therefore keytool command fails

 ls -la /etc/profile.d/
total 20
drwxr-xr-x 2 root root 4096 Nov 22 20:45 .
drwxr-xr-x 117 root root 4096 Nov 30 12:15 ..
-rw-r--r-- 1 root root 663 May 11 2016 bash_completion.sh
-rw-r--r-- 1 root root 1559 Jul 29 2014 Z97-byobu.sh
-rwxr-xr-x 1 root root 2691 Aug 17 14:26 Z99-cloud-locale-test.sh
ubuntu@rootrunas-cdh-5-worker-copy-2:/$ printenv | grep JAVA*
ubuntu@rootrunas-cdh-5-worker-copy-2:/$
ubuntu@rootrunas-cdh-5-worker-copy-2:/$
ubuntu@rootrunas-cdh-5-worker-copy-2:/$

my swift_help.py

from oslo_config import cfg
from oslo_log import log as logging

from sahara import context
from sahara.i18n import _LI
from sahara.swift import utils as su
from sahara.utils import xmlutils as x

LOG = logging.getLogger(__name__)
CONF = cfg.CONF
HADOOP_SWIFT_AUTH_URL = 'fs.swift.service.sahara.auth.url'
HADOOP_SWIFT_TENANT = 'fs.swift.service.sahara.tenant'
HADOOP_SWIFT_USERNAME = 'fs.swift.service.sahara.username'
HADOOP_SWIFT_PASSWORD = 'fs.swift.service.sahara.password'
HADOOP_SWIFT_REGION = 'fs.swift.service.sahara.region'
HADOOP_SWIFT_TRUST_ID = 'fs.swift.service.sahara.trust.id'
HADOOP_SWIFT_DOMAIN_NAME = 'fs.swift.service.sahara.domain.name'

opts = [
    cfg.StrOpt("public_identity_ca_file",
               help=("Location of ca certificate file to use for identity "
                     "client requests via public endpoint")),
    cfg.StrOpt("public_object_store_ca_file",
               help=("Location of ca certificate file to use for object-store "
                     "client requests via public endpoint"))
]

public_endpoint_cert_group = cfg.OptGroup(
    name="object_store_access", title="Auth options for Swift access from VM")

CONF.register_group(public_endpoint_cert_group)
CONF.register_opts(opts, group=public_endpoint_cert_group)

def retrieve_tenant():
    return context.current().tenant_name

def get_swift_configs():
    configs = x.load_hadoop_xml_defaults('swift/resources/conf-template.xml')
    for conf in configs:
        if conf['name'] == HADOOP_SWIFT_AUTH_URL:
            conf['value'] = su.retrieve_auth_url() + "tokens/"
        if conf['name'] == HADOOP_SWIFT_TENANT:
            conf['value'] = retrieve_tenant()
        if CONF.os_region_name and conf['name'] == HADOOP_SWIFT_REGION:
            conf['value'] = CONF.os_region_name

    result = [cfg for cfg in configs if cfg['value']]
    LOG.info(_LI("Swift would be integrated with the following "
             "params: {result}").format(result=result))
    return result

def read_default_swift_configs():
    return x.load_hadoop_xml_defaults('swift/resources/conf-template.xml')

def install_ssl_certs(instances):
    certs = []
    if CONF.object_store_access.public_identity_ca_file:
        certs.append(CONF.object_store_access.public_identity_ca_file)
    if CONF.object_store_access.public_object_store_ca_file:
        certs.append(CONF.object_store_access.public_object_store_ca_file)
    if not certs:
        return
    with context.ThreadGroup() as tg:
        for inst in instances:
            tg.spawn("configure-ssl-cert-%s" % inst.instance_id,
                     _install_ssl_certs, inst, certs)

def _install_ssl_certs(instance, certs):
    register_cmd = (
        "sudo su - -c \"keytool -import -alias sahara-%d -keystore "
        "`cut -f2 -d \\\"=\\\" /etc/profile.d/99-java.sh | head -1`"
        "/lib/security/cacerts -file /tmp/cert.pem -noprompt -storepass "
        "changeit\"")
    with instance.remote() as r:
        for idx, cert in enumerate(certs):
            with open(cert) as cert_fd:
                data = cert_fd.read()
            r.write_file_to("/tmp/cert.pem", data)
            try:
                r.execute_command(register_cmd % idx)
            finally:
                r.execute_command("rm /tmp/cert.pem")

Revision history for this message
Vitalii Gridnev (vgridnev) wrote :

Have you tried to rebuild image using latest image elements?

Revision history for this message
Vitalii Gridnev (vgridnev) wrote :

there was a fix introduced https://github.com/openstack/sahara-image-elements/commit/6010b9a4e1a9e0912bd0b6e345fde02b9f56ca35 , actually, could you please retry that with a new image?

Revision history for this message
Robert Duncan (rduncan-t) wrote :

I checked my sahara-image-elements mitaka branch and it does not contain the patch, I have patched it now and re-running the image-create tool.

https://github.com/openstack/sahara-image-elements/tree/stable/mitaka/elements/hadoop-cloudera/install.d

Revision history for this message
Robert Duncan (rduncan-t) wrote :

thanks Vitaly! - I can confirm that patch works with the mitaka branch.

Revision history for this message
Vitalii Gridnev (vgridnev) wrote :

Cool

Changed in sahara:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.