Skip to content

Commit f4fd4dd

Browse files
committed
refactor(aws): migrate AWS handlers + field mappings to machine_type/machine_role
Companion call-site updates for the Template.instance_type -> machine_type and instance_profile -> machine_role renames: AWS context mixin, HostFactory field mappings, and the instance-operation service now read the new field names (Jinja/HF wire keys that operators see are unchanged). Tests updated.
1 parent 6b1d478 commit f4fd4dd

7 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/orb/infrastructure/scheduler/hostfactory/field_mappings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class HostFactoryFieldMappings:
6363
"spotFleetRequestExpiry": "spot_fleet_request_expiry",
6464
"poolsCount": "pools_count",
6565
# AWS instance configuration
66-
"instanceProfile": "instance_profile",
66+
"instanceProfile": "machine_role",
6767
"launchTemplateId": "launch_template_id",
6868
"userDataScript": "user_data",
6969
},

src/orb/providers/aws/infrastructure/handlers/shared/base_context_mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def _prepare_standard_flags(self, template: AWSTemplate) -> dict[str, Any]:
105105
# Optional configuration flags
106106
"has_key_name": hasattr(template, "key_name") and bool(template.key_name),
107107
"has_user_data": hasattr(template, "user_data") and bool(template.user_data),
108-
"has_instance_profile": hasattr(template, "instance_profile")
109-
and bool(template.instance_profile),
108+
"has_instance_profile": hasattr(template, "machine_role")
109+
and bool(template.machine_role),
110110
"has_ebs_optimized": hasattr(template, "ebs_optimized")
111111
and template.ebs_optimized is not None, # type: ignore[attr-defined]
112112
"has_monitoring": hasattr(template, "monitoring_enabled")

src/orb/providers/aws/scheduler/hostfactory_field_mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AWSFieldMapping:
2929
"spotFleetRequestExpiry": "spot_fleet_request_expiry",
3030
"poolsCount": "pools_count",
3131
# AWS instance configuration
32-
"instanceProfile": "instance_profile",
32+
"instanceProfile": "machine_role",
3333
"launchTemplateId": "launch_template_id",
3434
"userDataScript": "user_data",
3535
}

src/orb/providers/aws/services/instance_operation_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async def create_instances(
6868
"iops",
6969
"fleet_role",
7070
"fleet_type",
71-
"instance_profile",
71+
"machine_role",
7272
"key_name",
7373
"user_data",
7474
]:

tests/providers/aws/mocked/test_run_instances_gaps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def _create_or_update(template: AWSTemplate, request: Any) -> LaunchTemplateResu
8989
lt_data["UserData"] = base64.b64encode(template.user_data.encode()).decode()
9090
if template.key_name:
9191
lt_data["KeyName"] = template.key_name
92-
if template.instance_profile:
93-
lt_data["IamInstanceProfile"] = {"Arn": template.instance_profile}
92+
if template.machine_role:
93+
lt_data["IamInstanceProfile"] = {"Arn": template.machine_role}
9494
try:
9595
resp = aws_client.ec2_client.create_launch_template(
9696
LaunchTemplateName=lt_name,
@@ -287,7 +287,7 @@ def test_acquire_with_iam_instance_profile(
287287
verify it is present in the launch template version data instead.
288288
"""
289289
profile_arn = "arn:aws:iam::123456789012:instance-profile/test-profile"
290-
template = _run_instances_template(subnet_id, sg_id, instance_profile=profile_arn)
290+
template = _run_instances_template(subnet_id, sg_id, machine_role=profile_arn)
291291
request = _make_request(request_id="req-iam-001")
292292

293293
result = handler.acquire_hosts(request, template)

tests/providers/aws/unit/test_base_context_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_prepare_standard_flags(self):
194194
self.template.machine_types = {"t3.medium": 1, "t3.large": 2}
195195
self.template.key_name = "my-key"
196196
self.template.user_data = "#!/bin/bash"
197-
self.template.instance_profile = "my-profile"
197+
self.template.machine_role = "my-profile"
198198
self.template.ebs_optimized = True
199199
self.template.monitoring_enabled = False
200200

tests/providers/aws/unit/test_launch_template_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_create_launch_template_data_user_data(self):
193193

194194
def test_create_launch_template_data_iam_instance_profile(self):
195195
"""Test launch template data creation with IAM instance profile."""
196-
self.aws_template.instance_profile = "test-instance-profile"
196+
self.aws_template.machine_role = "test-instance-profile"
197197

198198
data = self.manager._create_launch_template_data_legacy(self.aws_template, self.request)
199199

0 commit comments

Comments
 (0)