[autoscaler][commands] Fix load metrics summary (#20623)

Running ray status with the changes from #20359
while running an autoscaler older than those changes
results in an error on input "head_ip" to LoadMetricsSummary.
See #20359 (comment)
This PR fixes the bug by restoring head_ip as an optional parameter of LoadMetricsSummary.
This commit is contained in:
Dmitri Gekhtman 2021-11-22 07:34:02 -05:00 committed by GitHub
parent a912b68375
commit 76a01862cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -4,7 +4,7 @@ from functools import reduce
import logging
from numbers import Number
import time
from typing import Dict, List, Tuple
from typing import Dict, List, Optional, Tuple
import numpy as np
import ray.ray_constants
@ -34,6 +34,8 @@ class LoadMetricsSummary:
# Counts of demand bundles requested by autoscaler.sdk.request_resources
request_demand: List[DictCount]
node_types: List[DictCount]
# Optionally included for backwards compatibility: IP of the head node.
head_ip: Optional[NodeIP] = None
def add_resources(dict1: Dict[str, float],

View file

@ -1409,6 +1409,12 @@ class LoadMetricsTest(unittest.TestCase):
# Ensure summary_dict is json-serializable
json.dumps(summary_dict)
# Backwards compatibility check: head_ip is correctly processed
# when included as an argument to LoadMetricsSummary.
summary_dict["head_ip"] = "1.1.1.1"
# No compatibility issue.
LoadMetricsSummary(**summary_dict)
class AutoscalingTest(unittest.TestCase):
def setUp(self):