Skip to content

Commit eb6a645

Browse files
ci: [sync] Push chectl @ main to devspaces-chectl @ devspaces-3-rhel-9
Signed-off-by: devspacesbuild <[email protected]>
1 parent 981ec03 commit eb6a645

File tree

4 files changed

+170
-247
lines changed

4 files changed

+170
-247
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
}
117117
},
118118
"dependencies": {
119-
"@kubernetes/client-node": "0.14.3",
119+
"@kubernetes/client-node": "0.22.3",
120120
"@oclif/core": "^3.0.4",
121121
"@oclif/parser": "^3.8.17",
122122
"@oclif/plugin-autocomplete": "^2.3.9",
@@ -127,7 +127,7 @@
127127
"@octokit/rest": "^19.0.5",
128128
"analytics-node": "^6.2.0",
129129
"ansi-colors": "4.1.3",
130-
"axios": "^0.21.1",
130+
"axios": "^1.8.4",
131131
"cli-ux": "^6.0.9",
132132
"command-exists": "^1.2.9",
133133
"countries-and-timezones": "^3.6.0",

src/api/che-logs-reader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class CheLogsReader {
124124
return []
125125
}
126126

127-
return pod.status.containerStatuses.map(containerStatus => containerStatus.name)
127+
return pod.status.containerStatuses.filter(s => s.ready).map(s => s.name)
128128
}
129129

130130
/**

src/api/kube-client.ts

+34-20
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ export class KubeClient {
112112
rejectUnauthorized: false,
113113
requestCert: true,
114114
}),
115-
headers: token && {Authorization: 'bearer ' + token},
115+
}
116+
117+
if (token) {
118+
config.headers = {
119+
Authorization: `Bearer ${token}`,
120+
}
116121
}
117122

118123
const response = await axios.get(`${endpoint}`, config)
@@ -1189,17 +1194,31 @@ export class KubeClient {
11891194

11901195
async listClusterCustomObject(resourceAPIGroup: string, resourceAPIVersion: string, resourcePlural: string): Promise<any[]> {
11911196
const customObjectsApi = this.kubeConfig.makeApiClient(CustomObjectsApi)
1192-
try {
1193-
const {body} = await customObjectsApi.listClusterCustomObject(resourceAPIGroup, resourceAPIVersion, resourcePlural)
1194-
return (body as any).items ? (body as any).items : []
1195-
} catch (e: any) {
1196-
if (e.response && e.response.statusCode === 404) {
1197-
// There is no CRD
1198-
return []
1199-
}
12001197

1201-
throw this.wrapK8sClientError(e)
1198+
for (let attempt = 1; attempt <= 10; attempt++) {
1199+
try {
1200+
const { body } = await customObjectsApi.listClusterCustomObject(
1201+
resourceAPIGroup,
1202+
resourceAPIVersion,
1203+
resourcePlural
1204+
)
1205+
return (body as any).items ? (body as any).items : []
1206+
} catch (e: any) {
1207+
if (e.response?.statusCode === 404) {
1208+
return []
1209+
}
1210+
1211+
const wrappedError = this.wrapK8sClientError(e)
1212+
if (this.isStorageIsReInitializingError(wrappedError)) {
1213+
await ux.wait(1000)
1214+
continue
1215+
}
1216+
1217+
throw wrappedError
1218+
}
12021219
}
1220+
1221+
throw new Error('Exceeded maximum retry attempts to list cluster custom object: storage is (re)initializing')
12031222
}
12041223

12051224
async isCatalogSourceExists(name: string, namespace: string): Promise<boolean> {
@@ -1216,16 +1235,6 @@ export class KubeClient {
12161235
}
12171236
}
12181237

1219-
async listCatalogSource(namespace: string, labelSelector: string): Promise<CatalogSource[]> {
1220-
const customObjectsApi = this.kubeConfig.makeApiClient(CustomObjectsApi)
1221-
try {
1222-
const {body} = await customObjectsApi.listNamespacedCustomObject('operators.coreos.com', 'v1alpha1', namespace, 'catalogsources', undefined, undefined, undefined, labelSelector)
1223-
return (body as any).items as CatalogSource[]
1224-
} catch (e: any) {
1225-
throw this.wrapK8sClientError(e)
1226-
}
1227-
}
1228-
12291238
async getCatalogSource(name: string, namespace: string): Promise<CatalogSource | undefined> {
12301239
const customObjectsApi = this.kubeConfig.makeApiClient(CustomObjectsApi)
12311240
try {
@@ -1914,6 +1923,11 @@ export class KubeClient {
19141923
msg.includes('failed calling webhook') ||
19151924
msg.includes('conversion webhook')
19161925
}
1926+
1927+
private isStorageIsReInitializingError(error: any): boolean {
1928+
const msg = error.message as string
1929+
return msg.includes('storage is (re)initializing') || msg.includes('TooManyRequests')
1930+
}
19171931
}
19181932

19191933
class PatchedK8sAppsApi extends AppsV1Api {

0 commit comments

Comments
 (0)