Upgrade a Device Manager 3 pre-release #
The 3-dev line renamed fields that are stored in your data, without compatibility. An installation that ran an earlier 3 pre-release has to be upgraded once, with the migrate-device-manager script.
Applications upgrading from Device Manager 2 follow the v2 migration guide instead.
What changed #
The tenant is the request index (engineId → index) #
Kuzzle only confines a profile to a tenant through the request index: the actions now take the tenant as index.
| Before | After | Data migration |
|---|---|---|
engineId argument of every action | index (HTTP routes unchanged: device-manager/:index/...) | — |
newEngineId argument of assets:migrateTenant | newIndex | — |
engineIds field of tenant-scoped asset and measure models | indexes | Automatic, at startup |
engineId field of the device documents (platform index and tenants) | index | The script |
Requests still sending engineId are refused with Missing argument "index". A cross-tenant call made on behalf of a tenant user is now refused by Kuzzle: run it with the application SDK.
The class of a tenant (engineGroups → tenantClasses) #
| Before | After | Data migration |
|---|---|---|
engineGroups field of the model documents | tenantClasses | The script |
engineGroups argument of the device-manager/models actions | tenantClasses | — |
registerAsset(engineGroups, ...), registerGroup(engineGroups, ...) | Same positional argument, renamed tenantClasses | — |
engineGroups of the API measure targets | tenantClasses | — |
group payload of ask:device-manager:engine:list | tenantClass | — |
engineGroups payload of ask:device-manager:model:asset:get | tenantClasses | — |
The value "commons" (every class) is unchanged, and so are the model document IDs. The engine documents and the device-manager/engine:create and device-manager/engine:update actions still name the tenant class group: they belong to kuzzle-plugin-commons, which multi-tenancy relies on.
Procedure #
Back up the platform index (
device-managerby default) and the tenant indexes:kourou index:export device-managerUpdate your code for the renamed arguments and payloads listed above.
Upgrade the
kuzzle-device-managerdependency and restart Kuzzle. At startup, the plugin adds the new fields to the platform mappings and movesengineIdstoindexeson the models. Until the next step, the devices attached before the upgrade are seen as unattached: their measures are not routed to their tenant, and the models created through the API are not taken into account by the tenants. Run the next step right away, and do not attach, detach or create anything in between.Run the upgrade script with an administrator account:
npx migrate-device-manager --host=localhost --port=7512 --username=admin --password=<password> --dry-run npx migrate-device-manager --host=localhost --port=7512 --username=admin --password=<password>The script:
- refuses to run if the platform mappings have no
tenantClassesorindexfield yet (step 3 not done); - moves
engineGroupstotenantClasseson every model document, and removesengineGroups. When a model already hastenantClasses(models registered by the application at startup), that value is kept; - calls
device-manager/engine:updateon every engine, so the tenant collections get the mappings of the migrated models and the newindexfield of the devices; - moves
engineIdtoindexon the device documents of the platform index and of every tenant, and emptiesengineId. This is a partial update, so the measures ingested meanwhile are kept; - checks that no model still has
engineGroupsand no device only hasengineId.
It can be run again: it then only updates the engines.
- refuses to run if the platform mappings have no
| Option | Environment variable | Default |
|---|---|---|
--host | KUZZLE_HOST | localhost |
--port | KUZZLE_PORT | 7512 |
--protocol (websocket or http) | KUZZLE_PROTOCOL | websocket |
--ssl | KUZZLE_SSL=true | off |
--username, --password | KUZZLE_USERNAME, KUZZLE_PASSWORD | anonymous |
--platform-index | PLATFORM_INDEX | device-manager |
--dry-run | off: lists the changes without writing |
The former fields (engineGroups, engineIds, engineId) stay in the mappings of the existing installations, because Elasticsearch cannot remove a field from a mapping. Nothing reads or writes them anymore.