8
8
import tempfile
9
9
from typing import Annotated , Any , Dict , List , Literal , Optional , Tuple , Type , Union
10
10
11
- from pydantic import Field , PrivateAttr , field_validator , model_validator
11
+ from pydantic import Field , field_validator , model_validator
12
12
13
13
from _nebari import constants
14
14
from _nebari .provider import terraform
@@ -136,7 +136,7 @@ class AWSAmiTypes(str, enum.Enum):
136
136
137
137
class AWSNodeLaunchTemplate (schema .Base ):
138
138
pre_bootstrap_command : Optional [str ] = None
139
- _ami_id : Optional [str ] = PrivateAttr ( default = None )
139
+ ami_id : Optional [str ] = None
140
140
141
141
142
142
class AWSNodeGroupInputVars (schema .Base ):
@@ -152,10 +152,23 @@ class AWSNodeGroupInputVars(schema.Base):
152
152
launch_template : Optional [AWSNodeLaunchTemplate ] = None
153
153
154
154
155
- def construct_aws_ami_type (gpu_enabled : bool , launch_template : AWSNodeLaunchTemplate ):
156
- """Construct the AWS AMI type based on the provided parameters."""
155
+ def construct_aws_ami_type (
156
+ gpu_enabled : bool , launch_template : AWSNodeLaunchTemplate
157
+ ) -> str :
158
+ """
159
+ This function selects the Amazon Machine Image (AMI) type for AWS nodes by evaluating
160
+ the provided parameters. The selection logic prioritizes the launch template over the
161
+ GPU flag.
162
+
163
+ Returns the AMI type (str) determined by the following rules:
164
+ - Returns "CUSTOM" if a `launch_template` is provided and it includes a valid `ami_id`.
165
+ - Returns "AL2_x86_64_GPU" if `gpu_enabled` is True and no valid
166
+ `launch_template` is provided (None).
167
+ - Returns "AL2_x86_64" as the default AMI type if `gpu_enabled` is False and no
168
+ valid `launch_template` is provided (None).
169
+ """
157
170
158
- if launch_template and launch_template . _ami_id :
171
+ if launch_template and getattr ( launch_template , "ami_id" , None ) :
159
172
return "CUSTOM"
160
173
161
174
if gpu_enabled :
@@ -474,7 +487,16 @@ class AWSNodeGroup(schema.Base):
474
487
gpu : bool = False
475
488
single_subnet : bool = False
476
489
permissions_boundary : Optional [str ] = None
477
- launch_template : Optional [AWSNodeLaunchTemplate ] = None
490
+ # Disabled as part of 2024.11.1 until #2832 is resolved
491
+ # launch_template: Optional[AWSNodeLaunchTemplate] = None
492
+
493
+ @model_validator (mode = "before" )
494
+ def check_launch_template (cls , values ):
495
+ if "launch_template" in values :
496
+ raise ValueError (
497
+ "The 'launch_template' field is currently unavailable and has been removed from the configuration schema.\n Please omit this field until it is reintroduced in a future update." ,
498
+ )
499
+ return values
478
500
479
501
480
502
DEFAULT_AWS_NODE_GROUPS = {
@@ -855,10 +877,10 @@ def input_vars(self, stage_outputs: Dict[str, Dict[str, Any]]):
855
877
max_size = node_group .max_nodes ,
856
878
single_subnet = node_group .single_subnet ,
857
879
permissions_boundary = node_group .permissions_boundary ,
858
- launch_template = node_group . launch_template ,
880
+ launch_template = None ,
859
881
ami_type = construct_aws_ami_type (
860
882
gpu_enabled = node_group .gpu ,
861
- launch_template = node_group . launch_template ,
883
+ launch_template = None ,
862
884
),
863
885
)
864
886
for name , node_group in self .config .amazon_web_services .node_groups .items ()
0 commit comments