private static void validateSupportedStackVersion(StackInfo stack, ExtensionInfo extension) throws AmbariException {
    for (ExtensionMetainfoXml.Stack validStack : extension.getStacks()) {
      if (validStack.getName().equals(stack.getName())) {
        String minStackVersion = validStack.getVersion();
        if (VersionUtils.compareVersions(stack.getVersion(), minStackVersion) >= 0) {
          //Found a supported stack version
          return;
        }
      }
    }

    String message = "Stack is not supported by extension"
		+ ", stackName=" + stack.getName()
		+ ", stackVersion=" + stack.getVersion()
		+ ", extensionName=" + extension.getName()
		+ ", extensionVersion=" + extension.getVersion();

    throw new AmbariException(message);
  }
An extension version is like a stack version but it contains custom services.  Linking an extension
version to the current stack version allows the cluster to install the custom services contained in
the extension version.
ambari-server/src/main/java/org/apache/ambari/server/stack/ExtensionHelper.java