@@ -28,11 +28,11 @@ class AutoscalerService {
2828 { operationName : 'isAKSCluster' , maxRetries : 1 }
2929 ) ;
3030
31- if ( nodesResponse . body . items . length === 0 ) {
31+ if ( nodesResponse . items . length === 0 ) {
3232 return false ;
3333 }
3434
35- const node = nodesResponse . body . items [ 0 ] ;
35+ const node = nodesResponse . items [ 0 ] ;
3636 const labels = node . metadata ?. labels || { } ;
3737 const providerID = node . spec ?. providerID || '' ;
3838
@@ -65,7 +65,7 @@ class AutoscalerService {
6565 // Count unique node pools (agentpools) that have autoscaling enabled
6666 const autoscalingNodePools = new Set < string > ( ) ;
6767
68- for ( const node of nodesResponse . body . items ) {
68+ for ( const node of nodesResponse . items ) {
6969 const labels = node . metadata ?. labels || { } ;
7070
7171 // AKS labels autoscaler-enabled nodes with this label
@@ -127,23 +127,19 @@ class AutoscalerService {
127127
128128 // Fallback: Look for cluster-autoscaler deployment
129129 const deploymentsResponse = await withRetry (
130- ( ) => this . appsV1Api . listNamespacedDeployment (
131- 'kube-system' ,
132- undefined ,
133- undefined ,
134- undefined ,
135- undefined ,
136- 'app=cluster-autoscaler'
137- ) ,
130+ ( ) => this . appsV1Api . listNamespacedDeployment ( {
131+ namespace : 'kube-system' ,
132+ labelSelector : 'app=cluster-autoscaler' ,
133+ } ) ,
138134 { operationName : 'detectClusterAutoscalerDeployment' , maxRetries : 1 }
139135 ) ;
140136
141- const deployments = deploymentsResponse . body . items ;
137+ const deployments = deploymentsResponse . items ;
142138
143139 if ( deployments . length === 0 ) {
144140 // Try without label selector
145- const allDeployments = await this . appsV1Api . listNamespacedDeployment ( 'kube-system' ) ;
146- const caDeployment = allDeployments . body . items . find (
141+ const allDeployments = await this . appsV1Api . listNamespacedDeployment ( { namespace : 'kube-system' } ) ;
142+ const caDeployment = allDeployments . items . find (
147143 d => d . metadata ?. name ?. includes ( 'cluster-autoscaler' )
148144 ) ;
149145
@@ -181,14 +177,14 @@ class AutoscalerService {
181177 async getAutoscalerStatus ( ) : Promise < AutoscalerStatusInfo | null > {
182178 try {
183179 const configMapResponse = await withRetry (
184- ( ) => this . coreV1Api . readNamespacedConfigMap (
185- 'cluster-autoscaler-status' ,
186- 'kube-system'
187- ) ,
180+ ( ) => this . coreV1Api . readNamespacedConfigMap ( {
181+ name : 'cluster-autoscaler-status' ,
182+ namespace : 'kube-system' ,
183+ } ) ,
188184 { operationName : 'getAutoscalerStatus' , maxRetries : 1 }
189185 ) ;
190186
191- const configMap = configMapResponse . body ;
187+ const configMap = configMapResponse ;
192188 const statusData = configMap . data ?. [ 'status' ] || '{}' ;
193189
194190 let parsedStatus : any ;
0 commit comments