Skip to content

Commit d9778b0

Browse files
Merge pull request #3492 from RedisInsight/be/feature/RI-5812
RI-5812, RI-5839 enhance cluster connection
2 parents 8a06a14 + fc25346 commit d9778b0

File tree

5 files changed

+40
-11
lines changed

5 files changed

+40
-11
lines changed

redisinsight/api/config/default.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export default {
100100
retryTimes: parseInt(process.env.RI_CLIENTS_RETRY_TIMES, 10) || 3,
101101
retryDelay: parseInt(process.env.RI_CLIENTS_RETRY_DELAY, 10) || 500,
102102
maxRetriesPerRequest: parseInt(process.env.RI_CLIENTS_MAX_RETRIES_PER_REQUEST, 10) || 1,
103+
slotsRefreshTimeout: parseInt(process.env.RI_CLIENTS_SLOTS_REQUEST_TIMEOUT, 10) || 5000,
103104
},
104105
redis_scan: {
105106
countDefault: parseInt(process.env.RI_SCAN_COUNT_DEFAULT, 10) || 200,

redisinsight/api/src/modules/database/entities/database.entity.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import { CloudDatabaseDetailsEntity } from 'src/modules/cloud/database/entities/
1212
export enum HostingProvider {
1313
RE_CLUSTER = 'RE_CLUSTER',
1414
RE_CLOUD = 'RE_CLOUD',
15-
REDIS_MANAGED = 'REDIS_MANAGED',
15+
REDIS_STACK = 'REDIS_STACK',
16+
REDIS_ENTERPRISE = 'REDIS_ENTERPRISE',
1617
AZURE_CACHE = 'AZURE_CACHE',
1718
AZURE_CACHE_REDIS_ENTERPRISE = 'AZURE_CACHE_REDIS_ENTERPRISE',
18-
COMMUNITY_EDITION = 'COMMUNITY_EDITION',
19+
REDIS_COMMUNITY_EDITION = 'REDIS_COMMUNITY_EDITION',
1920
AWS_ELASTICACHE = 'AWS_ELASTICACHE',
2021
AWS_MEMORYDB = 'AWS_MEMORYDB',
2122
VALKEY = 'VALKEY',
@@ -26,6 +27,7 @@ export enum HostingProvider {
2627
KVROCKS = 'KVROCKS',
2728
REDICT = 'REDICT',
2829
UPSTASH = 'UPSTASH',
30+
UKNOWN_LOCALHOST = 'UKNOWN_LOCALHOST',
2931
UNKNOWN = 'UNKNOWN',
3032
}
3133

redisinsight/api/src/modules/redis/connection/ioredis.redis.connection.strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class IoredisRedisConnectionStrategy extends RedisConnectionStrategy {
8282
): Promise<ClusterOptions> {
8383
return {
8484
clusterRetryStrategy: options.useRetry ? this.retryStrategy.bind(this) : this.dummyFn.bind(this),
85-
slotsRefreshTimeout: 5000,
85+
slotsRefreshTimeout: REDIS_CLIENTS_CONFIG.slotsRefreshTimeout,
8686
redisOptions: await this.getRedisOptions(clientMetadata, database, options),
8787
};
8888
}

redisinsight/api/src/utils/hosting-provider-helper.spec.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { mockStandaloneRedisClient } from 'src/__mocks__';
33
import { getHostingProvider } from './hosting-provider-helper';
44

55
const getHostingProviderTests = [
6-
{ input: '127.0.0.1', output: HostingProvider.COMMUNITY_EDITION },
7-
{ input: '0.0.0.0', output: HostingProvider.COMMUNITY_EDITION },
8-
{ input: 'localhost', output: HostingProvider.COMMUNITY_EDITION },
9-
{ input: '172.18.0.2', output: HostingProvider.COMMUNITY_EDITION },
6+
{ input: '127.0.0.1', output: HostingProvider.UKNOWN_LOCALHOST },
7+
{ input: '0.0.0.0', output: HostingProvider.UKNOWN_LOCALHOST },
8+
{ input: 'localhost', output: HostingProvider.UKNOWN_LOCALHOST },
9+
{ input: '172.18.0.2', output: HostingProvider.UKNOWN_LOCALHOST },
1010
{ input: '176.87.56.244', output: HostingProvider.UNKNOWN },
1111
{ input: '192.12.56.244', output: HostingProvider.UNKNOWN },
1212
{ input: '255.255.56.244', output: HostingProvider.UNKNOWN },
@@ -32,6 +32,24 @@ const getHostingProviderTests = [
3232
{ input: 'contoso5.redis.cache.windows.net', output: HostingProvider.AZURE_CACHE },
3333
{ input: 'contoso5.redisenterprise.cache.azure.net', output: HostingProvider.AZURE_CACHE_REDIS_ENTERPRISE },
3434
{ input: 'demo-redis-provider.unknown.com', output: HostingProvider.UNKNOWN },
35+
{
36+
input: 'localhost',
37+
hello: [
38+
'server', 'redis',
39+
],
40+
info: '#Server\r\n'
41+
+ 'executable:/opt/redis/bin/redis-server',
42+
output: HostingProvider.REDIS_COMMUNITY_EDITION,
43+
},
44+
{
45+
input: 'localhost',
46+
hello: [
47+
'server', 'redis',
48+
],
49+
info: '#Server\r\n'
50+
+ 'executable:/opt/redis-stack/bin/redis-server',
51+
output: HostingProvider.REDIS_STACK,
52+
},
3553
{
3654
input: 'localhost',
3755
hello: [
@@ -45,7 +63,7 @@ const getHostingProviderTests = [
4563
],
4664
info: '#Server\r\n'
4765
+ 'redis_version: 7.2.0',
48-
output: HostingProvider.REDIS_MANAGED,
66+
output: HostingProvider.REDIS_ENTERPRISE,
4967
},
5068
{
5169
input: 'localhost',

redisinsight/api/src/utils/hosting-provider-helper.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const getHostingProvider = async (client: RedisClient, databaseHost: stri
4545
) as string[]).toLowerCase();
4646

4747
if (hello.includes('/enterprise-managed')) {
48-
return HostingProvider.REDIS_MANAGED;
48+
return HostingProvider.REDIS_ENTERPRISE;
4949
}
5050

5151
if (hello.includes('google')) {
@@ -96,17 +96,25 @@ export const getHostingProvider = async (client: RedisClient, databaseHost: stri
9696
if (info.includes('upstash_version')) {
9797
return HostingProvider.UPSTASH;
9898
}
99+
100+
if (info.includes('executable:/opt/redis/bin/redis-server')) {
101+
return HostingProvider.REDIS_COMMUNITY_EDITION;
102+
}
103+
104+
if (info.includes('executable:/opt/redis-stack/bin/redis-server')) {
105+
return HostingProvider.REDIS_STACK;
106+
}
99107
} catch (e) {
100108
// ignore error
101109
}
102110

103111
if (host === '0.0.0.0' || host === 'localhost' || host === '127.0.0.1') {
104-
return HostingProvider.COMMUNITY_EDITION;
112+
return HostingProvider.UKNOWN_LOCALHOST;
105113
}
106114

107115
// todo: investigate weather we need this
108116
if (IP_ADDRESS_REGEX.test(host) && PRIVATE_IP_ADDRESS_REGEX.test(host)) {
109-
return HostingProvider.COMMUNITY_EDITION;
117+
return HostingProvider.UKNOWN_LOCALHOST;
110118
}
111119
} catch (e) {
112120
// ignore any error

0 commit comments

Comments
 (0)