Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions redisinsight/api/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default {
retryTimes: parseInt(process.env.RI_CLIENTS_RETRY_TIMES, 10) || 3,
retryDelay: parseInt(process.env.RI_CLIENTS_RETRY_DELAY, 10) || 500,
maxRetriesPerRequest: parseInt(process.env.RI_CLIENTS_MAX_RETRIES_PER_REQUEST, 10) || 1,
slotsRefreshTimeout: parseInt(process.env.RI_CLIENTS_SLOTS_REQUEST_TIMEOUT, 10) || 5000,
},
redis_scan: {
countDefault: parseInt(process.env.RI_SCAN_COUNT_DEFAULT, 10) || 200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { CloudDatabaseDetailsEntity } from 'src/modules/cloud/database/entities/
export enum HostingProvider {
RE_CLUSTER = 'RE_CLUSTER',
RE_CLOUD = 'RE_CLOUD',
REDIS_MANAGED = 'REDIS_MANAGED',
REDIS_STACK = 'REDIS_STACK',
REDIS_ENTERPRISE = 'REDIS_ENTERPRISE',
AZURE_CACHE = 'AZURE_CACHE',
AZURE_CACHE_REDIS_ENTERPRISE = 'AZURE_CACHE_REDIS_ENTERPRISE',
COMMUNITY_EDITION = 'COMMUNITY_EDITION',
REDIS_COMMUNITY_EDITION = 'REDIS_COMMUNITY_EDITION',
AWS_ELASTICACHE = 'AWS_ELASTICACHE',
AWS_MEMORYDB = 'AWS_MEMORYDB',
VALKEY = 'VALKEY',
Expand All @@ -26,6 +27,7 @@ export enum HostingProvider {
KVROCKS = 'KVROCKS',
REDICT = 'REDICT',
UPSTASH = 'UPSTASH',
UKNOWN_LOCALHOST = 'UKNOWN_LOCALHOST',
UNKNOWN = 'UNKNOWN',
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class IoredisRedisConnectionStrategy extends RedisConnectionStrategy {
): Promise<ClusterOptions> {
return {
clusterRetryStrategy: options.useRetry ? this.retryStrategy.bind(this) : this.dummyFn.bind(this),
slotsRefreshTimeout: 5000,
slotsRefreshTimeout: REDIS_CLIENTS_CONFIG.slotsRefreshTimeout,
redisOptions: await this.getRedisOptions(clientMetadata, database, options),
};
}
Expand Down
28 changes: 23 additions & 5 deletions redisinsight/api/src/utils/hosting-provider-helper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { mockStandaloneRedisClient } from 'src/__mocks__';
import { getHostingProvider } from './hosting-provider-helper';

const getHostingProviderTests = [
{ input: '127.0.0.1', output: HostingProvider.COMMUNITY_EDITION },
{ input: '0.0.0.0', output: HostingProvider.COMMUNITY_EDITION },
{ input: 'localhost', output: HostingProvider.COMMUNITY_EDITION },
{ input: '172.18.0.2', output: HostingProvider.COMMUNITY_EDITION },
{ input: '127.0.0.1', output: HostingProvider.UKNOWN_LOCALHOST },
{ input: '0.0.0.0', output: HostingProvider.UKNOWN_LOCALHOST },
{ input: 'localhost', output: HostingProvider.UKNOWN_LOCALHOST },
{ input: '172.18.0.2', output: HostingProvider.UKNOWN_LOCALHOST },
{ input: '176.87.56.244', output: HostingProvider.UNKNOWN },
{ input: '192.12.56.244', output: HostingProvider.UNKNOWN },
{ input: '255.255.56.244', output: HostingProvider.UNKNOWN },
Expand All @@ -32,6 +32,24 @@ const getHostingProviderTests = [
{ input: 'contoso5.redis.cache.windows.net', output: HostingProvider.AZURE_CACHE },
{ input: 'contoso5.redisenterprise.cache.azure.net', output: HostingProvider.AZURE_CACHE_REDIS_ENTERPRISE },
{ input: 'demo-redis-provider.unknown.com', output: HostingProvider.UNKNOWN },
{
input: 'localhost',
hello: [
'server', 'redis',
],
info: '#Server\r\n'
+ 'executable:/opt/redis/bin/redis-server',
output: HostingProvider.REDIS_COMMUNITY_EDITION,
},
{
input: 'localhost',
hello: [
'server', 'redis',
],
info: '#Server\r\n'
+ 'executable:/opt/redis-stack/bin/redis-server',
output: HostingProvider.REDIS_STACK,
},
{
input: 'localhost',
hello: [
Expand All @@ -45,7 +63,7 @@ const getHostingProviderTests = [
],
info: '#Server\r\n'
+ 'redis_version: 7.2.0',
output: HostingProvider.REDIS_MANAGED,
output: HostingProvider.REDIS_ENTERPRISE,
},
{
input: 'localhost',
Expand Down
14 changes: 11 additions & 3 deletions redisinsight/api/src/utils/hosting-provider-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const getHostingProvider = async (client: RedisClient, databaseHost: stri
) as string[]).toLowerCase();

if (hello.includes('/enterprise-managed')) {
return HostingProvider.REDIS_MANAGED;
return HostingProvider.REDIS_ENTERPRISE;
}

if (hello.includes('google')) {
Expand Down Expand Up @@ -83,17 +83,25 @@ export const getHostingProvider = async (client: RedisClient, databaseHost: stri
if (info.includes('upstash_version')) {
return HostingProvider.UPSTASH;
}

if (info.includes('executable:/opt/redis/bin/redis-server')) {
return HostingProvider.REDIS_COMMUNITY_EDITION;
}

if (info.includes('executable:/opt/redis-stack/bin/redis-server')) {
return HostingProvider.REDIS_STACK;
}
} catch (e) {
// ignore error
}

if (host === '0.0.0.0' || host === 'localhost' || host === '127.0.0.1') {
return HostingProvider.COMMUNITY_EDITION;
return HostingProvider.UKNOWN_LOCALHOST;
}

// todo: investigate weather we need this
if (IP_ADDRESS_REGEX.test(host) && PRIVATE_IP_ADDRESS_REGEX.test(host)) {
return HostingProvider.COMMUNITY_EDITION;
return HostingProvider.UKNOWN_LOCALHOST;
}
} catch (e) {
// ignore any error
Expand Down