Skip to content

Commit

Permalink
fix(core): missing check for double removal of unresponsive module (#850
Browse files Browse the repository at this point in the history
)

* fix(core): missing check for double removal of unresponsive module
refactor(core): add sanity check for module existence in monitor loop

* chore: add more logs in module recovery
  • Loading branch information
kkopanidis authored Dec 18, 2023
1 parent 086658f commit 74ba6d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ export class ServiceMonitor {

private async monitorModules() {
for (const module of this._serviceRegistry.getRegisteredModules()) {
const registeredModule = this._serviceRegistry.getModule(module)!;
const registeredModule = this._serviceRegistry.getModule(module);
if (!registeredModule) continue;
try {
await this.healthCheckService(module, registeredModule.address);
} catch (e) {
this.handleUnresponsiveModule(
module,
registeredModule.address,
HealthCheckStatus.SERVICE_UNKNOWN,
);
if (this._serviceRegistry.getModule(module)) {
this.handleUnresponsiveModule(
module,
registeredModule.address,
HealthCheckStatus.SERVICE_UNKNOWN,
);
}
}
}
this.moduleRegister.emit('serving-modules-update');
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/config-manager/service-discovery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export class ServiceDiscovery {
this.grpcSdk.createModuleClient(moduleName, moduleUrl);
}
} catch (e) {
ConduitGrpcSdk.Logger.error(`SD: failed to recover: ${moduleName} ${moduleUrl}`);
ConduitGrpcSdk.Logger.error(`SD: recovery error: ${e}`);
throw new Error('Failed to register unresponsive module');
}
const healthStatus = healthResponse.status as unknown as HealthCheckStatus;
Expand Down

0 comments on commit 74ba6d5

Please sign in to comment.