Skip to content

Commit

Permalink
feat: add generic-worker metadata to pool configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
ahal committed Jan 6, 2025
1 parent adf7946 commit 3fb2555
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 20 deletions.
2 changes: 2 additions & 0 deletions environments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ firefoxci:
- westus
- westus2
- westeurope
sbom_url_tmpl: https://github.com/mozilla-platform-ops/worker-images/blob/main/sboms/{name}-{version}.md
google_config:
wst_server_url: https://firefoxci-websocktunnel.services.mozilla.com/
zones:
Expand Down Expand Up @@ -255,6 +256,7 @@ staging:
- southcentralus
- westus
- westus2
sbom_url_tmpl: https://github.com/mozilla-platform-ops/worker-images/blob/main/sboms/{name}-{version}.md
google_config:
wst_server_url: https://websocktunnel-stage.taskcluster.nonprod.cloudops.mozgcp.net/
zones:
Expand Down
4 changes: 3 additions & 1 deletion src/ciadmin/generate/ciconfig/worker_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def mk(image_name, info):
[mk(image_name, info) for image_name, info in worker_images.items()]
)

def get(self, cloud: str, key: str | None=None, default: Any|None=None) -> Any:
def get(
self, cloud: str, key: str | None = None, default: Any | None = None
) -> Any:
"""
Look up a key under the given cloud config for this worker image.
Expand Down
23 changes: 20 additions & 3 deletions src/ciadmin/generate/worker_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,27 @@ def get_azure_provider_config(
{"implementation": implementation},
)
worker_config = merge(worker_config, config.get("worker-config", {}))
gw_config = worker_config["genericWorker"]["config"]
if azure_config.get("wst_server_url"):
worker_config["genericWorker"]["config"].setdefault(
"wstServerURL", azure_config["wst_server_url"]
)
gw_config.setdefault("wstServerURL", azure_config["wst_server_url"])

# Populate some generic-worker metadata.
metadata = {}
has_sbom = image.get(provider_id, "sbom") in (None, True) # defaults None to True
if has_sbom and "sbom_url_tmpl" in azure_config:
context = image.clouds[provider_id].copy()

# The SBOM urls use dashes in the name, whereas the names defined in
# worker-images.yml can use underscores. This can be removed if these
# two places ever use the same format.
if "name" in context:
context["name"] = context["name"].replace("_", "-")

metadata["sbom"] = azure_config["sbom_url_tmpl"].format(**context)

if metadata:
gw_config.setdefault("workerTypeMetaData", {}).update(metadata)

tags = config.get("tags", {})

launch_configs = []
Expand Down
2 changes: 1 addition & 1 deletion src/ciadmin/util/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def merge(*objects):
return merge_to(objects[-1], merge(*objects[:-1]))


def deep_get(dict_: dict[str, Any], field: str, default: Any|None=None) -> Any:
def deep_get(dict_: dict[str, Any], field: str, default: Any | None = None) -> Any:
"""
Return a key from nested dictionaries using dot path notation
(e.g "key.subkey").
Expand Down
5 changes: 3 additions & 2 deletions tests/ciadmin/test_generate_worker_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def inner(provider, extra_config=None):
"locations": ["us-east1"],
"image_resource_group": "rg",
"vmSizes": [{"vmSize": "Standard_F8s_v2"}],
"worker-config": {"genericWorker": {"config": {}}},
"worker-purpose": "test",
}
)
Expand Down Expand Up @@ -186,7 +187,7 @@ def assert_azure_basic(pool):
},
"subnetId": "/subscriptions/subscription_id/resourceGroups/rg-us-east1-test/providers/Microsoft.Network/virtualNetworks/vn-us-east1-test/subnets/sn-us-east1-test", # noqa: E501
"tags": {"deploymentId": "d_id"},
"workerConfig": {},
"workerConfig": {"genericWorker": {"config": {}}},
}


Expand All @@ -208,7 +209,7 @@ def assert_azure_version(pool):
},
"subnetId": "/subscriptions/subscription_id/resourceGroups/rg-us-east1-test/providers/Microsoft.Network/virtualNetworks/vn-us-east1-test/subnets/sn-us-east1-test", # noqa: E501
"tags": {"deploymentId": "d_id"},
"workerConfig": {},
"workerConfig": {"genericWorker": {"config": {}}},
}


