-
Notifications
You must be signed in to change notification settings - Fork 214
feat(connections): warn then connecting to an end-of-life server COMPASS-9083 #6888
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
Conversation
😬 I just realized (and remembered) that @alenakhineika had already made a draft PR adding this #6805 🙈 I'll pick some of her ideas into this branch (as this has tests) and add a call to the update server. |
export function isEndOfLifeVersion(version: string) { | ||
try { | ||
const [major, minor] = version.split('.').map((part) => parseInt(part, 10)); | ||
return (major === 4 && minor <= 4) || major < 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're already taking this from the buildInfo
output, is there any reason not to use versionArray
directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly that I wasn't aware that this was included in the build info.
Never the less, I expect these lines to go away and instead I'll be using "semver" like Alena did in her PR:
compass/packages/compass-connections/src/stores/connections-store-redux.ts
Lines 1459 to 1470 in f5fffe5
export function isEndOfLifeServer( | |
serverVersion: string | undefined | null | |
): boolean { | |
if (!serverVersion) { | |
return true; | |
} | |
try { | |
return semver.satisfies(serverVersion, `<=${getEoLServerVersion()}`); | |
} catch (e) { | |
return true; | |
} | |
} |
const { HADRON_AUTO_UPDATE_ENDPOINT, HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE } = | ||
process.env; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a better place to put these. Some package intended to share constants across the main and renderer processes.
34b369e
to
c5ab3b2
Compare
…f-life modal everywhere
c5ab3b2
to
b88316c
Compare
@@ -23,6 +23,7 @@ export function showNonGenuineMongoDBWarningModal( | |||
) { | |||
return showConfirmation({ | |||
title: 'Non-Genuine MongoDB Detected', | |||
hideCancelButton: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest hiding the cancel button on this as well, to keep things aligned and because canceling this modal won't stop connecting anyway.
return (_dispatch, getState, { track }) => { | ||
const connectionInfo = getCurrentConnectionInfo(getState(), connectionId); | ||
track('Screen', { name: 'end_of_life_mongodb_modal' }, connectionInfo); | ||
void _showEndOfLifeMongoDBWarningModal(connectionInfo, version); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nit, but I'd personally probably have jumped through hoops to come up with two different names where one showEndOfLifeMongoDBWarningModal is the thunk action creator thingy and one is the function from the component. But I can live with this ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I didn't pay too much attention to naming there as I was mostly copying from the code above:
compass/packages/compass-connections/src/stores/connections-store-redux.ts
Lines 2162 to 2171 in 32e0d30
export const showNonGenuineMongoDBWarningModal = ( | |
connectionId: string | |
): ConnectionsThunkAction<void> => { | |
return (_dispatch, getState, { track }) => { | |
const connectionInfo = getCurrentConnectionInfo(getState(), connectionId); | |
track('Screen', { name: 'non_genuine_mongodb_modal' }, connectionInfo); | |
void _showNonGenuineMongoDBWarningModal(connectionInfo); | |
}; | |
}; | |
latestEndOfLifeServerVersion: string | ||
) { | ||
try { | ||
const coercedVersion = semverCoerce(version); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to understand under which circumstances this would be falsy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the docs:
Only text which lacks digits will fail coercion (
version one
is not valid).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But.. will it throw or be falsy? You seem to be checking/accounting for both and it isn't clear to me that both can happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try-catch is mostly to be extra safe that these calls won't prevent the caller from progressing - if we're unsure, we'll opt on the safe side instead of propagating errors. This also handles if semverSatisfies
or any future code added to the block throws for some reason.
The check for falsy coercedVersion
is the known case of a malformed server version. This is mostly to handle that we might fail to determine a non-genuine server with a malformed version or a future MongoDB version which is not able to coerce, for some unknown reason.
Description
Merging this PR will:
Screen.Recording.2025-05-02.at.10.11.41.mov
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes