@@ -1542,9 +1542,11 @@ def get_k8s_extension_module(module_name):
15421542 try :
15431543 # adding the installed extension in the path
15441544 from azure .cli .core .extension .operations import add_extension_to_path
1545+
15451546 add_extension_to_path (consts .CONST_K8S_EXTENSION_NAME )
15461547 # import the extension module
15471548 from importlib import import_module
1549+
15481550 azext_custom = import_module (module_name )
15491551 return azext_custom
15501552 except ImportError :
@@ -1555,27 +1557,33 @@ def get_k8s_extension_module(module_name):
15551557
15561558
15571559def get_bundle_feature_flag_from_arc_agentry_config (
1558- current_arc_agentry_config : list [ArcAgentryConfigurations ]
1560+ current_arc_agentry_config : list [ArcAgentryConfigurations ],
15591561) -> str | None :
15601562 for agentry_config in current_arc_agentry_config :
1561- if agentry_config .feature == consts .Arc_Agentry_Bundle_Feature and \
1562- consts .Arc_Agentry_Bundle_Feature_Setting in agentry_config .settings :
1563- return agentry_config .settings [consts .Arc_Agentry_Bundle_Feature_Setting ].lower ()
1563+ if (
1564+ agentry_config .feature == consts .Arc_Agentry_Bundle_Feature
1565+ and consts .Arc_Agentry_Bundle_Feature_Setting in agentry_config .settings
1566+ ):
1567+ return agentry_config .settings [
1568+ consts .Arc_Agentry_Bundle_Feature_Setting
1569+ ].lower ()
15641570 return None
15651571
15661572
15671573def get_bundle_feature_flag_from_configuration_settings (
1568- configuration_settings : dict [str , Any ]
1574+ configuration_settings : dict [str , Any ],
15691575) -> str | None :
15701576 settings = configuration_settings .get (consts .Arc_Agentry_Bundle_Feature , {})
15711577 value = settings .get (consts .Arc_Agentry_Bundle_Feature_Setting )
15721578 return value if value is None else value .lower ()
15731579
15741580
15751581def validate_bundle_feature_flag_value (
1576- configuration_settings : dict [str , Any ]
1582+ configuration_settings : dict [str , Any ],
15771583) -> str | None :
1578- print (f"Step: { utils .get_utctimestring ()} : Validating the bundle feature flag value" )
1584+ print (
1585+ f"Step: { utils .get_utctimestring ()} : Validating the bundle feature flag value"
1586+ )
15791587 value = get_bundle_feature_flag_from_configuration_settings (configuration_settings )
15801588
15811589 if value is not None :
@@ -1588,8 +1596,12 @@ def validate_bundle_feature_flag_value(
15881596 f"'{ value } '. Please specify a value from the list: { consts .Bundle_Feature_Value_List } ."
15891597 )
15901598
1591- configuration_settings [consts .Arc_Agentry_Bundle_Feature ][consts .Arc_Agentry_Bundle_Feature_Setting ] = value
1592- print (f"Step: { utils .get_utctimestring ()} : Setting the bundle feature flag value to '{ value } '" )
1599+ configuration_settings [consts .Arc_Agentry_Bundle_Feature ][
1600+ consts .Arc_Agentry_Bundle_Feature_Setting
1601+ ] = value
1602+ print (
1603+ f"Step: { utils .get_utctimestring ()} : Setting the bundle feature flag value to '{ value } '"
1604+ )
15931605
15941606 return value
15951607
@@ -1598,7 +1610,9 @@ def validate_connect_cluster_bundle_feature_flag_value(
15981610 configuration_settings : dict [str , Any ],
15991611 yes : bool = False ,
16001612):
1601- bundle_feature_flag_value = validate_bundle_feature_flag_value (configuration_settings )
1613+ bundle_feature_flag_value = validate_bundle_feature_flag_value (
1614+ configuration_settings
1615+ )
16021616
16031617 # If the bundle feature flag value is None, skip the validation
16041618 if bundle_feature_flag_value is None :
@@ -1616,7 +1630,7 @@ def validate_connect_cluster_bundle_feature_flag_value(
16161630 logger .warning (
16171631 "Entered %s 'preview' mode. All SLA support is discontinued, and the cluster will remain in 'preview' mode "
16181632 "until it is disconnected from Arc." ,
1619- consts .Arc_Agentry_Bundle_Feature_Setting
1633+ consts .Arc_Agentry_Bundle_Feature_Setting ,
16201634 )
16211635
16221636 elif bundle_feature_flag_value == "disabled" :
@@ -1635,13 +1649,17 @@ def validate_update_cluster_bundle_feature_flag_value(
16351649 resource_group_name : str ,
16361650 cluster_name : str ,
16371651):
1638- bundle_feature_flag_value = validate_bundle_feature_flag_value (configuration_settings )
1652+ bundle_feature_flag_value = validate_bundle_feature_flag_value (
1653+ configuration_settings
1654+ )
16391655
16401656 # If the bundle feature flag value is None, skip the validation
16411657 if bundle_feature_flag_value is None :
16421658 return
16431659
1644- current_bundle_feature_flag_value = get_bundle_feature_flag_from_arc_agentry_config (current_arc_agentry_config )
1660+ current_bundle_feature_flag_value = get_bundle_feature_flag_from_arc_agentry_config (
1661+ current_arc_agentry_config
1662+ )
16451663
16461664 if bundle_feature_flag_value == "preview" :
16471665 err_msg = (
@@ -1659,8 +1677,11 @@ def validate_update_cluster_bundle_feature_flag_value(
16591677 raise ArgumentUsageError (err_msg )
16601678
16611679 invalid_transition = (
1662- (current_bundle_feature_flag_value == "enabled" and bundle_feature_flag_value == "" ) or
1663- (current_bundle_feature_flag_value == "" and bundle_feature_flag_value == "disabled" )
1680+ current_bundle_feature_flag_value == "enabled"
1681+ and bundle_feature_flag_value == ""
1682+ ) or (
1683+ current_bundle_feature_flag_value == ""
1684+ and bundle_feature_flag_value == "disabled"
16641685 )
16651686
16661687 if invalid_transition :
@@ -1672,10 +1693,17 @@ def validate_update_cluster_bundle_feature_flag_value(
16721693 raise ArgumentUsageError (err_msg )
16731694
16741695 # If the bundle feature flag is set to 'disabled', check if any bundle extensions are installed
1675- if current_bundle_feature_flag_value == "enabled" and bundle_feature_flag_value == "disabled" :
1676- client_factory = get_k8s_extension_module (consts .CONST_K8S_EXTENSION_CLIENT_FACTORY_MOD_NAME )
1696+ if (
1697+ current_bundle_feature_flag_value == "enabled"
1698+ and bundle_feature_flag_value == "disabled"
1699+ ):
1700+ client_factory = get_k8s_extension_module (
1701+ consts .CONST_K8S_EXTENSION_CLIENT_FACTORY_MOD_NAME
1702+ )
16771703 client = client_factory .cf_k8s_extension_operation (cmd .cli_ctx )
1678- k8s_extension_custom_mod = get_k8s_extension_module (consts .CONST_K8S_EXTENSION_CUSTOM_MOD_NAME )
1704+ k8s_extension_custom_mod = get_k8s_extension_module (
1705+ consts .CONST_K8S_EXTENSION_CUSTOM_MOD_NAME
1706+ )
16791707 extensions = k8s_extension_custom_mod .list_k8s_extension (
16801708 client ,
16811709 resource_group_name ,
@@ -2296,7 +2324,11 @@ def update_connected_cluster(
22962324
22972325 # Validate and update bundle feature flag value if provided
22982326 validate_update_cluster_bundle_feature_flag_value (
2299- cmd , connected_cluster .arc_agentry_configurations , configuration_settings , resource_group_name , cluster_name
2327+ cmd ,
2328+ connected_cluster .arc_agentry_configurations ,
2329+ configuration_settings ,
2330+ resource_group_name ,
2331+ cluster_name ,
23002332 )
23012333
23022334 arc_agentry_configurations = generate_arc_agent_configuration (
@@ -2869,11 +2901,13 @@ def upgrade_agents(
28692901 ):
28702902 telemetry .set_user_fault ()
28712903
2872- namespace = "azure-arc"
2873- label_selector = "job-name=agent-update-validator "
2904+ namespace = consts . Arc_Namespace
2905+ label_selector = f "job-name={ consts . Arc_Agent_Update_Validator_Job_Label } "
28742906
28752907 # Get the list of pods matching the label
2876- pods = api_instance .list_namespaced_pod (namespace = namespace , label_selector = label_selector )
2908+ pods = api_instance .list_namespaced_pod (
2909+ namespace = namespace , label_selector = label_selector
2910+ )
28772911
28782912 # Extract the terminated message from the container
28792913 if pods .items :
0 commit comments