# Buggy code
def _set_ssh_ip_if_required(self):
    if self.ssh_ip is not None:
        return

    # We assume that this never changes.
    #   I think that's reasonable.
    deadline = time.time() + NODE_START_WAIT_S
    with LogTimer(self.log_prefix + "Got IP"):
        ip = self.wait_for_ip(deadline)

        cli_logger.doassert(ip is not None, "Could not get node IP.")  # todo: msg
        assert ip is not None, "Unable to find IP of node"

    self.ssh_ip = ip

    # This should run before any SSH commands and therefore ensure that
    #   the ControlPath directory exists, allowing SSH to maintain
    #   persistent sessions later on.
    try:
        os.makedirs(self.ssh_control_path, mode=0o700, exist_ok=True)
    except OSError as e:
        cli_logger.warning(e)  # todo: msg
        cli_logger.old_warning(logger, e)


# Traceback (ValueError)
Error executing: unmatched '{' in format spec

Exception in thread Thread-2:
Traceback (most recent call last):
File "/Users/allenyin/anaconda3/lib/python3.7/site-packages/ray/autoscaler/updater.py", line 74, in run
self.do_update()
File "/Users/allenyin/anaconda3/lib/python3.7/site-packages/ray/autoscaler/updater.py", line 285, in do_update
cmd_to_print, _numbered=("()", i, total))
File "/Users/allenyin/anaconda3/lib/python3.7/site-packages/ray/autoscaler/cli_logger.py", line 323, in print
self._print(_format_msg(msg, *args, **kwargs))
File "/Users/allenyin/anaconda3/lib/python3.7/site-packages/ray/autoscaler/cli_logger.py", line 96, in _format_msg
return numbering_str + msg.format(*args, **kwargs) + tags_str
ValueError: unmatched '{' in format spec

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/allenyin/anaconda3/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/Users/allenyin/anaconda3/lib/python3.7/site-packages/ray/autoscaler/updater.py", line 95, in run
cli_logger.error(str(e))  # todo: handle this better somehow?
File "/Users/allenyin/anaconda3/lib/python3.7/site-packages/ray/autoscaler/cli_logger.py", line 316, in error
self._print(_format_msg(cf.red(msg), *args, **kwargs))
File "/Users/allenyin/anaconda3/lib/python3.7/site-packages/ray/autoscaler/cli_logger.py", line 96, in _format_msg
return numbering_str + msg.format(*args, **kwargs) + tags_str
ValueError: expected '}' before end of string

# Fixed code
def _set_ssh_ip_if_required(self):
    if self.ssh_ip is not None:
        return

    # We assume that this never changes.
    #   I think that's reasonable.
    deadline = time.time() + NODE_START_WAIT_S
    with LogTimer(self.log_prefix + "Got IP"):
        ip = self.wait_for_ip(deadline)

        cli_logger.doassert(ip is not None, "Could not get node IP.")  # todo: msg
        assert ip is not None, "Unable to find IP of node"

    self.ssh_ip = ip

    # This should run before any SSH commands and therefore ensure that
    #   the ControlPath directory exists, allowing SSH to maintain
    #   persistent sessions later on.
    try:
        os.makedirs(self.ssh_control_path, mode=0o700, exist_ok=True)
    except OSError as e:
        cli_logger.warning("{}", str(e))  # todo: msg
        cli_logger.old_warning(logger, "{}", str(e))