@kapeta/local-cluster-service 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.5.2](https://github.com/kapetacom/local-cluster-service/compare/v0.5.1...v0.5.2) (2023-06-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Use internal docker host when inside docker ([#28](https://github.com/kapetacom/local-cluster-service/issues/28)) ([3b0ae9d](https://github.com/kapetacom/local-cluster-service/commit/3b0ae9d7612ae54b38ec8e39f632932f8543206e))
7
+
1
8
  ## [0.5.1](https://github.com/kapetacom/local-cluster-service/compare/v0.5.0...v0.5.1) (2023-06-06)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -134,7 +134,8 @@ router.get('/consumes/resource/:resourceType/:portType/:name', async (req, res)
134
134
  req.kapeta.instanceId,
135
135
  req.params.resourceType,
136
136
  req.params.portType,
137
- req.params.name
137
+ req.params.name,
138
+ req.kapeta.environment
138
139
  );
139
140
 
140
141
  res.send(operatorInfo);
@@ -13,7 +13,7 @@ const LABEL_PORT_PREFIX = 'kapeta_port-';
13
13
 
14
14
  const NANO_SECOND = 1000000;
15
15
  const HEALTH_CHECK_INTERVAL = 2000;
16
- const HEALTH_CHECK_MAX = 20;
16
+ const HEALTH_CHECK_MAX = 30;
17
17
  const IMAGE_PULL_CACHE_TTL = 30 * 60 * 1000;
18
18
  const IMAGE_PULL_CACHE = {};
19
19
 
@@ -349,6 +349,10 @@ class ContainerInfo {
349
349
  this._container = dockerContainer;
350
350
  }
351
351
 
352
+ get native() {
353
+ return this._container;
354
+ }
355
+
352
356
  async isRunning() {
353
357
  const inspectResult = await this.getStatus();
354
358
 
@@ -71,7 +71,7 @@ class OperatorManager {
71
71
  * @param {string} name
72
72
  * @returns {Promise<{host: string, port: (*|string), type: *, protocol: *, credentials: *}>}
73
73
  */
74
- async getResourceInfo(systemId, fromServiceId, resourceType, portType, name) {
74
+ async getResourceInfo(systemId, fromServiceId, resourceType, portType, name, environment) {
75
75
 
76
76
  const operator = this.getOperator(resourceType);
77
77
 
@@ -88,7 +88,7 @@ class OperatorManager {
88
88
  const dbName = name + '_' + fromServiceId.replace(/[^a-z0-9]/gi, '');
89
89
 
90
90
  return {
91
- host: 'localhost',
91
+ host: environment === 'docker' ? 'host.docker.internal' : 'localhost',
92
92
  port: portInfo.hostPort,
93
93
  type: portType,
94
94
  protocol: portInfo.protocol,
@@ -167,6 +167,16 @@ class OperatorManager {
167
167
  });
168
168
  }
169
169
 
170
+ try {
171
+ if (operatorData.health) {
172
+ await containerManager.waitForHealthy(container.native);
173
+ } else {
174
+ await containerManager.waitForReady(container.native);
175
+ }
176
+ } catch (e) {
177
+ console.error(e.message);
178
+ }
179
+
170
180
  return container;
171
181
  }
172
182
  }
@@ -274,10 +274,14 @@ class BlockInstanceRunner {
274
274
  ...dockerOpts
275
275
  });
276
276
 
277
- if (HealthCheck) {
278
- await containerManager.waitForHealthy(container);
279
- } else {
280
- await containerManager.waitForReady(container);
277
+ try {
278
+ if (HealthCheck) {
279
+ await containerManager.waitForHealthy(container);
280
+ } else {
281
+ await containerManager.waitForReady(container);
282
+ }
283
+ } catch (e) {
284
+ logs.addLog(e.message, 'ERROR');
281
285
  }
282
286
 
283
287
  return this._handleContainer(container, logs);
@@ -408,7 +412,11 @@ class BlockInstanceRunner {
408
412
  }
409
413
  });
410
414
 
411
- await containerManager.waitForReady(container);
415
+ try {
416
+ await containerManager.waitForReady(container);
417
+ } catch (e) {
418
+ logs.addLog(e.message, 'ERROR');
419
+ }
412
420
  }
413
421
 
414
422
  return this._handleContainer(container, logs);
@@ -543,10 +551,14 @@ class BlockInstanceRunner {
543
551
  ]
544
552
  });
545
553
 
546
- if (HealthCheck) {
547
- await containerManager.waitForHealthy(container);
548
- } else {
549
- await containerManager.waitForReady(container);
554
+ try {
555
+ if (HealthCheck) {
556
+ await containerManager.waitForHealthy(container);
557
+ } else {
558
+ await containerManager.waitForReady(container);
559
+ }
560
+ } catch (e) {
561
+ logs.addLog(e.message, 'ERROR');
550
562
  }
551
563
  }
552
564