When installing a service via an Ambari custom stack, I would like to restrict one component to only be installed on a node that has a specific component already installed on it. For example, I might want the component to only get installed on the same node as the secondary namenode. Is there a way to force or guarantee that?
I have tried adding something like the following to my service's metainfo file within the component level:
<dependencies> <dependency> <name>HDFS/SECONDARY_NAMENODE</name> <scope>host</scope> <auto-deploy> <enabled>true</enabled> <co-locate>MY_SERVICE/MY_COMPONENT</co-locate> </auto-deploy> </dependency> </dependencies>
But when I install through the Ambari UI, it still lets me install on any node.
Adding host scope dependency at component level will make sure that the dependent component is co-hosted with the needed one. This is done by default in blueprint based deployment. Post ambari-2.5.0 release (trunk of ambari), work has been done to make sure that UI deployments also forces users to co-host required components as marked in the stack.
Although user can choose to deploy MY_SERVICE/MY_COMPONENT on some additional hosts as well in either blueprint or ui based deployment which will be permitted.
If you strictly want to restrict user to have MY_SERVICE/MY_COMPONENT only on HDFS/SECONDARY_NAMENODE than you can add that logic as python code in service advisor of the custom service.
HAWQ service had some specific requirements for which they added the logic in it's service advisor. you can refer it as an example: https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/common-services/HAWQ/2....
Ok, thanks. Is there any property that will make HDFS/SECONDARY_NAMENODE the default node my service will be installed on? (even if the user is able to override manually)
I assume that your question is in context of ui driven service deployment (ambari-web installer or add service wizard).
There is no such property in released versions of ambari that will make HDFS/SECONDARY_NAMENODE the default node for custom service will be installed on.
Although as I said in my previous comment that service developer can always add python code to achieve such requirements in custom service's service advisor.
Also in the ambari trunk some work has already been done to achieve similar requirement in decalarative manner rather than writing python code. This has been done via AMBARI-19685. It's associated reviewboard (link) has the images of how ui will react when host scope dependency is added for some component.
Although this is not exactly what you are looking for, it will help your use-case. If MY_SERVICE/MY_COMPONENT is not hosted on HDFS/SECONDARY_NAMENODE then user will be prompted with the error message before they move forward. This is a validation and I understand that you are more looking for default recommendation, so that by default MY_SERVICE/MY_COMPONENT is hosted on HDFS/SECONDARY_NAMENODE when user lands on "Assign Masters" page for the first time and if user overrides the default presented layout, then in that case AMBARI-19685 validation work should show the message for component level dependency violation.
Please report your requirement as a task at apache ambari Jira and let us know over here. I will follow up on the reported jira and try to add this functionality as part of being developed Ambari-3.0.0 release.