Skip to content

Conversation

@andrewsignori-aot
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot commented Jun 7, 2023

While using the standalone mode (local development only) the configuration used was meant to be used by ioredis client but it was configured to use redis client. For reference only, this is the method on the Typeorm source code where the initialization of the specific client happens: https://github.com/typeorm/typeorm/blob/master/src/cache/RedisQueryResultCache.ts#L50
This is the Typeorm documention that states that the connection can happen using redis or ioredis client: https://orkhan.gitbook.io/typeorm/docs/caching

Expected by redis client

As shown below, the redis client requires a socket configuration. because the information about the host/port was not properly provided to redis client the connectivity was established on localhost:6379 by default, which explains why it was working from our localhost ad failing from the docker-compose.
redis client configuration options: https://github.com/redis/node-redis/blob/master/docs/client-configuration.md

 if (config.redis.redisStandaloneMode) {
  return {
    type: "redis",
    options: {
      socket: {
        host: config.redis.redisHost,
        port: config.redis.redisPort,
      },
      password: config.redis.redisPassword,
    },
    duration: ORM_CACHE_LIFETIME,
  };
}

Expected by ioredis client

ioredis configuration options: https://github.com/luin/ioredis/blob/v4/API.md#new-redisport-host-options

if (config.redis.redisStandaloneMode) {
  return {
    type: "ioredis",
    options: {
      host: config.redis.redisHost,
      port: config.redis.redisPort,
      password: config.redis.redisPassword,
    },
    duration: ORM_CACHE_LIFETIME,
  };
}

Why use ioredis client?

ioredis is also a Bull Queue framework dependency and it is also already used for the cluster mode, so it seems better to just use the same client for the standalone connection.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 17.92% ( 2092 / 11673 )
Methods: 8.23% ( 123 / 1494 )
Lines: 20.7% ( 1833 / 8854 )
Branches: 10.26% ( 136 / 1325 )

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 49.81% ( 267 / 536 )
Methods: 41.56% ( 32 / 77 )
Lines: 55.33% ( 218 / 394 )
Branches: 26.15% ( 17 / 65 )

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 69.4% ( 390 / 562 )
Methods: 59.15% ( 42 / 71 )
Lines: 71.52% ( 344 / 481 )
Branches: 40% ( 4 / 10 )

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

E2E SIMS API Coverage Report

Totals Coverage
Statements: 43.54% ( 3042 / 6986 )
Methods: 37.65% ( 340 / 903 )
Lines: 48.62% ( 2535 / 5214 )
Branches: 19.22% ( 167 / 869 )

@andrewsignori-aot andrewsignori-aot marked this pull request as ready for review June 7, 2023 02:22
@andrewsignori-aot andrewsignori-aot self-assigned this Jun 7, 2023
@andrewsignori-aot andrewsignori-aot added the Bug Something isn't working label Jun 7, 2023
Copy link
Contributor

@andrepestana-aot andrepestana-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Contributor

@ann-aot ann-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good catch

Copy link
Collaborator

@sh16011993 sh16011993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, LGTM 👍

Copy link
Collaborator

@dheepak-aot dheepak-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch and thanks for the fix.

As discussed we can make a recommendation to typeorm to update their documentation as it was misleading.

image

Copy link
Contributor

@guru-aot guru-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find before deploying to prod @andrewsignori-aot :)

@andrewsignori-aot andrewsignori-aot merged commit 0ef3ff9 into main Jun 7, 2023
@andrewsignori-aot andrewsignori-aot deleted the fix/redis-docker-connectivity branch June 7, 2023 18:10
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV June 7, 2023 19:11 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV June 7, 2023 19:28 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV June 7, 2023 19:28 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV June 7, 2023 19:28 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV June 7, 2023 19:28 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV June 7, 2023 19:36 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV June 7, 2023 19:36 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants