Skip to content

Commit b87d827

Browse files
Merge branch 'Azure:dev' into dev
2 parents 130c99c + 8e3b15a commit b87d827

File tree

11 files changed

+5229
-3137
lines changed

11 files changed

+5229
-3137
lines changed

src/azure-cli-core/azure/cli/core/commands/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ def _is_paged(obj):
12141214

12151215
def _is_poller(obj):
12161216
# Since loading msrest is expensive, we avoid it until we have to
1217-
if obj.__class__.__name__ in ['AzureOperationPoller', 'LROPoller', 'AAZLROPoller']:
1217+
if obj.__class__.__name__ in ['LROPoller', 'AAZLROPoller']:
12181218
return isinstance(obj, poller_classes())
12191219
return False
12201220

src/azure-cli-core/azure/cli/core/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,10 @@ def should_disable_connection_verify():
675675

676676

677677
def poller_classes():
678-
from msrestazure.azure_operation import AzureOperationPoller
679678
from msrest.polling.poller import LROPoller
680679
from azure.core.polling import LROPoller as AzureCoreLROPoller
681680
from azure.cli.core.aaz._poller import AAZLROPoller
682-
return (AzureOperationPoller, LROPoller, AzureCoreLROPoller, AAZLROPoller)
681+
return (LROPoller, AzureCoreLROPoller, AAZLROPoller)
683682

684683

685684
def augment_no_wait_handler_args(no_wait_enabled, handler, handler_args):

src/azure-cli-testsdk/azure/cli/testsdk/patches.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ def _shortcut_long_run_operation(*args, **kwargs): # pylint: disable=unused-arg
8585
return
8686

