Skip to content

Commit 14ba0fd

Browse files
committed
fix
1 parent 6552b9c commit 14ba0fd

2 files changed

Lines changed: 32 additions & 23 deletions

File tree

src/aks-preview/azext_aks_preview/agentpool_decorator.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,11 +1562,14 @@ def set_up_machines_mode(self, agentpool: AgentPool) -> AgentPool:
15621562
# Make sure all other attributes are None
15631563
# Check properties sub-model first (AgentPool), then flat fields (ManagedClusterAgentPoolProfile)
15641564
props = getattr(agentpool, 'properties', None)
1565-
if props is not None and hasattr(props, '_attr_to_rest_field'):
1566-
target, fields = props, props._attr_to_rest_field
1567-
elif hasattr(agentpool, '_attr_to_rest_field') and 'mode' in agentpool._attr_to_rest_field:
1568-
target, fields = agentpool, agentpool._attr_to_rest_field
1565+
rest_fields = getattr(props, '_attr_to_rest_field', None) if props is not None else None
1566+
if rest_fields is not None:
1567+
target, fields = props, rest_fields
15691568
else:
1569+
rest_fields = getattr(agentpool, '_attr_to_rest_field', None)
1570+
if rest_fields is not None and 'mode' in rest_fields:
1571+
target, fields = agentpool, rest_fields
1572+
else:
15701573
target, fields = None, None
15711574
if target is not None:
15721575
for attr in list(fields.keys()):

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def _get_etag_match_condition(if_match, if_none_match):
159159
return if_none_match, MatchConditions.IfMissing
160160
return None, None
161161

162+
162163
# type variables
163164
ContainerServiceClient = TypeVar("ContainerServiceClient")
164165
ContainerServiceNetworkProfileKubeProxyConfig = TypeVar("ContainerServiceNetworkProfileKubeProxyConfig")
@@ -4691,7 +4692,8 @@ def _setup_opentelemetry_logs(self, mc: ManagedCluster) -> None:
46914692
"""Set up OpenTelemetry logs configuration."""
46924693
self._ensure_app_monitoring_profile(mc)
46934694

4694-
otlp_logs_config = self.models.ManagedClusterAzureMonitorProfileAppMonitoringOpenTelemetryLogsAndTraces(enabled=True)
4695+
otel_logs_cls = self.models.ManagedClusterAzureMonitorProfileAppMonitoringOpenTelemetryLogsAndTraces
4696+
otlp_logs_config = otel_logs_cls(enabled=True)
46954697
logs_port = self.context.get_opentelemetry_logs_port()
46964698
if logs_port:
46974699
otlp_logs_config.http_port = logs_port
@@ -5568,25 +5570,28 @@ def update_managed_system_pools(self, mc: ManagedCluster) -> ManagedCluster:
55685570
return mc
55695571
for agentpool in mc.agent_pool_profiles:
55705572
# Check if agentpool is in ManagedSystem mode and handle special case
5571-
if agentpool.mode == CONST_NODEPOOL_MODE_MANAGEDSYSTEM:
5572-
# Make sure all other attributes are None
5573-
# Check properties sub-model first (AgentPool), then flat fields (ManagedClusterAgentPoolProfile)
5574-
props = getattr(agentpool, 'properties', None)
5575-
if props is not None and hasattr(props, '_attr_to_rest_field'):
5576-
target, fields = props, props._attr_to_rest_field
5577-
elif hasattr(agentpool, '_attr_to_rest_field') and 'mode' in agentpool._attr_to_rest_field:
5578-
target, fields = agentpool, agentpool._attr_to_rest_field
5573+
if agentpool.mode != CONST_NODEPOOL_MODE_MANAGEDSYSTEM:
5574+
continue
5575+
# Make sure all other attributes are None
5576+
# Check properties sub-model first (AgentPool), then flat fields (ManagedClusterAgentPoolProfile)
5577+
props = getattr(agentpool, 'properties', None)
5578+
rest_fields = getattr(props, '_attr_to_rest_field', None) if props is not None else None
5579+
if rest_fields is not None:
5580+
target, fields = props, rest_fields
5581+
else:
5582+
rest_fields = getattr(agentpool, '_attr_to_rest_field', None)
5583+
if rest_fields is not None and 'mode' in rest_fields:
5584+
target, fields = agentpool, rest_fields
55795585
else:
55805586
target, fields = None, None
5581-
if target is not None:
5582-
for attr in list(fields.keys()):
5583-
if attr not in ('name', 'mode'):
5584-
setattr(agentpool, attr, None)
5585-
else:
5586-
for attr in vars(agentpool):
5587-
if attr != 'name' and attr != 'mode' and not attr.startswith('_'):
5588-
if hasattr(agentpool, attr):
5589-
setattr(agentpool, attr, None)
5587+
if target is not None:
5588+
for attr in list(fields.keys()):
5589+
if attr not in ('name', 'mode'):
5590+
setattr(agentpool, attr, None)
5591+
else:
5592+
for attr in vars(agentpool):
5593+
if attr not in ('name', 'mode') and not attr.startswith('_') and hasattr(agentpool, attr):
5594+
setattr(agentpool, attr, None)
55905595
return mc
55915596

55925597
def init_models(self) -> None:
@@ -6807,7 +6812,8 @@ def update_azure_monitor_profile(self, mc: ManagedCluster) -> ManagedCluster:
68076812
)
68086813

68096814
# Configure OpenTelemetry logs with custom port if provided
6810-
otlp_logs_config = self.models.ManagedClusterAzureMonitorProfileAppMonitoringOpenTelemetryLogsAndTraces(enabled=True)
6815+
otel_logs_cls = self.models.ManagedClusterAzureMonitorProfileAppMonitoringOpenTelemetryLogsAndTraces
6816+
otlp_logs_config = otel_logs_cls(enabled=True)
68116817
if self.context.get_opentelemetry_logs_port():
68126818
otlp_logs_config.http_port = self.context.get_opentelemetry_logs_port()
68136819

0 commit comments

Comments
 (0)