Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Migrator could not read the custom configuration file #31

Closed
simonmorgenthaler opened this issue Aug 16, 2021 · 0 comments · Fixed by #32
Closed

Migrator could not read the custom configuration file #31

simonmorgenthaler opened this issue Aug 16, 2021 · 0 comments · Fixed by #32
Assignees
Milestone

Comments

@simonmorgenthaler
Copy link

Expected behavior

If lisk-migrator is started with --lisk-core-path </custom/path/to/lisk-main-2.1.7> it should read /custom/path/to/lisk-main-2.1.7/config.json which contains a section
"components": {
"storage": {
"user": "nonDefaultPgUser"
}
}
to connect to the pg database.

Actual behavior

It does not read the config.json from lisk-core-path but it uses/generates a default config. Because that default config uses the user 'lisk' to connect to the postgresql database, the connection will fail if a different user has been used to set up the database.

Steps to reproduce

  • Install Lisk somewhere non-default, like in /opt/lisk/
  • Setup the postgresql with a different user
  • create a custom config.json with the mentioned storage section and the non-default pg credentials/database
  • Verify that lisk-main-2.1.7 works smoothly with the custom db user, configured in config.json
  • run lisk-migrator --snapshot-height 16270292 --output ~/.lisk/lisk-core/config/mainnet/genesis_block.json --lisk-core-path /opt/lisk/lisk-main-2.1.7
  • See the following error:
    Compiling Lisk Core configuration... done
    Loading Lisk Core configuration... done
    Verifying Lisk-Core version... 2.1.7 detected
    Verifying connection to database "lisk_main"... !
    error: role "lisk" does not exist
    at Parser.parseErrorMessage (/lisk-migrator/node_modules/pg-protocol/dist/parser.js:278:15)
    at Parser.handlePacket (
    /lisk-migrator/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/lisk-migrator/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket. (
    /lisk-migrator/node_modules/pg-protocol/dist/index.js:10:42)

How to fix

I fixed it like this (not sure if that is the "best" solution):
Replace the following line 20 in lisk-migrator/dist/index.js
const config = await config_1.getConfig(liskCorePath);
with this:
const config = await config_1.getConfig(liskCorePath, path_1.join(liskCorePath, 'config.json'));

Which version(s) does this affect? (Environment, OS, etc...)

Migrator 1.0.1, probably also 1.0.0

@nazarhussain nazarhussain changed the title Migrator will fail with custom lisk-main directory, AND a custom 'storage' section (like pg user) in config.json Migrator could not read the custom configuration file Aug 17, 2021
shuse2 added a commit that referenced this issue Aug 17, 2021
Migrator could not read the custom configuration file - Closes #31
@shuse2 shuse2 closed this as completed Aug 17, 2021
@sridharmeganathan sridharmeganathan added this to the Sprint 8 milestone Aug 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants