def update_router_account()

in mysqloperator/controller/innodbcluster/router_objects.py [0:0]


def update_router_account(cluster: InnoDBCluster, on_nonupdated: Optional[Callable], logger: Logger) -> None:
      if not cluster.ready:
          logger.info(f"Cluster {cluster.namespace}/{cluster.name} not ready. Skipping router account update.")
          return

      try:
          user, password = cluster.get_router_account()
      except ApiException as e:
          if e.status == 404:
              # Should not happen, as cluster.ready should be False for a cluster with missing router account
              # In any case handle this case and skip
              logger.warning(f"Could not find router account of {cluster.name} in {cluster.namespace}")
              return
          raise

      updated = False

      for pod in cluster.get_pods():
          if pod.deleting:
              continue
          try:
              with shellutils.DbaWrap(shellutils.connect_dba(pod.endpoint_co, logger, max_tries=3)) as dba:
                  dba.get_cluster().setup_router_account(user, {"update": True})
                  updated = True
                  break

          except mysqlsh.Error as e:
              logger.warning(f"Could not connect to {pod.endpoint_co}: {e}")
              continue

      if not updated and on_nonupdated:
          on_nonupdated()