8787
mock_in_unit_test(unit_test,
88-
'msrestazure.azure_operation.AzureOperationPoller._delay',
89-
_shortcut_long_run_operation)
90-
mock_in_unit_test(unit_test,
91-
'msrestazure.polling.arm_polling.ARMPolling._delay',
88+
'azure.mgmt.core.polling.arm_polling.ARMPolling._delay',
9289
_shortcut_long_run_operation)
9390
mock_in_unit_test(unit_test,
9491
'azure.cli.core.commands.LongRunningOperation._delay',

src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ def setUp(self):
153153

154154
def tearDown(self):
155155
os.environ = self.original_env
156-
# Autorest.Python 2.x
157-
assert not [t for t in threading.enumerate() if t.name.startswith("AzureOperationPoller")], \
158-
"You need to call 'result' or 'wait' on all AzureOperationPoller you have created"
159156
# Autorest.Python 3.x
160157
assert not [t for t in threading.enumerate() if t.name.startswith("LROPoller")], \
161158
"You need to call 'result' or 'wait' on all LROPoller you have created"

src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _shortcut_long_run_operation(*args, **kwargs): # pylint: disable=unused-arg
1818
return
1919

2020
mock_in_unit_test(unit_test,
21-
'msrestazure.azure_operation.AzureOperationPoller._delay',
21+
'azure.mgmt.core.polling.arm_polling.ARMPolling._delay',
2222
_shortcut_long_run_operation)
2323

2424

src/azure-cli/azure/cli/command_modules/acs/custom.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,8 +1152,7 @@ def aks_enable_addons(cmd, client, resource_group_name, name, addons,
11521152
rotation_poll_interval=rotation_poll_interval,
11531153
no_wait=no_wait,)
11541154

1155-
enable_monitoring = CONST_MONITORING_ADDON_NAME in instance.addon_profiles \
1156-
and instance.addon_profiles[CONST_MONITORING_ADDON_NAME].enabled
1155+
enable_monitoring = is_monitoring_addon_enabled(addons, instance)
11571156
ingress_appgw_addon_enabled = CONST_INGRESS_APPGW_ADDON_NAME in instance.addon_profiles \
11581157
and instance.addon_profiles[CONST_INGRESS_APPGW_ADDON_NAME].enabled
11591158

@@ -3254,3 +3253,23 @@ def _aks_approuting_update(
32543253
return None
32553254

32563255
return aks_update_decorator.update_mc(mc)
3256+
3257+
3258+
def is_monitoring_addon_enabled(addons, instance):
3259+
monitoring_addon_enabled = False
3260+
is_monitoring_addon = False
3261+
try:
3262+
addon_args = addons.split(',')
3263+
for addon_arg in addon_args:
3264+
if addon_arg in ADDONS:
3265+
addon = ADDONS[addon_arg]
3266+
if addon == CONST_MONITORING_ADDON_NAME:
3267+
is_monitoring_addon = True
3268+
break
3269+
3270+
addon_profiles = instance.addon_profiles or {}
3271+
monitoring_addon_enabled = is_monitoring_addon and CONST_MONITORING_ADDON_NAME in addon_profiles and addon_profiles[
3272+
CONST_MONITORING_ADDON_NAME].enabled
3273+
except Exception as ex: # pylint: disable=broad-except
3274+
logger.debug("failed to check monitoring addon enabled: %s", ex)
3275+
return monitoring_addon_enabled

src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _get_lts_versions(self, location):
107107
).get_output_in_json()
108108
sorted_lts_versions = sorted(lts_versions, key=version_to_tuple, reverse=False)
109109
return sorted_lts_versions
110-
110+
111111
def _get_newer_non_lts_version(self, location, version):
112112
"""Return the nearest newer non-lts version of the specified version."""
113113
supported_versions = self.cmd(
@@ -8144,6 +8144,13 @@ def test_aks_create_with_monitoring_aad_auth_msi_with_datacollectionsettings(sel
81448144
aks_name = self.create_random_name('cliakstest', 16)
81458145
self.create_new_cluster_with_monitoring_aad_auth(resource_group, resource_group_location, aks_name, user_assigned_identity=False, syslog_enabled=False, data_collection_settings=get_test_data_file_path('datacollectionsettings.json'))
81468146

8147+
@live_only()
8148+
@AllowLargeResponse()
8149+
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
8150+
def test_aks_create_with_monitoring_aad_auth_msi_with_datacollectionsettings_and_otheraddon(self, resource_group, resource_group_location,):
8151+
aks_name = self.create_random_name('cliakstest', 16)
8152+
self.create_new_cluster_with_monitoring_aad_auth(resource_group, resource_group_location, aks_name, user_assigned_identity=False, syslog_enabled=False, data_collection_settings=get_test_data_file_path('datacollectionsettings.json'), use_ampls=False, highlogscale_mode_enabled=True, enableOtherAddon=True)
8153+
81478154
@live_only()
81488155
@AllowLargeResponse()
81498156
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
@@ -8176,7 +8183,7 @@ def test_aks_create_with_private_cluster_with_monitoring_aad_auth_msi_with_ampls
81768183

81778184

81788185

8179-
def create_new_cluster_with_monitoring_aad_auth(self, resource_group, resource_group_location, aks_name, user_assigned_identity=False, syslog_enabled=False, data_collection_settings=None, use_ampls=False, highlogscale_mode_enabled=False):
8186+
def create_new_cluster_with_monitoring_aad_auth(self, resource_group, resource_group_location, aks_name, user_assigned_identity=False, syslog_enabled=False, data_collection_settings=None, use_ampls=False, highlogscale_mode_enabled=False, enableOtherAddon=False):
81808187
self.kwargs.update({
81818188
'resource_group': resource_group,
81828189
'name': aks_name,
@@ -8208,6 +8215,10 @@ def create_new_cluster_with_monitoring_aad_auth(self, resource_group, resource_g
82088215
create_cmd += f'--ampls-resource-id {ampls_resource_id} ' if use_ampls else ''
82098216
create_cmd += f'--enable-high-log-scale-mode ' if highlogscale_mode_enabled else ''
82108217

8218+
if enableOtherAddon:
8219+
# enable other addon such azure-policy to verify the monitoring addon and DCRs etc.. remainins intact.
8220+
self.cmd(f'aks enable-addons -a azure-policy -g={resource_group} -n={aks_name}')
8221+
82118222
response = self.cmd(create_cmd, checks=[
82128223
self.check('addonProfiles.omsagent.enabled', True),
82138224
self.check('addonProfiles.omsagent.config.useAADAuth', 'true')
@@ -10555,7 +10566,7 @@ def test_aks_upgrade_with_tier_switch(self, resource_group, resource_group_locat
1055510566
upgrade_version = self._get_newer_non_lts_version(resource_group_location, create_version)
1055610567
if upgrade_version is None:
1055710568
self.skipTest('No newer non-LTS versions found in the location')
10558-
10569+
1055910570
self.kwargs.update({
1056010571
'resource_group': resource_group,
1056110572
'name': aks_name,

src/azure-cli/azure/cli/command_modules/resource/custom.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4522,7 +4522,9 @@ def invoke_action(self, action, request_body):
45224522
"""
45234523
Formats Url if none provided and sends the POST request with the url and request-body.
45244524
"""
4525-
from msrestazure.azure_operation import AzureOperationPoller
4525+
4526+
from azure.core.polling import LROPoller
4527+
from azure.mgmt.core.polling.arm_polling import ARMPolling
45264528

45274529
query_parameters = {}
45284530
serialize = self.rcf.resources._serialize # pylint: disable=protected-access
@@ -4564,28 +4566,14 @@ def invoke_action(self, action, request_body):
45644566
body_content_kwargs = {}
45654567
body_content_kwargs['content'] = json.loads(request_body) if request_body else None
45664568

4567-
# Construct and send request
4568-
def long_running_send():
4569-
request = client.post(url, query_parameters, header_parameters, **body_content_kwargs)
4570-
pipeline_response = client._pipeline.run(request, stream=False)
4571-
return pipeline_response.http_response.internal_response
4572-
4573-
def get_long_running_status(status_link, headers=None):
4574-
request = client.get(status_link, query_parameters, header_parameters)
4575-
if headers:
4576-
request.headers.update(headers)
4577-
pipeline_response = client._pipeline.run(request, stream=False)
4578-
return pipeline_response.http_response.internal_response
4579-
4580-
def get_long_running_output(response):
4581-
from azure.core.exceptions import HttpResponseError
4582-
if response.status_code not in [200, 202, 204]:
4583-
exp = HttpResponseError(response)
4584-
exp.request_id = response.headers.get('x-ms-request-id')
4585-
raise exp
4586-
return response.text
4587-
4588-
return AzureOperationPoller(long_running_send, get_long_running_output, get_long_running_status)
4569+
def deserialization_cb(pipeline_response):
4570+
return json.loads(pipeline_response.http_response.text())
4571+
4572+
request = client.post(url, query_parameters, header_parameters, **body_content_kwargs)
4573+
pipeline_response = client._pipeline.run(request, stream=False)
4574+
4575+
return LROPoller(client=client, initial_response=pipeline_response, deserialization_callback=deserialization_cb,
4576+
polling_method=ARMPolling())
45894577

45904578
@staticmethod
45914579
def resolve_api_version(rcf, resource_provider_namespace, parent_resource_path, resource_type,

0 commit comments

Comments
 (0)