Upgrade Guide
Major version can only be upgraded incrementally from immediate previous major version, i.e. from N to N+1.
v5 to v6
v6 introduced following backward incompatible changes
Redis is required. Redis connection is moved from
sms.throttle.clientOptions
andemail.throttle.clientOptions
toqueue.connection
. Update file src/config.local.[json|js|ts] from, for example,module.exports = { // ... sms: { throttle: { // ... datastore: 'ioredis', clientOptions: { host: '127.0.0.1', port: 6379, }, }, }, // ... email: { throttle: { // ... datastore: 'ioredis', clientOptions: { host: '127.0.0.1', port: 6379, }, }, }, };
to
module.exports = { // ... sms: { throttle: { // ... }, }, // ... email: { throttle: { // ... }, }, queue: { connection: { host: '127.0.0.1', port: 6379, }, }, };
If you deployed NotifyBC using Helm and haven't customized Redis connection in file src/config.local.[json|js|ts], this change is taken care of.
config
minTime
inemail.throttle
andsms.Throttle
is replaced withmax
andduration
. Effectively minTime=duration/max. By defaultmax
is 4 andduration
is 1000, equivalent to defaultminTime
of 250.Terms for node roles have changed. If you defined environment variable NOTIFYBC_NODE_ROLE with value other than slave, remove the environment variable; otherwise change it to secondary. If you deployed NotifyBC using Helm, this change is taken care of.
config
notification.broadcastSubRequestBatchSize
is deprecated. If you defined it in src/config.local.js, remove it.Bitnami MongoDB Helm chart is updated from version 14.3.2 to 16.3.3, with corresponding MongoDB from 7.0.4 to 8.0.4. If you deployed NotifyBC using Helm, or if you are running MongoDB 7 and planning to upgrade to MongoDB 8, follow Upgrade 7.0 to 8.0. In particular, ensure
setFeatureCompatibilityVersion
is set to7.0
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) db.adminCommand( { setFeatureCompatibilityVersion: "7.0" } )
Default SMTP service is changed from localhost to Ethereal. Make sure to setup SMTP in production if haven't done so.
After above changes are addressed, to upgrade NotifyBC to v6,
if NotifyBC is deployed from source code, run
git pull git checkout tags/v6.x.x npm i && npm run build
Replace
- v6.x.x with a v6 release, preferably latest, found in GitHub such as v6.0.2.
if NotifyBC is deployed to Kubernetes using Helm,
- backup MongoDB database
- runReplace
git pull git checkout tags/v6.x.x helm upgrade <release-name> -f helm/platform-specific/<platform>.yaml -f helm/values.local.yaml helm
- v6.x.x with a v6 release, preferably latest, found in GitHub such as v6.0.2.
- <release-name> with installed helm release name
- <platform> with openshift or aks depending on your platform
v4 to v5
v5 introduced following backward incompatible changes
Replica set is required for MongoDB. If you deployed NotifyBC using Helm, replica set is already enabled by default.
If you use default in-memory database, data in server/database/data.json will not be migrated automatically. Manually migrate if necessary.
Update file src/datasources/db.datasource.local.[json|js|ts]
- rename url property to uri
- for other properties, instead of following LoopBack MongoDB data source, follow Mongoose connection options. In particular, host, port and database properties are no longer supported. Use uri instead.
For example, change
{ "name": "db", "connector": "mongodb", "url": "mongodb://127.0.0.1:27017/notifyBC" }
to
{ "uri": "mongodb://127.0.0.1:27017/notifyBC" }
If you deployed NotifyBC using Helm, this is taken care of.
API querying operators have changed. Replace following Loopback operators with corresponding MongoDB operators at your client-side API call.
Loopback operators MongoDB operators eq $eq and $and or $or gt, gte $gt, $gte lt, lte $lt, $lte between (no equivalent, replace with $gt, $and and $lt) inq, nin $in, $nin near $near neq $ne like, nlike (replace with $regexp) like, nlike, options: i (replace with $regexp) regexp $regex API order filter syntax has changed. Replace syntax from Loopback to Mongoose at client-side API call. For example, if your client-side code generates following API call
GET http://localhost:3000/api/configurations?filter={"order":["serviceName asc"]}
change to either
GET http://localhost:3000/api/configurations?filter={"order":[["serviceName","asc"]]}
or
GET http://localhost:3000/api/configurations?filter={"order":"serviceName"}
In MongoDB administrator collection, email has changed from case-sensitively unique to case-insensitively unique. Make sure administrator emails differ not just by case.
When a subscription is created by anonymous user, the data field is preserved. In earlier versions this field is deleted.
Dynamic tokens in subscription confirmation request message and duplicated subscription message are not replaced with subscription data, for example {subscription::...} tokens are left unchanged. Update the template of the two messages if dynamic tokens in them depends on subscription data.
Inbound SMTP Server no longer accepts command line arguments or environment variables as inputs. All inputs have to be defined in config files shown in the link.
If you deployed NotifyBC using Helm, change MongoDB password format in your local values yaml file from
# in file helm/values.local.yaml mongodb: auth: rootPassword: <secret> replicaSetKey: <secret> password: <secret>
to
# in file helm/values.local.yaml mongodb: auth: rootPassword: <secret> replicaSetKey: <secret> passwords: - <secret>
After above changes are addressed, to upgrade NotifyBC to v5,
if NotifyBC is deployed from source code, run
git pull git checkout tags/v5.x.x npm i && npm run build
Replace
- v5.x.x with a v6 release, preferably latest, found in GitHub such as v5.0.0.
if NotifyBC is deployed to Kubernetes using Helm,
- backup MongoDB database
- runReplace <release-name> with installed helm release name
helm uninstall <release-name>
- delete PVCs used by MongoDB stateful set
- runReplace
git pull git checkout tags/v5.x.x helm install <release-name> -f helm/platform-specific/<platform>.yaml -f helm/values.local.yaml helm
- v5.x.x with a v5 release, preferably latest, found in GitHub such as v5.0.0.
- <release-name> with installed helm release name
- <platform> with openshift or aks depending on your platform
- restore MongoDB database
v3 to v4
v4 introduced following backward incompatible changes that need to be addressed in this order
The precedence of config, middleware and datasource files has been changed. Local file takes higher precedence than environment specific file. For example, for config file, the new precedence in ascending order is
- default file src/config.ts
- environment specific file src/config.<env>.js, where <env> is determined by environment variable NODE_ENV
- local file src/config.local.js
To upgrade, if you have environment specific file, merge its content into the local file, then delete it.
Config smtp is changed to email.smtp. See SMTP for example.
Config inboundSmtpServer is changed to email.inboundSmtpServer. See Inbound SMTP Server for example.
Config email.inboundSmtpServer.bounce is changed to email.bounce. See Bounce for example.
Config notification.handleBounce is changed to email.bounce.enabled.
Config notification.handleListUnsubscribeByEmail is changed to email.listUnsubscribeByEmail.enabled. See List-unsubscribe by Email for example.
Config smsServiceProvider is changed to sms.provider. See Provider for example.
SMS service provider specific settings defined in config sms are changed to sms.providerSettings. See Provider Settings for example. The config object sms now encapsulates all SMS configs - provider, providerSettings and throttle.
Legacy config subscription.unsubscriptionEmailDomain is removed. If you have it defined in your file src/config.local.js, replace with email.inboundSmtpServer.domain.
Helm chart added Redis that requires authentication by default. Create a new password in helm/values.local.yaml to facilitate upgrading
# in file helm/values.local.yaml
redis:
auth:
password: '<secret>'
After above changes are addressed, upgrading to v4 is as simple as
git pull
git checkout tags/v4.x.x
npm i && npm run build
or, if NotifyBC is deployed to Kubernetes using Helm.
git pull
git checkout tags/v4.x.x
helm upgrade <release-name> -f helm/platform-specific/<platform>.yaml -f helm/values.local.yaml helm
Replace v4.x.x with a v4 release, preferably latest, found in GitHub such as v4.0.0.
v2 to v3
v3 introduced following backward incompatible changes
- Changed output-only fields failedDispatches and successDispatches to dispatch.failed and dispatch.successful respectively in Notification api. If your client app depends on the fields, change accordingly.
- Changed config notification.logSuccessfulBroadcastDispatches to notification.guaranteedBroadcastPushDispatchProcessing and reversed default value from false to true. If you don't want NotifyBC guarantees processing all subscriptions to a broadcast push notification in a node failure resilient way, perhaps for performance reason, set the value to false in file src/config.local.js.
After above changes are addressed, upgrading to v3 is as simple as
git pull
git checkout tags/v3.x.x
npm i && npm run build
or, if NotifyBC is deployed to Kubernetes using Helm.
git pull
git checkout tags/v3.x.x
helm upgrade <release-name> -f helm/platform-specific/<platform>.yaml -f helm/values.local.yaml helm
Replace v3.x.x with a v3 release, preferably latest, found in GitHub such as v3.1.2.
OpenShift template to Helm
Upgrading NotifyBC on OpenShift created from OpenShift template to Helm involves 2 steps
Customize and install Helm chart
Follow customizations to create file helm/values.local.yaml containing customized configs such as
- notify-bc configMap
- web route host name and certificates
Then run helm install
with documented arguments to install a release.
Migrate MongoDB data
backup data from source
oc exec -i <mongodb-pod> -- bash -c 'mongodump -u "$MONGODB_USER" \ -p "$MONGODB_PASSWORD" -d $MONGODB_DATABASE --gzip --archive' > notify-bc.gz
replace <mongodb-pod> with the mongodb pod name.
restore backup to target
cat notify-bc.gz | oc exec -i <mongodb-pod-0> -- \ bash -c 'mongorestore -u "$MONGODB_USERNAME" -p"$MONGODB_PASSWORD" \ --uri="mongodb://$K8S_SERVICE_NAME" --db $MONGODB_DATABASE --gzip --drop --archive'
replace <mongodb-pod-0> with the first pod name in the mongodb stateful set.
If both source and target are in the same OpenShift cluster, the two operations can be combined into one
oc exec -i <mongodb-pod> -- bash -c 'mongodump -u "$MONGODB_USER" \
-p "$MONGODB_PASSWORD" -d $MONGODB_DATABASE --gzip --archive' | \
oc exec -i <mongodb-pod-0> -- bash -c \
'mongorestore -u "$MONGODB_USERNAME" -p"$MONGODB_PASSWORD" \
--uri="mongodb://$K8S_SERVICE_NAME" --db $MONGODB_DATABASE --gzip --drop --archive'
v1 to v2
Upgrading NotifyBC from v1 to v2 involves two steps
Update your client code
NotifyBC v2 introduced backward incompatible API changes documented in the rest of this section. If your client code will be impacted by the changes, update your code to address the incompatibility first.
Query parameter array syntax
In v1 array can be specified in query parameter using two formats
- by enclosing array elements in square brackets such as
&additionalServices=["s1","s2]
in one query parameter - by repeating the query parameters, for example
&additionalServices=s1&additionalServices=s2
In v2 only the latter format is supported.
Date-Time fields
In v1 date-time fields can be specified in date-only string such as 2020-01-01. In v2 the field must be specified in ISO 8601 extended format such as 2020-01-01T00:00:00Z.
Return status codes
HTTP response code of success calls to following APIs are changed from 200 to 204
- most PATCH by id requests except for Update a Subscription
- most PUT by id requests except for Replace a Subscription
- most DELETE by id requests except for Delete a Subscription (unsubscribing)
Administrator API
- Password is saved to Administrator in v1 and UserCredential in v2. Password is not migrated. New password has to be created by following Create/Update an Administrator's UserCredential .
- Complexity rules have been applied to passwords.
- login API is open to non-admin
Upgrade NotifyBC server
The procedure to upgrade from v1 to v2 depends on how v1 was installed.
Source-code Installation
- Stop NotifyBC
- Backup app root and database!
- Make sure current branch is tracking correct remote branch
git remote set-url origin https://github.com/bcgov/NotifyBC.git git branch -u origin/main
- Make a note of any extra packages added to package.json
- Run
git pull && git checkout tags/v2.x.x
from app root, replace v2.x.x with a v2 release, preferably latest, found in GitHub such as v2.9.0. - Make sure version property in package.json is 2.x.x
- Add back extra packages noted in step 4
- Move server/config.(local|dev|production).(js|json) to src/ if exists
- Move server/datasources.(local|dev|production).(js|json) to src/datasources/db.datasource.(local|dev|production).(js|json) if exists. Notice the file name has changed.
- Move server/middleware.*.(js|json) to src/ if exists. Reorganize top level properties to all or apiOnly, where all applies to all requests including web console and apiOnly applies to API requests only. For example, given
module.exports = {
initial: {
compression: {},
},
'routes:before': {
morgan: {
enabled: false,
},
},
};
if compression middleware will be applied to all requests and morgan will be applied to API requests only, then change the file to
module.exports = {
all: {
compression: {},
},
apiOnly: {
morgan: {
enabled: false,
},
},
};
- Run
npm i && npm run build
- Start server by running
npm run start
or Windows Service
OpenShift Installation
Run
git clone https://github.com/bcgov/NotifyBC.git cd NotifyBC
Run
oc delete bc/notify-bc oc process -f .openshift-templates/notify-bc-build.yml | oc create -f-
ignore AlreadyExists errors
Follow OpenShift Build
For each environment,
run
oc project <yourprojectname-<env>> oc delete dc/notify-bc-app dc/notify-bc-cron oc process -f .openshift-templates/notify-bc.yml | oc create -f-
ignore AlreadyExists errors
copy value of environment variable MONGODB_USER from mongodb deployment config to the same environment variable of deployment config notify-bc-app and notify-bc-cron, replacing existing value
remove middleware.local.json from configMap notify-bc
add middleware.local.js to configMap notify-bc with following content
module.exports = { apiOnly: { morgan: { enabled: false, }, }, };
Follow OpenShift Deploy or Change Propagation to tag image