Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LoginNodes] Update API to support multiple login node pools #6395

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/client/src/docs/ClusterInstance.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Name | Type | Description | Notes
**node_type** | [**NodeType**](NodeType.md) | |
**public_ip_address** | **str** | | [optional]
**queue_name** | **str** | | [optional]
**pool_name** | **str** | | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
2 changes: 1 addition & 1 deletion api/client/src/docs/DescribeClusterResponseContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Name | Type | Description | Notes
**tags** | [**[Tag]**](Tag.md) | Tags associated with the cluster. |
**scheduler** | [**Scheduler**](Scheduler.md) | | [optional]
**head_node** | [**EC2Instance**](EC2Instance.md) | | [optional]
**login_nodes** | [**LoginNodesPool**](LoginNodesPool.md) | | [optional]
**login_nodes** | [**[LoginNodesPool]**](LoginNodesPool.md) | | [optional]
**failures** | [**[Failure]**](Failure.md) | Failures array containing failures reason and code when the stack is in CREATE_FAILED status. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

Expand Down
1 change: 1 addition & 0 deletions api/client/src/docs/LoginNodesPool.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**status** | [**LoginNodesState**](LoginNodesState.md) | |
**pool_name** | **str** | | [optional]
**address** | **str** | | [optional]
**scheme** | **str** | | [optional]
**healthy_nodes** | **int** | | [optional]
Expand Down
4 changes: 4 additions & 0 deletions api/client/src/pcluster_client/model/cluster_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def openapi_types():
'node_type': (NodeType,), # noqa: E501
'public_ip_address': (str,), # noqa: E501
'queue_name': (str,), # noqa: E501
'pool_name': (str,), # noqa: E501
}

@cached_property
Expand All @@ -113,6 +114,7 @@ def discriminator():
'node_type': 'nodeType', # noqa: E501
'public_ip_address': 'publicIpAddress', # noqa: E501
'queue_name': 'queueName', # noqa: E501
'pool_name': 'poolName', # noqa: E501
}

