Bug 1634387: Support additional-user-data per instance type r=tomprince
authorWander Lairson Costa <wander.lairson@gmail.com>
Tue, 05 May 2020 15:43:43 +0000
changeset 221 815a494bbe2794789999e1c7d78131ecd620883f
parent 220 9c9a898b351909b2e0fe8420ac9d649ded523af3
child 222 db3700c72c62877f4bab2de4008fb8cb60de3f60
push id159
push usermozilla@hocat.ca
push dateTue, 05 May 2020 16:14:41 +0000
treeherderci-admin@815a494bbe27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince
bugs1634387
Bug 1634387: Support additional-user-data per instance type r=tomprince This patch allows the configuration of custom user data per instance type. Differential Revision: https://phabricator.services.mozilla.com/D73276
src/ciadmin/generate/worker_pools.py
--- a/src/ciadmin/generate/worker_pools.py
+++ b/src/ciadmin/generate/worker_pools.py
@@ -27,17 +27,17 @@ def is_invalid_aws_instance_type(invalid
 def get_aws_provider_config(
     environment, provider_id, worker_pool_id, config, worker_images, defaults
 ):
     regions = config.pop("regions")
     image = worker_images[config["image"]]
     instance_types = config["instance_types"]
     security = config.pop("security", "untrusted")
     spot = config.pop("spot", True)
-    user_data = config.pop("additional-user-data", None)
+    user_data = config.pop("additional-user-data", {})
     implementation = config.pop("implementation", "docker-worker")
 
     defaults = evaluate_keyed_by(defaults, "defaults", {"provider": provider_id})
     aws_config = environment.aws_config
 
     worker_config = evaluate_keyed_by(
         defaults.get("worker-config", {}),
         worker_pool_id,
@@ -78,18 +78,21 @@ def get_aws_provider_config(
                         "SubnetId": subnet_id,
                         "SecurityGroupIds": security_groups,
                         "InstanceType": instance_type["instanceType"],
                     },
                     "workerConfig": merge(
                         worker_config, instance_type.get("worker-config", {})
                     ),
                 }
-                if user_data is not None:
-                    launch_config["additionalUserData"] = user_data
+                launch_config["additionalUserData"] = {}
+                launch_config["additionalUserData"].update(user_data)
+                launch_config["additionalUserData"].update(
+                    instance_type.get("additional-user-data", {})
+                )
                 launch_config["launchConfig"] = merge(
                     launch_config["launchConfig"], instance_type.get("launchConfig", {})
                 )
                 if spot:
                     launch_config["launchConfig"]["InstanceMarketOptions"] = {
                         "MarketType": "spot"
                     }
                 launch_configs.append(launch_config)