@@ -5570,15 +5570,23 @@ def update_managed_system_pools(self, mc: ManagedCluster) -> ManagedCluster:
55705570 # Check if agentpool is in ManagedSystem mode and handle special case
55715571 if agentpool .mode == CONST_NODEPOOL_MODE_MANAGEDSYSTEM :
55725572 # Make sure all other attributes are None
5573- # Use _attr_to_rest_field for new SDK models, fall back to vars() for old SDK
5574- field_names = getattr (agentpool , '_attr_to_rest_field' , None )
5575- if field_names is not None :
5576- attrs = list (field_names .keys ())
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
55775579 else :
5578- attrs = [a for a in vars (agentpool ) if not a .startswith ('_' )]
5579- for attr in attrs :
5580- if attr not in ('name' , 'mode' ):
5581- setattr (agentpool , attr , None )
5580+ 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 )
55825590 return mc
55835591
55845592 def init_models (self ) -> None :
0 commit comments