private void removeOrphanConfigTypes() {
    Configuration configuration = clusterTopology.getConfiguration();
    removeOrphanConfigTypes(configuration);

    Map<String, HostGroupInfo> hostGroupInfoMap = clusterTopology.getHostGroupInfo();
    if (MapUtils.isNotEmpty(hostGroupInfoMap)) {
      for (Map.Entry<String, HostGroupInfo> hostGroupInfo : hostGroupInfoMap.entrySet()) {
        configuration = hostGroupInfo.getValue().getConfiguration();

        if (configuration != null) {
          removeOrphanConfigTypes(configuration);
        }
      }
    }
  }
Remove config-types, if there is no any services related to them (except cluster-env and global).
ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java