Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Cannot add a custom service through Ambari 2.7.0

avatar

Hi All,

I have been trying to add a customer service through Ambari 2.7.0 (NOTE: that works fine with the previous versions). After selecting the service from Choose Serivces, the system tries to add a client first. But this comes back with the following error:

Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/stack-hooks/before-ANY/scripts/hook.py", line 35, in <module>
    BeforeAnyHook().execute()
  File "/usr/lib/ambari-agent/lib/resource_management/libraries/script/script.py", line 353, in execute
    method(env)
  File "/var/lib/ambari-agent/cache/stack-hooks/before-ANY/scripts/hook.py", line 29, in hook
    setup_users()
  File "/var/lib/ambari-agent/cache/stack-hooks/before-ANY/scripts/shared_initialization.py", line 50, in setup_users
    groups = params.user_to_groups_dict[user],
KeyError: 'myuser'
Error: Error: Unable to run the custom hook script ['/usr/bin/python', '/var/lib/ambari-agent/cache/stack-hooks/before-ANY/scripts/hook.py', 'ANY', '/var/lib/ambari-agent/data/command-3409.json', '/var/lib/ambari-agent/cache/stack-hooks/before-ANY', '/var/lib/ambari-agent/data/structured-out-3409.json', 'INFO', '/var/lib/ambari-agent/tmp', 'PROTOCOL_TLSv1_2', '']

Should myuser be part of the Service Users and Groups - see the below table:

screen-shot-2018-07-19-at-45504-pm.png

If so, how can I add one in there?

1 ACCEPTED SOLUTION

avatar
New Member

I've figured out what the problem is there.

In order to make it work - you need to add more fields to your user config in env.xml. Compare the above cassandra example:

  <property>
    <name>cassandra_user</name>
    <value>cassandra</value>
    <property-type>USER</property-type>
    <description></description>
  </property>

And working YARN example from the Ambari 2.7 server:

  <property>
    <name>yarn_ats_user</name>
    <display-name>Yarn ATS User</display-name>
    <value>yarn-ats</value>
    <property-type>USER</property-type>
    <description>YARN Client User for ATSv2 backend</description>
    <value-attributes>
      <type>user</type>
      <overridable>false</overridable>
      <user-groups>
        <property>
          <type>cluster-env</type>
          <name>user_group</name>
        </property>
      </user-groups>
    </value-attributes>
    <on-ambari-upgrade add="false"/>
  </property>

You need to add the display-name and value-attributes fields to your env.xml file (https://github.com/Dominion-Digital/ambari-cassandra-service/blob/master/configuration/cassandra-env.xml, for example). Then - restart ambari server and this problem should be solved. In case of service install - you may want to remove and then add again your service.

View solution in original post

4 REPLIES 4

avatar

@Jay Kumar SenSharma, @Geoffrey Shelton Okot

Are you able to help on the above? Many thanks!

avatar

@rguruvannagari

Do you have an idea about that issue and how to workaround it?

I think it may be related to the fact there is no entry for myuser in user_groups variable defined in /var/lib/ambari-agent/data/command-3409.json. However, I am not sure how this one is built.

Any pointers very much appreciated. Thanks!

avatar
New Member

same issue here when trying to install cassandra as per https://github.com/Dominion-Digital/ambari-cassandra-service

getting:

stderr: 
Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/stack-hooks/before-ANY/scripts/hook.py", line 35, in 
    BeforeAnyHook().execute()
  File "/usr/lib/ambari-agent/lib/resource_management/libraries/script/script.py", line 353, in execute
    method(env)
  File "/var/lib/ambari-agent/cache/stack-hooks/before-ANY/scripts/hook.py", line 29, in hook
    setup_users()
  File "/var/lib/ambari-agent/cache/stack-hooks/before-ANY/scripts/shared_initialization.py", line 50, in setup_users
    groups = params.user_to_groups_dict[user],
KeyError: u'cassandra'
Error: Error: Unable to run the custom hook script ['/usr/bin/python', '/var/lib/ambari-agent/cache/stack-hooks/before-ANY/scripts/hook.py', 'ANY', '/var/lib/ambari-agent/data/command-163.json', '/var/lib/ambari-agent/cache/stack-hooks/before-ANY', '/var/lib/ambari-agent/data/structured-out-163.json', 'INFO', '/var/lib/ambari-agent/tmp', 'PROTOCOL_TLSv1_2', '']
 stdout:
2018-09-04 05:05:23,042 - Stack Feature Version Info: Cluster Stack=3.0, Command Stack=None, Command Version=None -> 3.0
2018-09-04 05:05:23,048 - Group['hadoop'] {}
2018-09-04 05:05:23,050 - User['zookeeper'] {'gid': 'hadoop', 'fetch_nonlocal_groups': True, 'groups': ['hadoop'], 'uid': None}
Error: Error: Unable to run the custom hook script ['/usr/bin/python', '/var/lib/ambari-agent/cache/stack-hooks/before-ANY/scripts/hook.py', 'ANY', '/var/lib/ambari-agent/data/command-163.json', '/var/lib/ambari-agent/cache/stack-hooks/before-ANY', '/var/lib/ambari-agent/data/structured-out-163.json', 'INFO', '/var/lib/ambari-agent/tmp', 'PROTOCOL_TLSv1_2', '']
2018-09-04 05:05:23,074 - The repository with version 3.0.0.0-1634 for this command has been marked as resolved. It will be used to report the version of the component which was installed
2018-09-04 05:05:23,081 - Skipping stack-select on CASSANDRA because it does not exist in the stack-select package structure.

Command failed after 1 tries

any ideas?

avatar
New Member

I've figured out what the problem is there.

In order to make it work - you need to add more fields to your user config in env.xml. Compare the above cassandra example:

  <property>
    <name>cassandra_user</name>
    <value>cassandra</value>
    <property-type>USER</property-type>
    <description></description>
  </property>

And working YARN example from the Ambari 2.7 server:

  <property>
    <name>yarn_ats_user</name>
    <display-name>Yarn ATS User</display-name>
    <value>yarn-ats</value>
    <property-type>USER</property-type>
    <description>YARN Client User for ATSv2 backend</description>
    <value-attributes>
      <type>user</type>
      <overridable>false</overridable>
      <user-groups>
        <property>
          <type>cluster-env</type>
          <name>user_group</name>
        </property>
      </user-groups>
    </value-attributes>
    <on-ambari-upgrade add="false"/>
  </property>

You need to add the display-name and value-attributes fields to your env.xml file (https://github.com/Dominion-Digital/ambari-cassandra-service/blob/master/configuration/cassandra-env.xml, for example). Then - restart ambari server and this problem should be solved. In case of service install - you may want to remove and then add again your service.