@Override
  public RepositoryVersionState getRepositoryState() {
    ServiceComponentDesiredStateEntity component = serviceComponentDesiredStateDAO.findById(
        desiredStateEntityId);

    if (null != component) {
      return component.getRepositoryState();
    } else {
      LOG.warn("Cannot retrieve repository state on component that may have been deleted: service {}, component {}",
          service != null ? service.getName() : null, componentName);

      return null;
    }
  }
Follows this version logic:
<table border="1">
  <tr>
    <th>DB hostcomponent1</th>
    <th>DB hostcomponentN</th>
    <th>DB desired</th>
    <th>New desired</th>
    <th>Repo State</th>
  </tr>
  <tr>
    <td>v1</td>
    <td>v1</td>
    <td>UNKNOWN</td>
    <td>v1</td>
    <td>CURRENT</td>
  </tr>
  <tr>
    <td>v1</td>
    <td>v2</td>
    <td>UNKNOWN</td>
    <td>UNKNOWN</td>
    <td>OUT_OF_SYNC</td>
  </tr>
  <tr>
    <td>v1</td>
    <td>v2</td>
    <td>v2</td>
    <td>v2 (no change)</td>
    <td>OUT_OF_SYNC</td>
  </tr>
  <tr>
    <td>v2</td>
    <td>v2</td>
    <td>v1</td>
    <td>v1 (no change)</td>
    <td>OUT_OF_SYNC</td>
  </tr>
  <tr>
    <td>v2</td>
    <td>v2</td>
    <td>v2</td>
    <td>v2 (no change)</td>
    <td>CURRENT</td>
  </tr>
</table>
ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java