read_only_vars = {
Expand Down Expand Up @@ -166,6 +168,7 @@ def _from_openapi_data(cls, instance_id, instance_type, launch_time, private_ip_
_visited_composed_classes = (Animal,)
public_ip_address (str): [optional] # noqa: E501
queue_name (str): [optional] # noqa: E501
pool_name (str): [optional] # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down Expand Up @@ -267,6 +270,7 @@ def __init__(self, instance_id, instance_type, launch_time, private_ip_address,
_visited_composed_classes = (Animal,)
public_ip_address (str): [optional] # noqa: E501
queue_name (str): [optional] # noqa: E501
pool_name (str): [optional] # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def openapi_types():
'tags': ([Tag],), # noqa: E501
'scheduler': (Scheduler,), # noqa: E501
'head_node': (EC2Instance,), # noqa: E501
'login_nodes': (LoginNodesPool,), # noqa: E501
'login_nodes': ([LoginNodesPool],), # noqa: E501
'failures': ([Failure],), # noqa: E501
}

Expand Down Expand Up @@ -204,7 +204,7 @@ def _from_openapi_data(cls, cluster_name, region, version, cloud_formation_stack
_visited_composed_classes = (Animal,)
scheduler (Scheduler): [optional] # noqa: E501
head_node (EC2Instance): [optional] # noqa: E501
login_nodes (LoginNodesPool): [optional] # noqa: E501
login_nodes ([LoginNodesPool]): [optional] # noqa: E501
failures ([Failure]): Failures array containing failures reason and code when the stack is in CREATE_FAILED status.. [optional] # noqa: E501
"""

Expand Down Expand Up @@ -317,7 +317,7 @@ def __init__(self, cluster_name, region, version, cloud_formation_stack_status,
_visited_composed_classes = (Animal,)
scheduler (Scheduler): [optional] # noqa: E501
head_node (EC2Instance): [optional] # noqa: E501
login_nodes (LoginNodesPool): [optional] # noqa: E501
login_nodes ([LoginNodesPool]): [optional] # noqa: E501
failures ([Failure]): Failures array containing failures reason and code when the stack is in CREATE_FAILED status.. [optional] # noqa: E501
"""

Expand Down
4 changes: 4 additions & 0 deletions api/client/src/pcluster_client/model/login_nodes_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def openapi_types():
lazy_import()
return {
'status': (LoginNodesState,), # noqa: E501
'pool_name': (str,), # noqa: E501
'address': (str,), # noqa: E501
'scheme': (str,), # noqa: E501
'healthy_nodes': (int,), # noqa: E501
Expand All @@ -101,6 +102,7 @@ def discriminator():

attribute_map = {
'status': 'status', # noqa: E501
'pool_name': 'poolName', # noqa: E501
'address': 'address', # noqa: E501
'scheme': 'scheme', # noqa: E501
'healthy_nodes': 'healthyNodes', # noqa: E501
Expand Down Expand Up @@ -151,6 +153,7 @@ def _from_openapi_data(cls, status, *args, **kwargs): # noqa: E501
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
pool_name (str): [optional] # noqa: E501
address (str): [optional] # noqa: E501
scheme (str): [optional] # noqa: E501
healthy_nodes (int): [optional] # noqa: E501
Expand Down Expand Up @@ -244,6 +247,7 @@ def __init__(self, status, *args, **kwargs): # noqa: E501
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
pool_name (str): [optional] # noqa: E501
address (str): [optional] # noqa: E501
scheme (str): [optional] # noqa: E501
healthy_nodes (int): [optional] # noqa: E501
Expand Down
8 changes: 7 additions & 1 deletion api/spec/openapi/ParallelCluster.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,8 @@ components:
$ref: '#/components/schemas/NodeType'
queueName:
type: string
poolName:
type: string
required:
- instanceId
- instanceType
Expand Down Expand Up @@ -1914,7 +1916,9 @@ components:
headNode:
$ref: '#/components/schemas/EC2Instance'
loginNodes:
$ref: '#/components/schemas/LoginNodesPool'
type: array
items:
$ref: '#/components/schemas/LoginNodesPool'
failures:
type: array
items:
Expand Down Expand Up @@ -2323,6 +2327,8 @@ components:
properties:
status:
$ref: '#/components/schemas/LoginNodesState'
poolName:
type: string
address:
type: string
scheme:
Expand Down
2 changes: 1 addition & 1 deletion api/spec/smithy/model/operations/DescribeCluster.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ structure DescribeClusterResponse {
@documentation("Tags associated with the cluster.")
tags: Tags,
headNode: EC2Instance,
loginNodes: LoginNodesPool,
loginNodes: LoginNodes,
@documentation("Failures array containing failures reason and code when the stack is in CREATE_FAILED status.")
failures: Failures
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ structure ClusterInstance {
state: InstanceState,
@required
nodeType: NodeType,
queueName: String
queueName: String,
poolName: String
}

list InstanceSummaries {
Expand Down
5 changes: 5 additions & 0 deletions api/spec/smithy/model/types/LoginNodesPool.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ namespace parallelcluster
])
string LoginNodesState

list LoginNodes {
member: LoginNodesPool
}

structure LoginNodesPool {
@required
status: LoginNodesState,
poolName: String
address: String,
scheme: String,
healthyNodes: Integer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def describe_cluster_instances(cluster_name, region=None, next_token=None, node_
private_ip_address=instance.private_ip,
node_type=node_type,
queue_name=instance.queue_name,
pool_name=instance.pool_name,
)
)
return DescribeClusterInstancesResponseContent(instances=ec2_instances, next_token=next_token)
Original file line number Diff line number Diff line change
Expand Up @@ -266,26 +266,23 @@ def describe_cluster(cluster_name, region=None):
def _get_login_nodes(cluster):
login_nodes_status = cluster.login_nodes_status

# TODO Fix once the API models are updated to support multiple pools in describe-cluster response
if login_nodes_status.get_login_nodes_pool_available():
login_nodes = []

for _pool_name, pool_status in login_nodes_status.get_pool_status_dict().items():
for pool_name, pool_status in login_nodes_status.get_pool_status_dict().items():
status = LoginNodesState.FAILED
if pool_status.get_status() == LoginNodesPoolState.ACTIVE:
status = LoginNodesState.ACTIVE
elif pool_status.get_status() == LoginNodesPoolState.PENDING:
status = LoginNodesState.PENDING
pool = LoginNodesPool(status=status)
# pool.name = pool_name
pool.pool_name = pool_name
pool.address = pool_status.get_address()
pool.scheme = pool_status.get_scheme()
pool.healthy_nodes = pool_status.get_healthy_nodes()
pool.unhealthy_nodes = pool_status.get_unhealthy_nodes()
login_nodes.append(pool)
break

return login_nodes[0]
return login_nodes
return None


Expand Down
27 changes: 27 additions & 0 deletions cli/src/pcluster/api/models/cluster_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
launch_time=None,
instance_id=None,
queue_name=None,
pool_name=None,
public_ip_address=None,
instance_type=None,
state=None,
Expand All @@ -42,6 +43,8 @@ def __init__(
:type instance_id: str
:param queue_name: The queue_name of this ClusterInstance. # noqa: E501
:type queue_name: str
:param pool_name: The pool_name of this ClusterInstance. # noqa: E501
:type pool_name: str
:param public_ip_address: The public_ip_address of this ClusterInstance. # noqa: E501
:type public_ip_address: str
:param instance_type: The instance_type of this ClusterInstance. # noqa: E501
Expand All @@ -57,6 +60,7 @@ def __init__(
"launch_time": datetime,
"instance_id": str,
"queue_name": str,
"pool_name": str,
"public_ip_address": str,
"instance_type": str,
"state": InstanceState,
Expand All @@ -68,6 +72,7 @@ def __init__(
"launch_time": "launchTime",
"instance_id": "instanceId",
"queue_name": "queueName",
"pool_name": "poolName",
"public_ip_address": "publicIpAddress",
"instance_type": "instanceType",
"state": "state",
Expand All @@ -78,6 +83,7 @@ def __init__(
self._launch_time = launch_time
self._instance_id = instance_id
self._queue_name = queue_name
self._pool_name = pool_name
self._public_ip_address = public_ip_address
self._instance_type = instance_type
self._state = state
Expand Down Expand Up @@ -274,3 +280,24 @@ def private_ip_address(self, private_ip_address):
raise ValueError("Invalid value for `private_ip_address`, must not be `None`") # noqa: E501

self._private_ip_address = private_ip_address

@property
def pool_name(self):
"""Gets the pool_name of this ClusterInstance.


:return: The pool_name of this ClusterInstance.
:rtype: str
"""
return self._pool_name

@pool_name.setter
def pool_name(self, pool_name):
"""Sets the pool_name of this ClusterInstance.


:param pool_name: The pool_name of this ClusterInstance.
:type pool_name: str
"""

self._pool_name = pool_name
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
:param scheduler: The scheduler of this DescribeClusterResponseContent. # noqa: E501
:type scheduler: Scheduler
:param login_nodes: The login_nodes of this DescribeClusterResponseContent. # noqa: E501
:type login_nodes: LoginNodesPool
:type login_nodes: List[LoginNodesPool]
:param failures: The failures of this DescribeClusterResponseContent. # noqa: E501
:type failures: List[Failure]
"""
Expand All @@ -97,7 +97,7 @@ def __init__(
"region": str,
"cluster_status": ClusterStatus,
"scheduler": Scheduler,
"login_nodes": LoginNodesPool,
"login_nodes": List[LoginNodesPool],
"failures": List[Failure],
}

Expand Down Expand Up @@ -469,7 +469,7 @@ def login_nodes(self):


:return: The login_nodes of this DescribeClusterResponseContent.
:rtype: LoginNodesPool
:rtype: List[LoginNodesPool]
"""
return self._login_nodes

Expand All @@ -479,7 +479,7 @@ def login_nodes(self, login_nodes):


:param login_nodes: The login_nodes of this DescribeClusterResponseContent.
:type login_nodes: LoginNodesPool
:type login_nodes: List[LoginNodesPool]
"""

self._login_nodes = login_nodes
Expand Down
30 changes: 29 additions & 1 deletion cli/src/pcluster/api/models/login_nodes_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ class LoginNodesPool(Model):
Do not edit the class manually.
"""

def __init__(self, status=None, address=None, scheme=None, healthy_nodes=None, unhealthy_nodes=None): # noqa: E501
def __init__(
self, status=None, pool_name=None, address=None, scheme=None, healthy_nodes=None, unhealthy_nodes=None
): # noqa: E501
"""LoginNodesPool - a model defined in OpenAPI

:param status: The status of this LoginNodesPool. # noqa: E501
:type status: LoginNodesState
:param pool_name: The pool_name of this LoginNodesPool. # noqa: E501
:type pool_name: str
:param address: The address of this LoginNodesPool. # noqa: E501
:type address: str
:param scheme: The scheme of this LoginNodesPool. # noqa: E501
Expand All @@ -38,6 +42,7 @@ def __init__(self, status=None, address=None, scheme=None, healthy_nodes=None, u
"""
self.openapi_types = {
"status": LoginNodesState,
"pool_name": str,
"address": str,
"scheme": str,
"healthy_nodes": int,
Expand All @@ -46,13 +51,15 @@ def __init__(self, status=None, address=None, scheme=None, healthy_nodes=None, u

self.attribute_map = {
"status": "status",
"pool_name": "poolName",
"address": "address",
"scheme": "scheme",
"healthy_nodes": "healthyNodes",
"unhealthy_nodes": "unhealthyNodes",
}

self._status = status
self._pool_name = pool_name
self._address = address
self._scheme = scheme
self._healthy_nodes = healthy_nodes
Expand Down Expand Up @@ -92,6 +99,27 @@ def status(self, status):

self._status = status

@property
def pool_name(self):
"""Gets the pool_name of this LoginNodesPool.


:return: The pool_name of this LoginNodesPool.
:rtype: str
"""
return self._pool_name

@pool_name.setter
def pool_name(self, pool_name):
"""Sets the pool_name of this LoginNodesPool.


:param pool_name: The pool_name of this LoginNodesPool.
:type pool_name: str
"""

self._pool_name = pool_name

@property
def address(self):
"""Gets the address of this LoginNodesPool.
Expand Down
Loading
Loading