Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joyc-bq committed Jan 27, 2025
1 parent 3f1852a commit 98c59df
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions common/lib/plugins/efm/host_monitoring_connection_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class HostMonitoringConnectionPlugin extends AbstractConnectionPlugin imp
return result;
}

private throwUnableToIdentifyConnection(host: HostInfo | null, provider: HostListProvider | null): never {
private throwUnableToIdentifyConnection(host: HostInfo | null): never {
throw new AwsWrapperError(
Messages.get(
"HostMonitoringConnectionPlugin.unableToIdentifyConnection",
Expand All @@ -164,17 +164,17 @@ export class HostMonitoringConnectionPlugin extends AbstractConnectionPlugin imp
this.monitoringHostInfo = this.pluginService.getCurrentHostInfo();
const provider: HostListProvider | null = this.pluginService.getHostListProvider();
if (this.monitoringHostInfo == null) {
this.throwUnableToIdentifyConnection(null, provider);
this.throwUnableToIdentifyConnection(null);
}
const rdsUrlType: RdsUrlType = this.rdsUtils.identifyRdsType(this.monitoringHostInfo.url);

try {
if (rdsUrlType.isRdsCluster) {
logger.debug("Monitoring host info is associated with a cluster endpoint, plugin needs to identify the cluster connection");
logger.debug(Messages.get("HostMonitoringConnectionPlugin.identifyClusterConnection"));
this.monitoringHostInfo = await this.pluginService.identifyConnection(this.pluginService.getCurrentClient().targetClient!);
if (this.monitoringHostInfo == null) {
const host: HostInfo | null = this.pluginService.getCurrentHostInfo();
this.throwUnableToIdentifyConnection(host, provider);
this.throwUnableToIdentifyConnection(host);
}
await this.pluginService.fillAliases(this.pluginService.getCurrentClient().targetClient!, this.monitoringHostInfo);
}
Expand Down
2 changes: 1 addition & 1 deletion common/lib/plugins/efm/monitor_connection_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class MonitorConnectionContext {
this.telemetryAbortedConnectionCounter.inc();
} catch (error: any) {
// ignore
logger.debug(Messages.get("MonitorConnectionContext.exceptionAbortingConnection", error.message));
logger.debug(Messages.get("MonitorConnectionContext.errorAbortingConnection", error.message));
}
this.abortedConnectionCounter++;
}
Expand Down
12 changes: 6 additions & 6 deletions common/lib/plugins/efm2/host_monitoring2_connection_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ export class HostMonitoring2ConnectionPlugin extends AbstractConnectionPlugin im
return result;
}

private throwUnableToIdentifyConnection(host: HostInfo | null, provider: HostListProvider | null): never {
private throwUnableToIdentifyConnection(host: HostInfo | null): never {
const provider: HostListProvider | null = this.pluginService.getHostListProvider();
throw new AwsWrapperError(
Messages.get(
"HostMonitoringConnectionPlugin.unableToIdentifyConnection",
Expand All @@ -134,19 +135,18 @@ export class HostMonitoring2ConnectionPlugin extends AbstractConnectionPlugin im
async getMonitoringHostInfo(): Promise<HostInfo> {
if (this.monitoringHostInfo == null) {
this.monitoringHostInfo = this.pluginService.getCurrentHostInfo();
const provider: HostListProvider | null = this.pluginService.getHostListProvider();
if (this.monitoringHostInfo == null) {
this.throwUnableToIdentifyConnection(null, provider);
this.throwUnableToIdentifyConnection(null);
}
const rdsUrlType: RdsUrlType = this.rdsUtils.identifyRdsType(this.monitoringHostInfo.url);

try {
if (rdsUrlType.isRdsCluster) {
logger.debug("Monitoring host info is associated with a cluster endpoint, plugin needs to identify the cluster connection");
logger.debug(Messages.get("HostMonitoringConnectionPlugin.identifyClusterConnection"));
this.monitoringHostInfo = await this.pluginService.identifyConnection(this.pluginService.getCurrentClient().targetClient!);
if (this.monitoringHostInfo == null) {
const host: HostInfo | null = this.pluginService.getCurrentHostInfo();
this.throwUnableToIdentifyConnection(host, provider);
this.throwUnableToIdentifyConnection(host);
}
await this.pluginService.fillAliases(this.pluginService.getCurrentClient().targetClient!, this.monitoringHostInfo);
}
Expand All @@ -165,8 +165,8 @@ export class HostMonitoring2ConnectionPlugin extends AbstractConnectionPlugin im
if (changes.has(HostChangeOptions.HOSTNAME) || changes.has(HostChangeOptions.HOST_CHANGED)) {
// Reset monitoring host info since the associated connection has changed.
this.monitoringHostInfo = null;
return OldConnectionSuggestionAction.NO_OPINION;
}
return OldConnectionSuggestionAction.NO_OPINION;
}

async releaseResources(): Promise<void> {
Expand Down
3 changes: 1 addition & 2 deletions common/lib/plugins/efm2/monitor_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ export class MonitorServiceImpl implements MonitorService {
context.setInactive();
try {
await clientToAbort.abort();
await clientToAbort.end();
this.abortedConnectionsCounter.inc();
} catch (error) {
// ignore
logger.debug(Messages.get("MonitorConnectionContext.exceptionAbortingConnection", error.message));
logger.debug(Messages.get("MonitorConnectionContext.errorAbortingConnection", error.message));
}
} else {
context.setInactive();
Expand Down
3 changes: 2 additions & 1 deletion common/lib/utils/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"SamlAuthPlugin.unhandledException": "Unhandled exception: '%s'",
"HostAvailabilityStrategy.invalidMaxRetries": "Invalid value of '%s' for configuration parameter `hostAvailabilityStrategyMaxRetries`. It must be an integer greater or equal to 1.",
"HostAvailabilityStrategy.invalidInitialBackoffTime": "Invalid value of '%s' for configuration parameter `hostAvailabilityStrategyInitialBackoffTime`. It must be an integer greater or equal to 1.",
"MonitorConnectionContext.exceptionAbortingConnection": "Exception during aborting connection: %s.",
"MonitorConnectionContext.errorAbortingConnection": "Error during aborting connection: %s.",
"MonitorConnectionContext.hostDead": "Host %s is *dead*.",
"MonitorConnectionContext.hostNotResponding": "Host %s is not *responding* with failureCount: %s",
"MonitorConnectionContext.hostAlive": "Host %s is *alive*.",
Expand All @@ -145,6 +145,7 @@
"HostMonitoringConnectionPlugin.unableToIdentifyConnection": "Unable to identify the given connection: '%s', please ensure the correct host list provider is specified. The host list provider in use is: '%s'.",
"HostMonitoringConnectionPlugin.errorIdentifyingConnection": "Error occurred while identifying connection: '%s'.",
"HostMonitoringConnectionPlugin.unavailableHost": "Host '%s' is unavailable.",
"HostMonitoringConnectionPlugin.identifyClusterConnection": "Monitoring host info is associated with a cluster endpoint, plugin needs to identify the cluster connection",
"PluginServiceImpl.failedToRetrieveHostPort": "PluginServiceImpl.failedToRetrieveHostPort",
"AuroraInitialConnectionStrategyPlugin.unsupportedStrategy": "Unsupported host selection strategy '%s'.",
"AuroraInitialConnectionStrategyPlugin.requireDynamicProvider": "Dynamic host list provider is required.",
Expand Down

0 comments on commit 98c59df

Please sign in to comment.