Skip to content

Commit

Permalink
fix(redis): Show a warning on the dashboard if Amazon ElastiCache is …
Browse files Browse the repository at this point in the history
…used as the database
  • Loading branch information
andris9 committed Dec 12, 2023
1 parent 086f1c6 commit 814e724
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/routes-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ function applyRoutes(server, call) {
stats,
counterList,
hasAccounts,

isElastiCache: ['elasticache'].includes(stats.redisSoftware),

redisPing: {
key: 'redisPing',
title: 'Redis Latency',
Expand Down
12 changes: 12 additions & 0 deletions lib/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV3QUiYsp13nD9suD1/ZkEXnuMoSg

let redisVersion;
let softwareDetails;
let redisSoftware;
try {
let redisInfo = await module.exports.getRedisStats(redis);
if (!redisInfo || typeof redisInfo.redis_version !== 'string') {
Expand All @@ -1135,21 +1136,31 @@ MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV3QUiYsp13nD9suD1/ZkEXnuMoSg
// Detect Dragonfly
if (typeof redisInfo.dragonfly_version === 'string') {
softwareDetails = `Dragonfly v${redisInfo.dragonfly_version.replace(/^[^\d]*/, '')}`;
redisSoftware = 'dragonfly';
}

// Detect KeyDB
if (typeof redisInfo.mvcc_depth === 'number') {
softwareDetails = `KeyDB`;
redisSoftware = 'keydb';
}

// Detect Upstash
if (typeof redisInfo.upstash_version === 'string') {
softwareDetails = `Upstash Redis v${redisInfo.upstash_version.replace(/^[^\d]*/, '')}`;
redisSoftware = 'upstash';
}

// Detect Memurai
if (typeof redisInfo.memurai_version === 'string') {
softwareDetails = `${redisInfo.memurai_edition || 'Memurai'} v${redisInfo.memurai_version.replace(/^[^\d]*/, '')}`;
redisSoftware = 'memurai';
}

// Detect ElastiCache
if (/Amazon ElastiCache/i.test(redisInfo.os)) {
softwareDetails = `Amazon ElastiCache`;
redisSoftware = 'elasticache';
}
} catch (err) {
console.log(err);
Expand Down Expand Up @@ -1193,6 +1204,7 @@ MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV3QUiYsp13nD9suD1/ZkEXnuMoSg
accounts: await redis.scard(`${REDIS_PREFIX}ia:accounts`),
node: process.versions.node,
redis: `${redisVersion}${softwareDetails ? ` (${softwareDetails})` : ''}`,
redisSoftware,
imapflow: ImapFlow.version || 'please upgrade',
bullmq: bullmqPackage.version,
arch: process.arch,
Expand Down
21 changes: 20 additions & 1 deletion views/dashboard.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,33 @@
</div>


{{#if isElastiCache}}
<div class="card border-left-danger mt-4">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-danger text-uppercase mb-1">Compatiblity warning
</div>
<p>EmailEngine is incompatible with Amazon ElastiCache as the database backend.</p>
<p>Please switch to a standard Redis instance. Using ElastiCache with EmailEngine can result in data
loss and several functionalities may not work.</p>
</div>
<div class="col-auto">
<i class="fas fa-exclamation-circle fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
{{/if}}


{{#unless hasAccounts}}

<div class="card border-left-success mt-4">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-danger text-uppercase mb-1">Welcome to EmailEngine!
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">Welcome to EmailEngine!
</div>
<p>To start using EmailEngine, add an email account to the <a href="/admin/accounts">account
registry</a>. Once registered, you can access this account to send
Expand Down

0 comments on commit 814e724

Please sign in to comment.