Expand Down
22 changes: 9 additions & 13 deletions worker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ ubuntu-2404-headless:
ronin-b1-windows2012-vs-py2-alpha:
azure2:
version: NA
sbom: false
resource_group: rg-packer-through-cib
deployment_id: alpha
central-us: win2012r2-64-vs-py2-l1-centralus-2012-R2-Datacenter
north-central-us: win2012r2-64-vs-py2-l1-northcentralus-2012-R2-Datacenter
ronin-b1-windows2012-vs-py2-prod:
azure2:
version: NA
sbom: false
resource_group: rg-packer-through-cib
deployment_id: 7aa76c6
central-us: win2012r2-64-vs-py2-l1-centralus-2012-R2-Datacenter
Expand All @@ -122,6 +124,7 @@ ronin-b1-windows2012-vs-py2-prod:
ronin-b3-windows2012-vs-py2-prod:
azure_trusted:
version: NA
sbom: false
resource_group: rg-packer-through-cib
deployment_id: 7aa76c6
central-us: trusted-win2012r2-64-vs-py2-l3-centralus-2012-R2-Datacenter
Expand All @@ -134,6 +137,7 @@ ronin-b3-windows2012-vs-py2-prod:
ronin-b1-windows2012-prod:
azure2:
version: NA
sbom: false
resource_group: rg-packer-through-cib
deployment_id: 75bd9ed
central-us: win2012r2-64-l1-centralus-2012-R2-Datacenter
Expand All @@ -146,6 +150,7 @@ ronin-b1-windows2012-prod:
ronin-b3-windows2012-prod:
azure_trusted:
version: NA
sbom: false
resource_group: rg-packer-through-cib
deployment_id: 7cde253
central-us: trusted-win2012r2-64-l3-centralus-2012-R2-Datacenter
Expand All @@ -162,19 +167,18 @@ ronin_b1_windows2022_64_2009_alpha:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: alpha
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win2022-64-2009-alpha.md
name: win2022_64_2009_alpha
ronin_b1_windows2022_64_2009:
azure2:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: "8346140"
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win2022-64-2009.md
name: win2022_64_2009
ronin-b3-windows2022-prod:
azure_trusted:
deployment_id: "8346140"
version: NA
sbom: false
resource_group: rg-packer-through-cib
central-us: trusted-win2022-64-2009-centralus-2022-datacenter-azure-edition
east-us: trusted-win2022-64-2009-eastus-2022-datacenter-azure-edition
Expand All @@ -190,76 +194,68 @@ ronin_t_windows10_64_2009_prod:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: "8346140"
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win10-64-2009.md
name: win10_64_2009
ronin_t_windows10_64_2009_alpha:
azure2:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: alpha
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win10-64-2009-alpha.md
name: win10_64_2009_alpha
# Windows 11
ronin_b1_windows11_a64_24h2_builder_alpha:
azure2:
version: 0.0.1
resource_group: rg-packer-worker-images
deployment_id: alpha
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win11-a64-24h2-builder-alpha.md
name: win11_a64_24h2_builder_alpha
ronin_b1_windows11_a64_24h2_builder:
azure2:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: a03478d
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win11-a64-24h2-builder.md
name: win11_a64_24h2_builder
sbom: false
ronin_b3_windows11_a64_24h2_builder:
azure_trusted:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: a03478d
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win11-a64-24h2-builder.md
name: win11_a64_24h2_builder
sbom: false
ronin_t_windows11_a64_24h2_tester_alpha:
azure2:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: alpha
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win11-a64-24h2-tester-alpha.md
name: win11_a64_24h2_tester_alpha
ronin_t_windows11_a64_24h2_tester:
azure2:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: a03478d
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win11-a64-24h2-tester.md
name: win11_a64_24h2_tester
sbom: false
ronin_t_windows11_64_24h2:
azure2:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: "8346140"
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win11-64-24h2.md
name: win11_64_24h2
ronin_t_windows11_64_24h2_alpha:
azure2:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: alpha
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win11-64-24h2-alpha.md
name: win11_64_24h2_alpha
ronin_t_windows11_64_2009_alpha:
azure2:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: alpha
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win11-64-2009-alpha.md
name: win11_64_2009_alpha
ronin_t_windows11_64_2009:
azure2:
version: 1.0.0
resource_group: rg-packer-worker-images
deployment_id: "8346140"
SBOM: https://github.com/mozilla-platform-ops/worker-images/blob/main/config/win11-64-2009.md
name: win11_64_2009

0 comments on commit 3fb2555

Please sign in to comment.