Skip to content

Commit 6b82274

Browse files
authored
Merge pull request #1117 from mook-as/kube-slow-startup
K8s-engine: assert at least one item in list, not nonzero.
2 parents 806cdd1 + c767f40 commit 6b82274

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/k8s-engine/client.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,15 @@ export class KubeClient extends events.EventEmitter {
243243
// the k3s server must be running. But with wsl we've observed that the service
244244
// watcher needs more time to start up. When this call returns at least one
245245
// service, it's ready.
246-
if ((await this.coreV1API.listServiceForAllNamespaces()).body.items.length === 0) {
246+
try {
247+
const { body } = await this.coreV1API.listServiceForAllNamespaces();
248+
249+
if (!(body.items.length > 0)) {
250+
return null;
251+
}
252+
} catch (ex) {
253+
console.debug(`Error fetching services: ${ ex }`);
254+
247255
return null;
248256
}
249257
this.services = new k8s.ListWatch(

0 commit comments

Comments
 (0)