From 50b48ca8891372cfd0effde48e60b1b069f1ab39 Mon Sep 17 00:00:00 2001 From: Paymaun Heidari Date: Mon, 2 Oct 2023 17:56:34 -0700 Subject: [PATCH 1/3] fix(init):Include separate optional param for custom location namespace. --- azext_edge/edge/commands_edge.py | 6 +++++- azext_edge/edge/params.py | 12 +++++++++--- azext_edge/edge/providers/support/bluefin.py | 2 +- azext_edge/tests/edge/init/test_init_unit.py | 10 ++++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/azext_edge/edge/commands_edge.py b/azext_edge/edge/commands_edge.py index 3c04314b5..ceb5fff3a 100644 --- a/azext_edge/edge/commands_edge.py +++ b/azext_edge/edge/commands_edge.py @@ -64,6 +64,7 @@ def init( cluster_name: str, resource_group_name: str, cluster_namespace: str = "default", + custom_location_namespace: Optional[str] = None, pas_version: str = DeployablePasVersions.v012.value, custom_location_name: Optional[str] = None, show_pas_version: Optional[bool] = None, @@ -91,6 +92,9 @@ def init( if not custom_location_name: custom_location_name = f"{cluster_name_lowered}-azedge-init" + if not custom_location_namespace: + custom_location_namespace = cluster_namespace + if not processor_instance_name: processor_instance_name = f"{cluster_name_lowered}-azedge-init-proc" processor_instance_name = processor_instance_name.replace("_", "-") @@ -106,7 +110,7 @@ def init( cluster_name=cluster_name, cluster_namespace=cluster_namespace, custom_location_name=custom_location_name, - custom_location_namespace=cluster_namespace, + custom_location_namespace=custom_location_namespace, resource_group_name=resource_group_name, pas_version=pas_version, location=location, diff --git a/azext_edge/edge/params.py b/azext_edge/edge/params.py index 4fc126f03..78968a1ed 100644 --- a/azext_edge/edge/params.py +++ b/azext_edge/edge/params.py @@ -152,18 +152,24 @@ def load_iotedge_arguments(self, _): context.argument( "custom_location_name", options_list=["--custom-location"], - help="The custom location name corresponding to the PAS deployment. If no custom location name is provided" + help="The custom location name corresponding to PAS solution deployment. If no custom location name is provided" " one will be generated in the form '{cluster_name}-azedge-init'.", ) + context.argument( + "custom_location_namespace", + options_list=["--custom-location-namespace", "--cln"], + help="The namespace associated with the custom location mapped to the cluster. Must be lowercase. If not provided " + "cluster namespace will be used.", + ) context.argument( "cluster_namespace", options_list=["--cluster-namespace"], - help="The cluster namespace PAS resources will be deployed to. Must be lowercase.", + help="The cluster namespace PAS infrastructure will be deployed to. Must be lowercase.", ) context.argument( "location", options_list=["--location"], - help="The location that will be used for provisioned collateral. " + help="The ARM location that will be used for provisioned ARM collateral. " "If not provided the resource group location will be used.", ) context.argument( diff --git a/azext_edge/edge/providers/support/bluefin.py b/azext_edge/edge/providers/support/bluefin.py index 7f48a6e7f..d0c2ce297 100644 --- a/azext_edge/edge/providers/support/bluefin.py +++ b/azext_edge/edge/providers/support/bluefin.py @@ -23,7 +23,7 @@ BLUEFIN_APP_LABEL = ( - "app in (bluefin-reader-worker,bluefin-refdata-store,bf-instance-nats-box" + "app in (bluefin-reader-worker,bluefin-refdata-store,bf-instance-nats-box,nats" ",bluefin-scheduler,bluefin-runner-worker,bluefin-portal,bluefin-api-proxy)" ) BLUEFIN_RELEASE_LABEL = "release in (bf-instance)" diff --git a/azext_edge/tests/edge/init/test_init_unit.py b/azext_edge/tests/edge/init/test_init_unit.py index eafb44833..0230c5ad3 100644 --- a/azext_edge/tests/edge/init/test_init_unit.py +++ b/azext_edge/tests/edge/init/test_init_unit.py @@ -18,7 +18,7 @@ @pytest.mark.parametrize( - "cluster_name,cluster_namespace,rg,custom_location_name,location,pas_version," + "cluster_name,cluster_namespace,rg,custom_location_name,custom_location_namespace,location,pas_version," "processor_instance_name,simulate_plc,opcua_discovery_endpoint,create_sync_rules," "custom_version,target_name", [ @@ -27,6 +27,7 @@ generate_generic_id(), # cluster_namespace generate_generic_id(), # rg generate_generic_id(), # custom_location_name + generate_generic_id(), # custom_location_namespace generate_generic_id(), # location DeployablePasVersions.v012.value, generate_generic_id(), # processor_instance_name @@ -41,6 +42,7 @@ "default", # cluster_namespace generate_generic_id(), # rg None, # custom_location_name + None, # custom_location_namespace None, # location DeployablePasVersions.v012.value, None, # processor_instance_name @@ -59,6 +61,7 @@ def test_init_show_template( cluster_namespace, rg, custom_location_name, + custom_location_namespace, location, pas_version, processor_instance_name, @@ -75,6 +78,7 @@ def test_init_show_template( cluster_namespace=cluster_namespace, resource_group_name=rg, custom_location_name=custom_location_name, + custom_location_namespace=custom_location_namespace, location=location, processor_instance_name=processor_instance_name, simulate_plc=simulate_plc, @@ -105,6 +109,7 @@ def test_init_show_template( cluster_name=cluster_name, cluster_namespace=cluster_namespace, custom_location_name=custom_location_name, + custom_location_namespace=custom_location_namespace, pas_version=pas_version, processor_instance_name=processor_instance_name, simulate_plc=simulate_plc, @@ -135,6 +140,7 @@ def assert_resources( cluster_name: str, cluster_namespace: str, custom_location_name: str, + custom_location_namespace: str, pas_version: str, processor_instance_name: Optional[str] = None, simulate_plc: Optional[bool] = None, @@ -185,7 +191,7 @@ def assert_resources( custom_location=next(iter(custom_locations.values())), name=custom_location_name, cluster_name=cluster_name, - namespace=cluster_namespace, + namespace=custom_location_namespace or cluster_namespace, depends_on=cluster_extension_ids, cluster_ext_ids=cluster_extension_ids, ) From b64e000cbd14cbf1b4683b10e1baa6135f095665 Mon Sep 17 00:00:00 2001 From: Paymaun Heidari Date: Mon, 2 Oct 2023 18:18:44 -0700 Subject: [PATCH 2/3] lint fix --- azext_edge/edge/params.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azext_edge/edge/params.py b/azext_edge/edge/params.py index 78968a1ed..371e00fb2 100644 --- a/azext_edge/edge/params.py +++ b/azext_edge/edge/params.py @@ -152,14 +152,14 @@ def load_iotedge_arguments(self, _): context.argument( "custom_location_name", options_list=["--custom-location"], - help="The custom location name corresponding to PAS solution deployment. If no custom location name is provided" - " one will be generated in the form '{cluster_name}-azedge-init'.", + help="The custom location name corresponding to PAS solution deployment. " + "If no custom location name is provided one will be generated in the form '{cluster_name}-azedge-init'.", ) context.argument( "custom_location_namespace", - options_list=["--custom-location-namespace", "--cln"], - help="The namespace associated with the custom location mapped to the cluster. Must be lowercase. If not provided " - "cluster namespace will be used.", + options_list=["--custom-location-namespace"], + help="The namespace associated with the custom location mapped to the cluster. Must be lowercase. " + "If not provided cluster namespace will be used.", ) context.argument( "cluster_namespace", From 8e93ffd72a40506c45014b650eb1e1d2edcd1e9e Mon Sep 17 00:00:00 2001 From: Paymaun Heidari Date: Mon, 2 Oct 2023 18:29:21 -0700 Subject: [PATCH 3/3] re-add short alias. --- azext_edge/edge/params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azext_edge/edge/params.py b/azext_edge/edge/params.py index 371e00fb2..b4b1e3919 100644 --- a/azext_edge/edge/params.py +++ b/azext_edge/edge/params.py @@ -157,7 +157,7 @@ def load_iotedge_arguments(self, _): ) context.argument( "custom_location_namespace", - options_list=["--custom-location-namespace"], + options_list=["--custom-location-namespace", "--cln"], help="The namespace associated with the custom location mapped to the cluster. Must be lowercase. " "If not provided cluster namespace will be used.", )