From 0a95d4521f569e2589ec1052c5d07ccc9ff3ba4a Mon Sep 17 00:00:00 2001 From: bragi92 Date: Fri, 28 Jul 2023 11:11:21 -0700 Subject: [PATCH 1/5] {ARC} fix: update logic to sanitize cluster name for dc* objects --- .../partner_extensions/azuremonitormetrics/dc/defaults.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py index 8dd7260377e..ee8ad7184b3 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py @@ -13,10 +13,11 @@ # All DC* object names should end only in alpha numeric (after `length` trim) # DCE remove underscore from cluster name def sanitize_name(name, objtype, length): + name = name[0:length] length = length - 1 if objtype == DC_TYPE.DCE: name = name.replace("_", "") - name = name[0:length] + name = ''.join(char for char in name if char.isalnum() or char == '-') lastIndexAlphaNumeric = len(name) - 1 while ((name[lastIndexAlphaNumeric].isalnum() is False) and lastIndexAlphaNumeric > -1): lastIndexAlphaNumeric = lastIndexAlphaNumeric - 1 From 3e2d8a3dccdb106129786284ff27da3b18fceae1 Mon Sep 17 00:00:00 2001 From: bragi92 Date: Fri, 28 Jul 2023 12:29:56 -0700 Subject: [PATCH 2/5] only apply for DCE --- .../partner_extensions/azuremonitormetrics/dc/defaults.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py index ee8ad7184b3..e5d44ea7eab 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py @@ -17,7 +17,7 @@ def sanitize_name(name, objtype, length): length = length - 1 if objtype == DC_TYPE.DCE: name = name.replace("_", "") - name = ''.join(char for char in name if char.isalnum() or char == '-') + name = ''.join(char for char in name if char.isalnum() or char == '-') lastIndexAlphaNumeric = len(name) - 1 while ((name[lastIndexAlphaNumeric].isalnum() is False) and lastIndexAlphaNumeric > -1): lastIndexAlphaNumeric = lastIndexAlphaNumeric - 1 From e7e1bdb0b77f3f625668d632b555e46ce91355ff Mon Sep 17 00:00:00 2001 From: bragi92 Date: Fri, 28 Jul 2023 13:11:30 -0700 Subject: [PATCH 3/5] Update defaults.py --- .../partner_extensions/azuremonitormetrics/dc/defaults.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py index e5d44ea7eab..e126a422020 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py @@ -14,7 +14,8 @@ # DCE remove underscore from cluster name def sanitize_name(name, objtype, length): name = name[0:length] - length = length - 1 + length = length - + if objtype == DC_TYPE.DCE: name = name.replace("_", "") name = ''.join(char for char in name if char.isalnum() or char == '-') From fc762892bda651ec0db5ce27378aa477f3bd0c40 Mon Sep 17 00:00:00 2001 From: bragi92 Date: Fri, 28 Jul 2023 14:12:44 -0700 Subject: [PATCH 4/5] Update defaults.py --- .../partner_extensions/azuremonitormetrics/dc/defaults.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py index e126a422020..e5d44ea7eab 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py @@ -14,8 +14,7 @@ # DCE remove underscore from cluster name def sanitize_name(name, objtype, length): name = name[0:length] - length = length - - + length = length - 1 if objtype == DC_TYPE.DCE: name = name.replace("_", "") name = ''.join(char for char in name if char.isalnum() or char == '-') From 42ed7ca6cabcc43cd55e416891c4cdc6f6f93f78 Mon Sep 17 00:00:00 2001 From: bragi92 Date: Tue, 1 Aug 2023 12:35:50 -0700 Subject: [PATCH 5/5] remove uneeded line --- .../partner_extensions/azuremonitormetrics/dc/defaults.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py index e5d44ea7eab..9acd2ae8e23 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py @@ -16,7 +16,6 @@ def sanitize_name(name, objtype, length): name = name[0:length] length = length - 1 if objtype == DC_TYPE.DCE: - name = name.replace("_", "") name = ''.join(char for char in name if char.isalnum() or char == '-') lastIndexAlphaNumeric = len(name) - 1 while ((name[lastIndexAlphaNumeric].isalnum() is False) and lastIndexAlphaNumeric > -1):