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: check version compatibility with core #236

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export async function createServer() {
host: COUNTRY_CONFIG_HOST,
port: COUNTRY_CONFIG_PORT,
routes: {
cors: { origin: whitelist },
cors: { origin: whitelist, additionalHeaders: ['X-Version'] },
payload: { maxBytes: 52428800, timeout: DEFAULT_TIMEOUT }
}
})
Expand Down Expand Up @@ -533,6 +533,19 @@ export async function createServer() {
type: 'onRequest',
method(request: Hapi.Request & { sentryScope?: any }, h) {
request.sentryScope?.setExtra('payload', request.payload)
const coreVersion = request.headers['x-version']
const countryConfigVersion = process.env.npm_package_version
if (
coreVersion &&
coreVersion !== 'undefined' &&
countryConfigVersion &&
countryConfigVersion !== 'undefined' &&
coreVersion !== countryConfigVersion
) {
const errorMessage = `Version mismatch!! Opencrvs-Core is running on: ${coreVersion}, Opencrvs-Countryconfig is running on: ${countryConfigVersion}`
console.error(errorMessage)
return h.response({ message: errorMessage }).code(426).takeover()
}
Comment on lines +536 to +548
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const coreVersion = request.headers['x-version']
const countryConfigVersion = process.env.npm_package_version
if (
coreVersion &&
coreVersion !== 'undefined' &&
countryConfigVersion &&
countryConfigVersion !== 'undefined' &&
coreVersion !== countryConfigVersion
) {
const errorMessage = `Version mismatch!! Opencrvs-Core is running on: ${coreVersion}, Opencrvs-Countryconfig is running on: ${countryConfigVersion}`
console.error(errorMessage)
return h.response({ message: errorMessage }).code(426).takeover()
}

I'm thinking we could make an assumption here that the client is always up to date as its core's responsibility to verify it. One of our design goals is to hide country config completely behind gateway which would also eliminate this issue

return h.continue
}
})
Expand Down
5 changes: 5 additions & 0 deletions src/translations/client.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ misc.notif.updatePINSuccess,Label for update PIN success notification toast,Your
misc.notif.userAuditSuccess,Label for user audit success notification,"{name} was {action, select, DEACTIVATE {deactivated} REACTIVATE {reactivated} other{deactivated}}","{name} était {action, select, DEACTIVATE {désactivé} REACTIVATE {réactivé} other{désactivé}}"
misc.notif.userFormSuccess,The message that appears in notification when a new user is created,New user created,Nouvel utilisateur créé
misc.notif.userFormUpdateSuccess,The message that appears in notification when user details have been updated,User details have been updated,Les détails de l'utilisateur ont été mis à jour
misc.notif.versionMismatchError,Label for when client version does not match countryConfig,Version Mismatch: Register Client is running on {clientVersion} whereas gateway is running on {gatewayVersion}. Please reload to get the latest client,Incompatibilité de version : le client Register fonctionne sur {clientVersion} tandis que la passerelle fonctionne sur {gatewayVersion}. Veuillez recharger pour obtenir la dernière version du client.
misc.pinMatchError,The error displayed if PINs don't match,PIN code did not match. Please try again.,Le code PIN ne correspond pas. Veuillez réessayer.
misc.pinSameDigitsError,The error displayed if PIN contains 4 same digits.,PIN cannot have same 4 digits,Le code PIN ne peut pas avoir les mêmes 4 chiffres
misc.pinSeqDigitsError,The error displayed if PIN contains sequential digits.,PIN cannot contain sequential digits,Le code PIN ne peut pas contenir de chiffres séquentiels
Expand Down Expand Up @@ -1742,6 +1743,10 @@ register.selectVitalEvent.registerNewEventHeading,The section heading on the pag
register.selectVitalEvent.registerNewEventTitle,The title that appears on the select vital event page,New declaration,Nouvelle déclaration
register.selectinformant.legalGuardian,,Legal guardian,Tuteur légal
register.workQueue.declarations.banner,,Declarations to register in your area,Déclarations à enregistrer dans votre région
reloadmodal.button.notnow,Label for not now button,Not now,Pas maintenant
reloadmodal.button.reload,Label for reload button,Relaod,Recharger
reloadmodal.title.newcontent,Title when new content is available,New content available. Please reload to get the latest client,Nouveau contenu disponible. Veuillez recharger pour obtenir la dernière version du client.
reloadmodal.title.versionMismatch,Title when versions does not match,Version does not match. please refer to the log for more details,La version ne correspond pas. Veuillez consulter le journal pour plus de détails.
review.actions.desc.regConfComp,,"By clicking register, you confirm that the information entered is correct and the vital event can be registered.","En cliquant sur Enregistrer, vous confirmez que les informations sont correctes et ont été vérifiées par l'informateur. L'informateur comprend qu'elles seront utilisées pour enregistrer la naissance et à des fins de planification. En enregistrant cette naissance, un certificat de naissance sera généré avec votre signature pour être délivré."
review.actions.desc.regConfInComp,,Please add mandatory information before registering.,Des informations obligatoires sont manquantes. Veuillez ajouter ces informations afin de pouvoir terminer le processus d'enregistrement.
review.actions.description,,"By clicking register, you confirm that the information entered is correct and the vital event can be registered. ","En vous enregistrant, vous confirmez que vous avez examiné cette déclaration et que vous êtes convaincu qu'elle remplit les conditions requises pour l'enregistrement."
Expand Down
Loading