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

Fix Lambda python version for previous versions of ParallelCluster. #281

Merged
merged 1 commit into from
Nov 4, 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
24 changes: 12 additions & 12 deletions source/cdk/cdk_slurm_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import boto3
from botocore.exceptions import ClientError
import config_schema
from config_schema import get_PARALLEL_CLUSTER_MUNGE_VERSION, get_PARALLEL_CLUSTER_PYTHON_VERSION, get_PC_SLURM_VERSION, get_SLURM_VERSION
from config_schema import get_PARALLEL_CLUSTER_LAMBDA_RUNTIME, get_PARALLEL_CLUSTER_MUNGE_VERSION, get_PARALLEL_CLUSTER_PYTHON_VERSION, get_PC_SLURM_VERSION, get_SLURM_VERSION
from constructs import Construct
from copy import copy, deepcopy
from hashlib import sha512
Expand Down Expand Up @@ -1427,7 +1427,7 @@ def create_parallel_cluster_lambdas(self):
aws_lambda.Architecture.X86_64,
],
compatible_runtimes = [
aws_lambda.Runtime.PYTHON_3_12,
get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version']))
],
)

Expand All @@ -1437,7 +1437,7 @@ def create_parallel_cluster_lambdas(self):
function_name=f"{self.stack_name}-CreateBuildFiles",
description="Create ParallelCluster build configuration files",
memory_size=2048,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.X86_64,
timeout=Duration.minutes(2),
log_retention=logs.RetentionDays.INFINITE,
Expand Down Expand Up @@ -1499,7 +1499,7 @@ def create_parallel_cluster_lambdas(self):
function_name=f"{self.stack_name}-CreateParallelClusterConfig",
description="Create ParallelCluster config",
memory_size=2048,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.X86_64,
timeout=Duration.minutes(15),
log_retention=logs.RetentionDays.INFINITE,
Expand Down Expand Up @@ -1547,7 +1547,7 @@ def create_parallel_cluster_lambdas(self):
function_name=f"{self.stack_name}-CreateParallelCluster",
description="Create ParallelCluster",
memory_size=2048,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.X86_64,
timeout=Duration.minutes(15),
log_retention=logs.RetentionDays.INFINITE,
Expand Down Expand Up @@ -1846,7 +1846,7 @@ def create_parallel_cluster_lambdas(self):
function_name=f"{self.stack_name}-CreateHeadNodeARecord",
description="Create head node A record",
memory_size=2048,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.X86_64,
timeout=Duration.minutes(15),
log_retention=logs.RetentionDays.INFINITE,
Expand Down Expand Up @@ -1893,7 +1893,7 @@ def create_parallel_cluster_lambdas(self):
function_name=f"{self.stack_name}-UpdateHeadNode",
description="Update head node",
memory_size=2048,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.X86_64,
timeout=Duration.minutes(15),
log_retention=logs.RetentionDays.INFINITE,
Expand Down Expand Up @@ -1935,7 +1935,7 @@ def create_parallel_cluster_lambdas(self):
function_name=f"{self.stack_name}-ConfigUsersGroupsJson",
description="Configure users and groups json file",
memory_size=2048,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.X86_64,
timeout=Duration.minutes(15),
log_retention=logs.RetentionDays.INFINITE,
Expand Down Expand Up @@ -1983,7 +1983,7 @@ def create_parallel_cluster_lambdas(self):
function_name=f"{self.stack_name}-ConfigExternalLoginNodes",
description="Configure external login nodes",
memory_size=2048,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.X86_64,
timeout=Duration.minutes(15),
log_retention=logs.RetentionDays.INFINITE,
Expand Down Expand Up @@ -2030,7 +2030,7 @@ def create_parallel_cluster_lambdas(self):
function_name=f"{self.stack_name}-DeconfigUsersGroupsJson",
description="Deconfigure RES users and groups json file",
memory_size=2048,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.X86_64,
timeout=Duration.minutes(15),
log_retention=logs.RetentionDays.INFINITE,
Expand Down Expand Up @@ -2072,7 +2072,7 @@ def create_parallel_cluster_lambdas(self):
function_name=f"{self.stack_name}-DeconfigExternalLoginNodes",
description="Deconfigure external login nodes",
memory_size=2048,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.X86_64,
timeout=Duration.minutes(15),
log_retention=logs.RetentionDays.INFINITE,
Expand Down Expand Up @@ -2114,7 +2114,7 @@ def create_callSlurmRestApiLambda(self):
function_name=f"{self.stack_name}-CallSlurmRestApiLambda",
description="Example showing how to call Slurm REST API",
memory_size=128,
runtime=aws_lambda.Runtime.PYTHON_3_12,
runtime=get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parse_version(self.config['slurm']['ParallelClusterConfig']['Version'])),
architecture=aws_lambda.Architecture.ARM_64,
timeout=Duration.minutes(1),
log_retention=logs.RetentionDays.INFINITE,
Expand Down
11 changes: 11 additions & 0 deletions source/cdk/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

from aws_cdk import (
aws_lambda as aws_lambda
)
import boto3
from botocore.client import ClientError
import json
Expand Down Expand Up @@ -318,6 +321,14 @@ def PARALLEL_CLUSTER_SUPPORTS_CUSTOM_MUNGE_KEY(parallel_cluster_version):
def PARALLEL_CLUSTER_SUPPORTS_HOME_MOUNT(parallel_cluster_version):
return parallel_cluster_version >= PARALLEL_CLUSTER_SUPPORTS_HOME_MOUNT_VERSION

# Version 3.11.0

def get_PARALLEL_CLUSTER_LAMBDA_RUNTIME(parallel_cluster_version):
if parallel_cluster_version < parse_version('3.11.1'):
return aws_lambda.Runtime.PYTHON_3_9
else:
return aws_lambda.Runtime.PYTHON_3_12

# Determine all AWS regions available on the account.
default_region = environ.get("AWS_DEFAULT_REGION", "us-east-1")
ec2_client = boto3.client("ec2", region_name=default_region)
Expand Down