Python
feat: prepare private Azure registry and expiry-owned management access
Rohit P66e9506d141c
diff --git a/docs/harness/guides/azure.md b/docs/harness/guides/azure.mdindex e965ad28..ed68454d 100644--- a/docs/harness/guides/azure.md+++ b/docs/harness/guides/azure.md@@ -39,6 +39,20 @@ assume subscription Owner rights, and the normal executor is not granted permissto change role assignments. Keep customer-owned/shared resources outside the trial'scleanup scope.+For a private cleanup image, set `guardRegistryResourceId` to an existing ACR in+the control resource group and use its digest-pinned image in `guardImage`. The+cleanup package configures managed-identity pulls and exports an exact `AcrPull`+assignment for review. Registry passwords and workload-owned cleanup images are+not supported.++An optional `managementAccess` object accepts `operatorIpv4` and a pinned+`ubuntuImageVersion` for Canonical's `ubuntu-24_04-lts:server` image. With Dasv7+nodes, this adds one `Standard_D2as_v7` management VM, restricted to SSH from that+single IPv4 address. The VM, NIC, public IP and security group are tracked by the+same expiry cleanup as the workload; its generated OS disk uses delete-on-VM-delete.+The private AKS API remains private. Preflight includes the extra two vCPUs; a+verified SSH tunnel can keep the operator's Azure credentials on their machine.+This deployment path is experimental. Validate live Azure permissions, network,OpenShell compatibility and independent cleanup in your subscription before use.diff --git a/harness/service-cli/src/deployment_azure_infrastructure.rs b/harness/service-cli/src/deployment_azure_infrastructure.rsindex f6a7b5c8..02d61eb7 100644--- a/harness/service-cli/src/deployment_azure_infrastructure.rs+++ b/harness/service-cli/src/deployment_azure_infrastructure.rs@@ -20,10 +20,22 @@ pub(crate) struct Inputs {pub(crate) admin_group_object_ids: Vec<String>,pub(crate) control_resource_group: String,pub(crate) guard_image: String,+ /// Optional private ACR in the independent control group. Pulls use the+ /// cleanup identity, never a registry password or workload-owned registry.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub(crate) guard_registry_resource_id: Option<String>,+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub(crate) management_access: Option<ManagementAccess>,pub(crate) postgres_password: SecretReference,}#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]#[serde(rename_all = "camelCase", deny_unknown_fields)]+pub(crate) struct ManagementAccess {+ pub(crate) operator_ipv4: std::net::Ipv4Addr,+ pub(crate) ubuntu_image_version: String,+}+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]+#[serde(rename_all = "camelCase", deny_unknown_fields)]pub(crate) struct SecretReference {key_vault_id: String,secret_name: String,@@ -45,6 +57,7 @@ pub(crate) fn node_sku(size: &str) -> Option<(&'static str, u64)> {"Standard_D4s_v5" => Some(("standardDSv5Family", 4)),"Standard_D8s_v5" => Some(("standardDSv5Family", 8)),"Standard_D4as_v7" => Some(("StandardDasv7Family", 4)),+ "Standard_D2as_v7" => Some(("StandardDasv7Family", 2)),_ => None,}}@@ -71,7 +84,7 @@ impl Inputs {"Pin an exact Kubernetes 1.x.y version; regional availability requires live preflight");ensure!(- node_sku(&self.node_vm_size).is_some(),+ node_sku(&self.node_vm_size).is_some_and(|(_, cores)| cores >= 4),"Use an explicitly bounded AMD64 node SKU; OpenShell compatibility remains a live gate");let key: Vec<_> = self.ssh_public_key.split_whitespace().collect();@@ -147,6 +160,29 @@ impl Inputs {.contains(&format!("{}.azurecr.io", names(p).registry)),"Cleanup image must survive deletion of the workload registry");+ if let Some(registry_id) = &self.guard_registry_resource_id {+ let prefix = format!("/subscriptions/{subscription}/resourceGroups/{}/providers/Microsoft.ContainerRegistry/registries/", self.control_resource_group);+ let name = registry_id+ .strip_prefix(&prefix)+ .context("Cleanup registry must be in the exact independent control group")?;+ ensure!(+ (5..=50).contains(&name.len())+ && name+ .bytes()+ .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit())+ && self.guard_image.starts_with(&format!("{name}.azurecr.io/")),+ "Cleanup image and registry identity must match"+ );+ }+ if let Some(access) = &self.management_access {+ ensure!(self.node_vm_size == "Standard_D4as_v7"+ && !access.operator_ipv4.is_unspecified() && !access.operator_ipv4.is_loopback()+ && !access.operator_ipv4.is_multicast()+ && access.ubuntu_image_version.split('.').count() == 3+ && access.ubuntu_image_version.bytes().all(|b| b.is_ascii_digit() || b == b'.')+ && access.ubuntu_image_version.split('.').all(|s| !s.is_empty()),+ "Management access requires bounded Dasv7 nodes, one operator IPv4, and a pinned Ubuntu image version");+ }Ok(())}}@@ -232,7 +268,7 @@ fn assignment_resource(/// disappear with parents; the customer RG and AKS-generated node RG are not owned.pub(crate) fn inventory(p: &Plan) -> Vec<Value> {let n = names(p);- [+ let mut resources: Vec<Value> = [("cluster","Microsoft.ContainerService/managedClusters",format!("{}-aks",n.prefix),"2024-10-01","/systemData/createdAt"),("foundation","Microsoft.DBforPostgreSQL/flexibleServers",format!("{}-pg",n.prefix),"2024-08-01","/systemData/createdAt"),("foundation","Microsoft.Network/privateEndpoints",format!("{}-blob",n.prefix),"2024-05-01","/systemData/createdAt"),@@ -244,7 +280,42 @@ pub(crate) fn inventory(p: &Plan) -> Vec<Value> {("foundation","Microsoft.ManagedIdentity/userAssignedIdentities",format!("{}-artifacts",n.prefix),"2023-01-31","/properties/principalId"),("foundation","Microsoft.ManagedIdentity/userAssignedIdentities",format!("{}-kubelet",n.prefix),"2023-01-31","/properties/principalId"),("foundation","Microsoft.ManagedIdentity/userAssignedIdentities",format!("{}-cluster",n.prefix),"2023-01-31","/properties/principalId"),- ].into_iter().map(|(stage,kind,name,api,pointer)|json!({"stage":stage,"id":id(p,kind,&name),"apiVersion":api,"incarnationPointer":pointer})).collect()+ ].into_iter().map(|(stage,kind,name,api,pointer)|json!({"stage":stage,"id":id(p,kind,&name),"apiVersion":api,"incarnationPointer":pointer})).collect();+ if p.azure_infrastructure+ .as_ref()+ .unwrap()+ .management_access+ .is_some()+ {+ let access = [+ (+ "Microsoft.Compute/virtualMachines",+ "management",+ "2024-07-01",+ "/properties/vmId",+ ),+ (+ "Microsoft.Network/networkInterfaces",+ "management-nic",+ "2024-05-01",+ "/properties/resourceGuid",+ ),+ (+ "Microsoft.Network/publicIPAddresses",+ "management-ip",+ "2024-05-01",+ "/properties/resourceGuid",+ ),+ (+ "Microsoft.Network/networkSecurityGroups",+ "management-nsg",+ "2024-05-01",+ "/properties/resourceGuid",+ ),+ ];+ resources.splice(0..0, access.into_iter().map(|(kind, suffix, api, pointer)| json!({"stage":"foundation","id":id(p,kind,&format!("{}-{suffix}",n.prefix)),"apiVersion":api,"incarnationPointer":pointer})));+ }+ resources}pub(crate) fn artifacts(p: &Plan) -> Result<BTreeMap<String, Vec<u8>>> {let c = p@@ -357,6 +428,60 @@ pub(crate) fn artifacts(p: &Plan) -> Result<BTreeMap<String, Vec<u8>>> {pg["sku"] = json!({"name":"Standard_B1ms","tier":"Burstable"});pg["dependsOn"] = json!([vnet, pg_zone]);foundation.push(pg);+ if let Some(access) = &c.management_access {+ foundation[0]["properties"]["subnets"]+ .as_array_mut()+ .unwrap()+ .push(json!({"name":"management","properties":{"addressPrefix":"10.72.6.0/24"}}));+ let nic = id(+ p,+ "Microsoft.Network/networkInterfaces",+ &format!("{}-management-nic", n.prefix),+ );+ let pip = id(+ p,+ "Microsoft.Network/publicIPAddresses",+ &format!("{}-management-ip", n.prefix),+ );+ let nsg = id(+ p,+ "Microsoft.Network/networkSecurityGroups",+ &format!("{}-management-nsg", n.prefix),+ );+ let mut ip = resource(+ p,+ "Microsoft.Network/publicIPAddresses",+ "2024-05-01",+ &format!("{}-management-ip", n.prefix),+ json!({"publicIPAllocationMethod":"Static","publicIPAddressVersion":"IPv4"}),+ );+ ip["sku"] = json!({"name":"Standard"});+ foundation.push(ip);+ foundation.push(resource(p,"Microsoft.Network/networkSecurityGroups","2024-05-01",&format!("{}-management-nsg",n.prefix),json!({"securityRules":[{"name":"operator-ssh","properties":{"priority":100,"protocol":"Tcp","access":"Allow","direction":"Inbound","sourceAddressPrefix":format!("{}/32",access.operator_ipv4),"sourcePortRange":"*","destinationAddressPrefix":"*","destinationPortRange":"22"}}]})));+ let mut iface = resource(+ p,+ "Microsoft.Network/networkInterfaces",+ "2024-05-01",+ &format!("{}-management-nic", n.prefix),+ json!({"networkSecurityGroup":{"id":nsg},"ipConfigurations":[{"name":"primary","properties":{"privateIPAllocationMethod":"Dynamic","subnet":{"id":format!("{vnet}/subnets/management")},"publicIPAddress":{"id":pip}}}]}),+ );+ iface["dependsOn"] = json!([vnet, nsg, pip]);+ foundation.push(iface);+ let mut vm = resource(+ p,+ "Microsoft.Compute/virtualMachines",+ "2024-07-01",+ &format!("{}-management", n.prefix),+ json!({+ "hardwareProfile":{"vmSize":"Standard_D2as_v7"},+ "storageProfile":{"diskControllerType":"NVMe","imageReference":{"publisher":"Canonical","offer":"ubuntu-24_04-lts","sku":"server","version":access.ubuntu_image_version},"osDisk":{"createOption":"FromImage","diskSizeGB":32,"deleteOption":"Delete","managedDisk":{"storageAccountType":"StandardSSD_LRS"}}},+ "osProfile":{"computerName":"ow-management","adminUsername":"owsadmin","linuxConfiguration":{"disablePasswordAuthentication":true,"ssh":{"publicKeys":[{"path":"/home/owsadmin/.ssh/authorized_keys","keyData":c.ssh_public_key}]}}},+ "networkProfile":{"networkInterfaces":[{"id":nic,"properties":{"primary":true,"deleteOption":"Detach"}}]}+ }),+ );+ vm["dependsOn"] = json!([nic]);+ foundation.push(vm);+ }let mut ft = template(foundation, json!({}));ft["parameters"]["postgresPassword"] = json!({"type":"secureString"});let mut aks = resource(@@ -437,6 +562,7 @@ pub(crate) fn artifacts(p: &Plan) -> Result<BTreeMap<String, Vec<u8>>> {}}for action in [+ "Microsoft.Network/networkInterfaces/join/action","Microsoft.Network/virtualNetworks/subnets/read","Microsoft.Network/virtualNetworks/subnets/join/action","Microsoft.Network/privateDnsZones/virtualNetworkLinks/read",diff --git a/harness/service-cli/src/deployment_azure_lifecycle.rs b/harness/service-cli/src/deployment_azure_lifecycle.rsindex 0cffadb8..4b01a55a 100644--- a/harness/service-cli/src/deployment_azure_lifecycle.rs+++ b/harness/service-cli/src/deployment_azure_lifecycle.rs@@ -987,13 +987,18 @@ fn control_artifacts(s: &State) -> Result<BTreeMap<String, Vec<u8>>> {let cleanup_assignment = json!({"properties":{"principalId":recipient,"principalType":"ServicePrincipal","roleDefinitionId":role_id}});let blob_scope = format!("{account_id}/blobServices/default/containers/control");let builtin=format!("/subscriptions/{subscription}/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe");- let control_resources = vec![+ let mut control_resources = vec![json!({"type":"Microsoft.ManagedIdentity/userAssignedIdentities","apiVersion":"2023-01-31","name":identity_name,"location":location}),json!({"type":"Microsoft.Storage/storageAccounts","apiVersion":"2023-05-01","name":control_account,"location":location,"sku":{"name":"Standard_LRS"},"kind":"StorageV2","properties":{"allowSharedKeyAccess":false,"allowBlobPublicAccess":false,"minimumTlsVersion":"TLS1_2","supportsHttpsTrafficOnly":true,"publicNetworkAccess":"Enabled"}}),json!({"type":"Microsoft.Storage/storageAccounts/blobServices/containers","apiVersion":"2023-05-01","name":format!("{control_account}/default/control"),"dependsOn":[account_id],"properties":{"publicAccess":"None"}}),json!({"type":"Microsoft.App/managedEnvironments","apiVersion":"2024-03-01","name":format!("{}-expiry",n.prefix),"location":location,"properties":{"appLogsConfiguration":{"destination":"none"}}}),json!({"type":"Microsoft.App/jobs","apiVersion":"2024-03-01","name":format!("{}-expiry",n.prefix),"location":location,"tags":{"ows-deployment":p.deployment_id,"ows-nonce":s.nonce,"ows-bundle":s.bundle_digest},"dependsOn":[identity_id,environment_id],"identity":{"type":"UserAssigned","userAssignedIdentities":{identity_id.clone():{}}},"properties":{"environmentId":environment_id,"configuration":{"triggerType":"Schedule","replicaTimeout":240,"replicaRetryLimit":0,"scheduleTriggerConfig":{"cronExpression":"*/5 * * * *","parallelism":1,"replicaCompletionCount":1}},"template":{"containers":[{"name":"cleanup","image":c.guard_image,"command":["/opt/openworker/ows"],"args":["deploy","azure","cleanup","tick","--control",control_url(p),"--tenant",tenant,"--subscription",subscription,"--client-id",client],"resources":{"cpu":0.25,"memory":"0.5Gi"}}]}}}),];+ if let Some(registry) = &c.guard_registry_resource_id {+ let server = format!("{}.azurecr.io", registry.rsplit('/').next().unwrap());+ control_resources.last_mut().unwrap()["properties"]["configuration"]["registries"] =+ json!([{"server":server,"identity":identity_id}]);+ }let template = json!({"$schema":"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#","contentVersion":"1.0.0.0","resources":control_resources});let blob_binding = json!({"schemaVersion":1,"scope":blob_scope,"roleDefinitionId":builtin,"assignments":[{"guid":guid(p,"cleanup-control"),"principalId":recipient,"principalType":"ServicePrincipal"},{"guid":guid(p,"setup-control"),"principalId":p.azure_bootstrap.as_ref().unwrap().setup_object_id,"principalType":p.azure_bootstrap.as_ref().unwrap().setup_principal_type.azure()}],"resolveIdentityAfterControlDeployment":true});let job_role = json!({"properties":{"roleName":format!("{}-cleanup-stop",n.prefix),"type":"CustomRole","assignableScopes":[control_scope],"permissions":[{"actions":["Microsoft.App/jobs/read","Microsoft.App/jobs/delete"],"notActions":[],"dataActions":[],"notDataActions":[]}]},"assignmentScope":job_id(p),"principalId":recipient,"roleDefinitionGuid":guid(p,"cleanup-stop-role"),"assignmentGuid":guid(p,"cleanup-stop-assignment")});@@ -1019,6 +1024,15 @@ fn control_artifacts(s: &State) -> Result<BTreeMap<String, Vec<u8>>> {&json!({"deploymentId":p.deployment_id,"bundleDigest":s.bundle_digest,"control":control_url(p),"controlScope":control_scope,"cleanupRoleDefinitionId":role_id,"cleanupRoleUrl":format!("https://management.azure.com{}/providers/Microsoft.Authorization/roleDefinitions/{}?api-version=2022-04-01",scope(p),guid(p,"cleanup-role")),"cleanupAssignmentUrl":format!("https://management.azure.com{}/providers/Microsoft.Authorization/roleAssignments/{}?api-version=2022-04-01",scope(p),guid(p,"cleanup-workload")),"initializationRequired":true,"retainedControlOwnedByCustomer":true,"liveQualified":false}),)?,),+ (+ "azure-control-registry-binding.json".into(),+ json_bytes(&match &c.guard_registry_resource_id {+ Some(registry) => {+ json!({"scope":registry,"principalId":recipient,"principalType":"ServicePrincipal","roleDefinitionId":format!("/subscriptions/{subscription}/providers/Microsoft.Authorization/roleDefinitions/7f951dda-4ed3-4680-a7ca-43fe172d538d"),"assignmentGuid":guid(p,"cleanup-registry-pull"),"resolveIdentityAfterControlDeployment":true,"automaticGrant":false})+ }+ None => json!({"required":false}),+ })?,+ ),("AZURE-CLEANUP.md".into(), readme.into_bytes()),]))}@@ -1321,6 +1335,40 @@ mod tests {assert!(c.writes.is_empty());}#[test]+ fn private_registry_pulls_bind_cleanup_identity_and_reject_credential_drift() {+ let mut s = state();+ let input = s.plan.azure_infrastructure.as_mut().unwrap();+ input.guard_registry_resource_id = Some("/subscriptions/66666666-7777-4888-8999-aaaaaaaaaaaa/resourceGroups/customer-control/providers/Microsoft.ContainerRegistry/registries/controlacr".into());+ input.guard_image = format!("controlacr.azurecr.io/cleanup@sha256:{}", "a".repeat(64));+ s.bundle_digest = digest(&s.plan).unwrap();+ let job = fixture_job(&s);+ assert!(guard_body(&s, &job).is_ok());+ let files = control_artifacts(&s).unwrap();+ let binding: Value =+ serde_json::from_slice(&files["azure-control-registry-binding.json"]).unwrap();+ assert_eq!(+ binding["scope"],+ s.plan+ .azure_infrastructure+ .as_ref()+ .unwrap()+ .guard_registry_resource_id+ .as_ref()+ .unwrap()+ .as_str()+ );+ for (field, value) in [+ ("identity", json!("system")),+ ("server", json!("foreign.azurecr.io")),+ ("passwordSecretRef", json!("password")),+ ("username", json!("admin")),+ ] {+ let mut changed = job.clone();+ changed["properties"]["configuration"]["registries"][0][field] = value;+ assert!(guard_body(&s, &changed).is_err());+ }+ }+ #[test]fn control_package_has_no_keys_no_cluster_dependency_and_retains_audit_control() {let s = state();let files = control_artifacts(&s).unwrap();@@ -1559,6 +1607,35 @@ fn guard_body(s: &State, body: &Value) -> Result<GuardReceipt> {&& config["scheduleTriggerConfig"]["replicaCompletionCount"] == 1,"Independent cleanup job configuration drift");+ if let Some(registry) = &s+ .plan+ .azure_infrastructure+ .as_ref()+ .unwrap()+ .guard_registry_resource_id+ {+ let entries = config["registries"]+ .as_array()+ .filter(|v| v.len() == 1)+ .context("Exactly one managed-identity cleanup registry required")?;+ let entry = &entries[0];+ ensure!(+ entry["server"] == format!("{}.azurecr.io", registry.rsplit('/').next().unwrap())+ && entry["identity"]+ .as_str()+ .is_some_and(|v| v.eq_ignore_ascii_case(&mi))+ && entry.get("username").is_none_or(Value::is_null)+ && entry.get("passwordSecretRef").is_none_or(Value::is_null),+ "Cleanup registry authentication drift"+ );+ } else {+ ensure!(+ config+ .get("registries")+ .is_none_or(|v| v.is_null() || v.as_array().is_some_and(Vec::is_empty)),+ "Unexpected cleanup registry credentials"+ );+ }Ok(receipt)}diff --git a/harness/service-cli/src/deployment_azure_preflight.rs b/harness/service-cli/src/deployment_azure_preflight.rsindex 4f8f0422..8082c1e3 100644--- a/harness/service-cli/src/deployment_azure_preflight.rs+++ b/harness/service-cli/src/deployment_azure_preflight.rs@@ -159,7 +159,7 @@ fn selected_sku(value: Value, size: &str, location: &str) -> Observed {|| cap("vCPUs").and_then(|v| v.parse::<u64>().ok()) != Some(cores)|| !cap("MemoryGB").and_then(|v| v.parse::<f64>().ok())- .is_some_and(|v| v.is_finite() && v >= 16.0)+ .is_some_and(|v| v.is_finite() && v >= (cores * 4) as f64)|| cap("PremiumIO") != Some("True"){return Err("sku_capability_mismatch");@@ -197,7 +197,7 @@ fn quota_headroom(value: Value, family: &str, needed: u64) -> Observed {}}Ok(- json!({"requiredVcpus":needed,"limits":limits,"scope":"initial_node_pool_only","additionalManagementOrSurgeCapacityIncluded":false,"capacityReserved":false}),+ json!({"requiredVcpus":needed,"limits":limits,"scope":"initial_node_pool_only","managementCapacityIncluded":false,"surgeCapacityIncluded":false,"capacityReserved":false}),)}fn expected_role(p: &Plan, value: Value) -> Observed {@@ -438,6 +438,29 @@ pub async fn preflight(o: &Preflight) -> Result<()> {.and_then(|v| selected_sku(v, size, location)),true,);+ if config.management_access.is_some() {+ check(+ &mut checks,+ "management_sku",+ api.read(+ &["vm", "list-skus"],+ &[+ "--location".into(),+ location.clone(),+ "--resource-type".into(),+ "virtualMachines".into(),+ "--size".into(),+ "Standard_D2as_v7".into(),+ "--all".into(),+ "--query".into(),+ "[?name=='Standard_D2as_v7']".into(),+ ],+ )+ .await+ .and_then(|v| selected_sku(v, "Standard_D2as_v7", location)),+ true,+ );+ }let (family, cores) = graph::node_sku(size).context("Unsupported node SKU")?;quota_verified = check(&mut checks,@@ -447,7 +470,26 @@ pub async fn preflight(o: &Preflight) -> Result<()> {&["--location".into(), location.clone()],).await- .and_then(|v| quota_headroom(v, family, cores * u64::from(p.topology.node_count))),+ .and_then(|v| {+ quota_headroom(+ v,+ family,+ cores * u64::from(p.topology.node_count)+ + if config.management_access.is_some() {+ 2+ } else {+ 0+ },+ )+ .map(|mut detail| {+ if config.management_access.is_some() {+ detail["scope"] = json!("initial_node_pool_and_management");+ detail["managementVcpusIncluded"] = json!(2);+ detail["managementCapacityIncluded"] = json!(true);+ }+ detail+ })+ }),true,);}diff --git a/harness/service-cli/src/deployment_local.rs b/harness/service-cli/src/deployment_local.rsindex 6a591a9f..6a774781 100644--- a/harness/service-cli/src/deployment_local.rs+++ b/harness/service-cli/src/deployment_local.rs@@ -9,7 +9,10 @@ use tokio::{const OWNER: &str = "openworker.io/installer-id";#[path = "deployment_cluster_platform.rs"]mod platform;-const CHART_SHA: &str = "5a82e27d6cf4089fa16d96c87d9fc0fe62f65fa05341465bc749ba5ab91abb33";+const CHART_PINS: &[&str] = &[+ "5a82e27d6cf4089fa16d96c87d9fc0fe62f65fa05341465bc749ba5ab91abb33", // 0.1.3+ "5ce3e63648d1a80f96f748063e44444069667ae9049457b8aded35cdb2a6171a", // 0.1.7 official OCI archive+];#[derive(Subcommand)]pub enum Command {Platform {@@ -436,8 +439,8 @@ fn inputs(c: &Config) -> Result<BTreeMap<String, String>> {{let sha = hash_path(archive)?;ensure!(- sha == CHART_SHA,- "OpenShell archive differs from qualified 0.1.3 pin"+ CHART_PINS.contains(&sha.as_str()),+ "OpenShell archive differs from reviewed 0.1.3/0.1.7 pins");let v = read_json(values_file)?;ensure!(diff --git a/harness/service-cli/tests/azure.rs b/harness/service-cli/tests/azure.rsindex 8d3c74b1..b6bd3609 100644--- a/harness/service-cli/tests/azure.rs+++ b/harness/service-cli/tests/azure.rs@@ -752,3 +752,71 @@ fn selected_compute_restrictions_architecture_and_consumed_quota_block_preflight);}}++#[test]+fn private_control_registry_and_management_access_are_bounded_and_cleanup_owned() {+ let f = Fixture::ready();+ let mut c = infrastructure_config();+ c["nodeVmSize"] = serde_json::json!("Standard_D4as_v7");+ c["guardImage"] = serde_json::json!(format!(+ "trialcontrol.azurecr.io/cleanup@sha256:{}",+ "a".repeat(64)+ ));+ c["guardRegistryResourceId"] = serde_json::json!("/subscriptions/66666666-7777-4888-8999-aaaaaaaaaaaa/resourceGroups/customer-ow-control/providers/Microsoft.ContainerRegistry/registries/trialcontrol");+ c["managementAccess"] =+ serde_json::json!({"operatorIpv4":"203.0.113.42","ubuntuImageVersion":"24.04.202610010"});+ assert!(infrastructure(&f, &c, "managed").status.success());+ let get = |name: &str| -> Value {+ serde_json::from_slice(&fs::read(f.path("managed").join(name)).unwrap()).unwrap()+ };+ let inv = get("azure-inventory.json");+ assert_eq!(inv["resources"].as_array().unwrap().len(), 15);+ assert!(inv["resources"][0]["id"]+ .as_str()+ .unwrap()+ .contains("Microsoft.Compute/virtualMachines"));+ let arm = get("azure-foundation.arm.json");+ let resources = arm["resources"].as_array().unwrap();+ let vm = resources+ .iter()+ .find(|r| r["type"] == "Microsoft.Compute/virtualMachines")+ .unwrap();+ assert_eq!(+ vm["properties"]["hardwareProfile"]["vmSize"],+ "Standard_D2as_v7"+ );+ assert_eq!(+ vm["properties"]["storageProfile"]["osDisk"]["deleteOption"],+ "Delete"+ );+ assert_eq!(+ vm["properties"]["osProfile"]["linuxConfiguration"]["disablePasswordAuthentication"],+ true+ );+ let nsg = resources+ .iter()+ .find(|r| r["type"] == "Microsoft.Network/networkSecurityGroups")+ .unwrap();+ assert_eq!(+ nsg["properties"]["securityRules"][0]["properties"]["sourceAddressPrefix"],+ "203.0.113.42/32"+ );+ let result = f.preflight_plan("managed", "ready", "managed-report");+ assert!(+ result.status.success(),+ "{}",+ String::from_utf8_lossy(&result.stderr)+ );+ let report = f.report("managed-report");+ let quota = report["checks"]+ .as_array()+ .unwrap()+ .iter()+ .find(|v| v["name"] == "selected_node_quota")+ .unwrap();+ assert_eq!(quota["detail"]["requiredVcpus"], 10);+ for (key,bad) in [("guardRegistryResourceId",serde_json::json!("/subscriptions/other/resourceGroups/other/providers/Microsoft.ContainerRegistry/registries/trialcontrol")),("managementAccess",serde_json::json!({"operatorIpv4":"0.0.0.0/0","ubuntuImageVersion":"latest"}))] {+ let mut invalid=c.clone();invalid[key]=bad;+ assert!(!infrastructure(&f,&invalid,"invalid-managed").status.success());+ }+}diff --git a/harness/service-cli/tests/fixtures/azure-bootstrap.py b/harness/service-cli/tests/fixtures/azure-bootstrap.pyindex ede4d345..7470b534 100644--- a/harness/service-cli/tests/fixtures/azure-bootstrap.py+++ b/harness/service-cli/tests/fixtures/azure-bootstrap.py@@ -96,8 +96,8 @@ if args[:2] == ["vm", "list-skus"]:assert value("--location") == target["location"]assert value("--resource-type") == "virtualMachines" and "--all" in argsassert value("--query") == "[?name=='" + size + "']"- family = "StandardDasv7Family" if size == "Standard_D4as_v7" else "standardDSv5Family"- caps = {"CpuArchitectureType": "x64", "vCPUs": "8" if size == "Standard_D8s_v5" else "4", "MemoryGB": "16", "PremiumIO": "True"}+ family = "StandardDasv7Family" if size in ["Standard_D4as_v7", "Standard_D2as_v7"] else "standardDSv5Family"+ caps = {"CpuArchitectureType": "x64", "vCPUs": "8" if size == "Standard_D8s_v5" else "2" if size == "Standard_D2as_v7" else "4", "MemoryGB": "16", "PremiumIO": "True"}if scenario == "arm-sku": caps["CpuArchitectureType"] = "Arm64"emit([{"name":size,"family":family,"resourceType":"virtualMachines","locations":[target["location"]],"capabilities":[{"name":k,"value":v} for k,v in caps.items()],"restrictions":[{"type":"Location","reasonCode":"NotAvailableForSubscription"}] if scenario == "restricted-sku" else []}])if args[:2] == ["vm", "list-usage"]: