Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BB-760 : When elasticsearch configuration is missing, server crashes #1081

Merged
merged 12 commits into from
May 27, 2024

Conversation

Tarunmeena0901
Copy link
Contributor

Problem

BB-760

Solution

As the reason behind the crashing of BB server was the absence of elastic search configuration in our configuration template , I added some checks just before we are initializng the search server in app.js .
Those checks will ensure incase of missing configuration elastic search will still get some hardcoded configuration which will prevent it from crashing on initializing

and also incase of missing configuration error will be logged in console and a warning banner will be displayed on homepage

Screenshot 2024-03-28 001914

Screenshot 2024-03-28 001936

Areas of Impact

  • ./src/server/app.js
  • ./src/api/app.js

Copy link
Contributor

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

Sorry for the long delay!
I have some suggestions to simplify the code a bit and deduplicate some code:

src/api/app.js Outdated Show resolved Hide resolved
src/server/app.js Outdated Show resolved Hide resolved
src/server/app.js Outdated Show resolved Hide resolved
src/server/app.js Outdated Show resolved Hide resolved
src/server/app.js Outdated Show resolved Hide resolved
@Tarunmeena0901
Copy link
Contributor Author

There were some unexpected es lint error not releated to the changes in this PR , but I fixed them too I hope it does no make things confusing for you

@MonkeyDo
Copy link
Contributor

MonkeyDo commented May 27, 2024

There were some unexpected es lint error not releated to the changes in this PR , but I fixed them too I hope it does no make things confusing for you

Thanks for the changes, reviewing now.
For posterity, it's not ideal as it touches a bunch of files that are unrelated.
That being said, the changes in question are so minor that it really isn't an issue to review.

In case it's useful in the future, you can run eslint for specific files instead by passing a file path to the commend:
npx eslint path/to/my/file

Copy link
Contributor

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

Perfect, thanks!

updated configuration options, removing old ones that are not valid anymore
Adding a type to the Elasticsearch client has revealed an issue with our handling of error during bulk indexing, we were using the wrong
@MonkeyDo
Copy link
Contributor

Great solution! One thing I would like to ask: the type you mentioned here {type ClientOptions} from '@elastic/elasticsearch'; doesn't have the properties that options should have like "auth" and "host"

options = {
	auth: { password: 'changeme', username: 'elastic' },
	node: 'http://localhost:9200',
	requestTimeout: 60000,
	host: 'localhost:9200'
};

Thanks for pointing this out!
I took a closer look and indeed the configuration was incorrect> I took the liberty to piggyback on the PR and fix it, since there were a few places to fix it but not very obvious.
While adding the typescript type to the ES client, it also raised a separate issue which I also fixed.

Hope you don't mind my meddling!

@MonkeyDo MonkeyDo merged commit 5a8a0f8 into metabrainz:master May 27, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants