Skip to content

Conversation

@gagik
Copy link
Contributor

@gagik gagik commented Mar 31, 2025

We expose a status for the automerge being enabled/disabled so we'd want it to be shown in sh.status()

This does that in form:

automerge: 
    Currently enabled: yes

};
})(),
(async (): Promise<void> => {
// Is automerge currently enabled, available since >= 7.0
Copy link
Contributor Author

@gagik gagik Mar 31, 2025

Choose a reason for hiding this comment

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

I'm using null scenario to return true to match the mongod behavior. But this is available since 7.0 which means in older versions it'd also similarly say 'yes' which is weird.
The solution to this is to check for the server version and compare with semver but I don't see this being used anywhere

  1. Do we want to introduce this kind of differentiation and hide this field < 7.0?
  2. If yes, what does a server version mean for automerge in sharded cluster? If I understand right it's possible for shards to have i.e. mix of 6.0 and 7.0 Mongo versions, does one get it from i.e. adminDB or something of sort?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering – what does automerge === null correspond to? Is that the case in which we would want to not print this information?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going off https://github.com/mongodb/mongo/blob/a79ad6aa8b026d511227c4ece3d8c80265578831/src/mongo/shell/utils_sh.js#L264 my guess is that the idea here is that automerge wasn't explicitly enabled but it is enabled by default in 7.x+ so they print it out as such

Copy link
Contributor Author

@gagik gagik Mar 31, 2025

Choose a reason for hiding this comment

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

Yeah just confirmed this more or less with start/stop autoMerger is when that'd appear.

We could omit it when the information isn't explicitly set and show only if it has been configured; users looking for it would probably end up starting/stopping automerger so seems reasonable, though a bit of divergence from what we usually do

@gagik gagik marked this pull request as ready for review March 31, 2025 11:32
});
describe('automerge', function () {
it('not shown if sh.status() if not explicitly enabled', async function () {
expect((await sh.status()).value.automerge).is.undefined;
Copy link
Contributor Author

@gagik gagik Apr 1, 2025

Choose a reason for hiding this comment

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

this works but does kind of mess with the sh.status integrity a little as we don't really hide fields beyond that.

I'm unsure how problematic would determining the implicit default status based on the version would be but that seems to be the only other option (or setting the status to 'unknown' but that is also a bit weird and would be shown to a lot of users by default). If we went that route, the version would probably be derived from the admin DB right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we went that route, the version would probably be derived from the admin DB right?

The server version? The only reliable version that clients are supposed to make decisions on is the wire version reported by hello

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm okay, if omitting the field is fine then we could just go with that.
Thinking about it more, it's also a weird precedent to assume that because it's a certain version then lack of a setting means it is some set default from our end

@gagik gagik requested a review from addaleax April 1, 2025 09:37
});
describe('automerge', function () {
it('not shown if sh.status() if not explicitly enabled', async function () {
expect((await sh.status()).value.automerge).is.undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we went that route, the version would probably be derived from the admin DB right?

The server version? The only reliable version that clients are supposed to make decisions on is the wire version reported by hello

@gagik gagik force-pushed the gagik/sh-status branch from cc7cddc to 5615062 Compare April 1, 2025 10:29
gagik added 2 commits April 1, 2025 14:31
It's possible the setting can exist in the cluster we're using so we shouldn't have a test assuming it'd be undefined (and thus not show) for versions >= 7
@gagik gagik merged commit 66c3e61 into main Apr 2, 2025
133 of 135 checks passed
@gagik gagik deleted the gagik/sh-status branch April 2, 2025 14:05
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.

3 participants