@@ -63,11 +63,14 @@ class KubernetesClientAdapter {
6363 const kubeApi = this . config . makeApiClient ( k8s . CoreV1Api ) ;
6464
6565 const result = await this . runWithRetries ( retries , "Create Pod" , ( ) =>
66- kubeApi . createNamespacedPod ( this . _namespace , {
67- apiVersion : "v1" ,
68- kind : "Pod" ,
69- metadata,
70- spec
66+ kubeApi . createNamespacedPod ( {
67+ namespace : this . _namespace ,
68+ body : {
69+ apiVersion : "v1" ,
70+ kind : "Pod" ,
71+ metadata,
72+ spec
73+ }
7174 } )
7275 ) ;
7376
@@ -81,7 +84,11 @@ class KubernetesClientAdapter {
8184 const kubeApi = this . config . makeApiClient ( k8s . CoreV1Api ) ;
8285
8386 const result = await this . runWithRetries ( retries , "Delete Pod" , ( ) =>
84- kubeApi . deleteNamespacedPod ( podName , this . _namespace , undefined , undefined , 0 )
87+ kubeApi . deleteNamespacedPod ( {
88+ name : podName ,
89+ namespace : this . _namespace ,
90+ gracePeriodSeconds : 0
91+ } )
8592 ) ;
8693
8794 return result as {
@@ -109,10 +116,13 @@ class KubernetesClientAdapter {
109116 // eslint-disable-next-line no-constant-condition
110117 while ( true ) {
111118 try {
112- const response = await kubeApi . readNamespacedPodStatus ( podName , this . _namespace ) ;
113- const status = response . body . status ?. phase || "" ;
119+ const response = await kubeApi . readNamespacedPodStatus ( {
120+ name : podName ,
121+ namespace : this . _namespace
122+ } ) ;
123+ const status = response . status ?. phase || "" ;
114124
115- const container = ( response . body . status ?. containerStatuses || [ ] ) . find ( c => c . name === podName ) ;
125+ const container = ( response . status ?. containerStatuses || [ ] ) . find ( c => c . name === podName ) ;
116126
117127 if ( expectedStatuses . includes ( status ) ) {
118128 return {
@@ -121,10 +131,10 @@ class KubernetesClientAdapter {
121131 } ;
122132 }
123133 } catch ( err : any ) {
124- if ( err instanceof k8s . HttpError ) {
125- this . logger . error ( `Status for "${ podName } " pod responded with error` , err ?. body ?. message ) ;
134+ if ( err instanceof k8s . FetchError ) {
135+ this . logger . error ( `Status for "${ podName } " pod responded with error` , err ?. message ) ;
126136
127- if ( err . statusCode === 404 ) {
137+ if ( err . errno === " 404" ) {
128138 this . logger . error ( "Pod not found" , podName ) ;
129139 throw Error ( "Pod not found" ) ;
130140 }
@@ -145,31 +155,35 @@ class KubernetesClientAdapter {
145155
146156 async getPodLog ( podName : string ) : Promise < string [ ] > {
147157 const kubeApi = this . config . makeApiClient ( k8s . CoreV1Api ) ;
148- const response = await kubeApi . readNamespacedPodLog (
149- podName , this . _namespace ,
150- undefined , false , undefined , undefined ,
151- undefined , false , undefined ,
152- 100 , true
153- ) ;
154-
155- return [ response . body ] ;
158+ const response = await kubeApi . readNamespacedPodLog ( {
159+ name : podName ,
160+ namespace : this . _namespace ,
161+ follow : false ,
162+ tailLines : 100
163+ } ) ;
164+
165+ return [ response ] ;
156166 }
157167
158168 async getPodTerminatedContainerReason ( podName : string ) : Promise < string | undefined > {
159169 const kubeApi = this . config . makeApiClient ( k8s . CoreV1Api ) ;
160- const response = await kubeApi . readNamespacedPod ( podName , this . _namespace ) ;
170+ const response = await kubeApi . readNamespacedPod ( {
171+ name : podName ,
172+ namespace : this . _namespace
173+ } ) ;
161174
162- return response . body . status ?. containerStatuses ?. [ 0 ] . state ?. terminated ?. reason ;
175+ return response . status ?. containerStatuses ?. [ 0 ] . state ?. terminated ?. reason ;
163176 }
164177
165178 async isPodsLimitReached ( quotaName : string ) {
166179 const kubeApi = this . config . makeApiClient ( k8s . CoreV1Api ) ;
167180
168181 try {
169- const getQuotaPromise =
170- await kubeApi . readNamespacedResourceQuota ( quotaName , this . _namespace ) ;
171-
172- const responseBody = getQuotaPromise . body ;
182+ const responseBody =
183+ await kubeApi . readNamespacedResourceQuota ( {
184+ name : quotaName ,
185+ namespace : this . _namespace
186+ } ) ;
173187
174188 if ( responseBody ) {
175189 const used = parseInt ( responseBody . status ?. used ?. pods || "" , 10 ) || 0 ;
@@ -202,8 +216,8 @@ class KubernetesClientAdapter {
202216
203217 success = true ;
204218 } catch ( err : any ) {
205- if ( err instanceof k8s . HttpError ) {
206- this . logger . error ( `Running "${ name } " responded with error` , err ?. body ?. message ) ;
219+ if ( err instanceof k8s . FetchError ) {
220+ this . logger . error ( `Running "${ name } " responded with error` , err ?. message ) ;
207221 } else {
208222 this . logger . error ( `Failed to run: ${ name } .` , err ) ;
209223 }
0 commit comments