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

feat: support load balancer connections COMPASS-4898 #2326

Merged
merged 4 commits into from Jul 7, 2021
Merged

Conversation

addaleax
Copy link
Contributor

@addaleax addaleax commented Jul 6, 2021

Pending a driver update to include NODE-3011, this should give
us what we need to support load balanced connections (specifically,
I tested this against the current state of that PR and it works).

Description

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@addaleax
Copy link
Contributor Author

addaleax commented Jul 6, 2021

I'm taking ideas for how to add tests here, if anybody has any :)

@addaleax addaleax changed the title feat: support load ablancer conenctions COMPASS-4898 feat: support load balancer connections COMPASS-4898 Jul 6, 2021
Pending a driver update to include NODE-3011, this should give
us what we need to support load balanced connections (specifically,
I tested this against the current state of that PR and it works).
@@ -1046,14 +1048,23 @@ Connection = AmpersandModel.extend({
const parseConnectionStringAsPromise = promisify(parseConnectionString);

async function createConnectionFromUrl(url) {
// We use resolveMongodbSrv because it understands the load balancer
// option, whereas parseConnectionString from the 3.6 driver does not.
// This could potentially go away once we're using the 3.7 driver,
Copy link
Contributor

@mcasimir mcasimir Jul 7, 2021

Choose a reason for hiding this comment

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

// This could potentially go away once we're using the 3.7 driver,

4.x would work directly with this right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no parseOptions like the one we use here in the 4.x driver, otherwise we would use it :)

@@ -1046,14 +1048,23 @@ Connection = AmpersandModel.extend({
const parseConnectionStringAsPromise = promisify(parseConnectionString);

async function createConnectionFromUrl(url) {
// We use resolveMongodbSrv because it understands the load balancer
Copy link
Contributor

@mcasimir mcasimir Jul 7, 2021

Choose a reason for hiding this comment

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

What was happening with "mongo3" here, did we get an error or just the loadBalanced=true was not added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we get an error because it rejects the unknown option.

Copy link
Contributor

@mcasimir mcasimir left a comment

Choose a reason for hiding this comment

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

Do we also need to support loadBalanced as connection param?

Copy link
Contributor

@mcasimir mcasimir left a comment

Choose a reason for hiding this comment

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

The SRV resolution we get in Compass is a side effect of a driver change in the parseConnectionString (when srv+mongodb support has been added) and causes more chaos than what's useful for.

If the old parseConnectionString just don’t understand loadBalanced but don’t error either, maybe we could keep everything as it is for now, at least in the meanwhile we are debugging the other connectivity issues.

Or … since we finally are changing this parseConnectionString to ConnectionString maybe is also time to drop it entirely, if @mmarcon is ok with that.

@mmarcon
Copy link
Member

mmarcon commented Jul 7, 2021

I don't have enough context to recommend one option vs the other. Please choose the option you think is best.

@mcasimir
Copy link
Contributor

mcasimir commented Jul 7, 2021

I don't have enough context to recommend one option vs the other. Please choose the option you think is best.

@mmarcon If we don't parse SRV the list of host in the sidebar won't be populated with the actual hostnames for srv records. If that's important maybe we should keep the resolution for now and we could just move it to a place that does not interfere with the connection later. Though that's something we may want to do in future with a bit more calm.

@addaleax
Copy link
Contributor Author

addaleax commented Jul 7, 2021

Do we also need to support loadBalanced as connection param?

Err yeah, I think we probably should, thanks for pointing it out 👍

I don't have enough context to recommend one option vs the other. Please choose the option you think is best.

@mmarcon If we don't parse SRV the list of host in the sidebar won't be populated with the actual hostnames for srv records. If that's important maybe we should keep the resolution for now and we could just move it to a place that does not interfere with the connection later. Though that's something we may want to do in future with a bit more calm.

Yeah, I think we actually should skip displaying the actual hostnames here – but I’d probably leave that for when we move our usage of the 3.x driver option parsing.

@mcasimir
Copy link
Contributor

mcasimir commented Jul 7, 2021

Do we also need to support loadBalanced as connection param?

Err yeah, I think we probably should, thanks for pointing it out 👍

I don't have enough context to recommend one option vs the other. Please choose the option you think is best.

@mmarcon If we don't parse SRV the list of host in the sidebar won't be populated with the actual hostnames for srv records. If that's important maybe we should keep the resolution for now and we could just move it to a place that does not interfere with the connection later. Though that's something we may want to do in future with a bit more calm.

Yeah, I think we actually should skip displaying the actual hostnames here – but I’d probably leave that for when we move our usage of the 3.x driver option parsing.

Yeah that's a good point, probably the format is very different. What was happening before we did this? const resolvedUrl = await resolveMongodbSrv(unescapedUrl); does 3.x just errors with srv records with loadbalancer?

@addaleax
Copy link
Contributor Author

addaleax commented Jul 7, 2021

`` does 3.x just errors with srv records with loadbalancer?

Yes.

@mmarcon
Copy link
Member

mmarcon commented Jul 7, 2021

If we don't parse SRV the list of host in the sidebar won't be populated with the actual hostnames for srv records. If that's important maybe we should keep the resolution for now and we could just move it to a place that does not interfere with the connection later. Though that's something we may want to do in future with a bit more calm.

@mcasimir I think it's an acceptable compromise. Let's make a ticket to bring it back in the near future.
Can we make sure that if there is no list of hosts there, then the HOSTS title is hidden?

@addaleax
Copy link
Contributor Author

addaleax commented Jul 7, 2021

This is how the sidebar looks now:

Screenshot 2021-07-07 at 14 14 38

@addaleax addaleax merged commit 4146ed1 into main Jul 7, 2021
@addaleax addaleax deleted the 4898-dev branch July 7, 2021 13:01
Copy link

@Baoanh217 Baoanh217 left a comment

Choose a reason for hiding this comment

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

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants