scylladb / care-pet

Care Pet IoT ScyllaDB example
https://care-pet.docs.scylladb.com/
Apache License 2.0
47 stars 28 forks source link

[BUG] JS migrate script does not work (using Docker) #118

Closed zseta closed 2 months ago

zseta commented 1 year ago

Hi there,

I've been following the instructions outlined here. to build this project using JavaScript.

I get stuck when trying to run the migrate script. (I'm using Docker)

npm run migrate -- --hosts 172.24.0.4

Error:

info: Bootstrapping database...
(node:96046) UnhandledPromiseRejectionWarning: ArgumentError: 'localDataCenter' is not defined in Client options and also was not specified in constructor. At least one is required. Available DCs are: [datacenter1]
    at setLocalDc (/home/attila/Documents/stuff/FY23Q1/scylla/care-pet/javascript/node_modules/cassandra-driver/lib/policies/load-balancing.js:860:11)
    at DefaultLoadBalancingPolicy.init (/home/attila/Documents/stuff/FY23Q1/scylla/care-pet/javascript/node_modules/cassandra-driver/lib/policies/load-balancing.js:565:7)
    at /home/attila/Documents/stuff/FY23Q1/scylla/care-pet/javascript/node_modules/cassandra-driver/lib/execution-profile.js:171:55
    at /home/attila/Documents/stuff/FY23Q1/scylla/care-pet/javascript/node_modules/cassandra-driver/lib/promise-utils.js:52:5
    at new Promise (<anonymous>)
    at Object.fromCallback (/home/attila/Documents/stuff/FY23Q1/scylla/care-pet/javascript/node_modules/cassandra-driver/lib/promise-utils.js:51:10)
    at ProfileManager.init (/home/attila/Documents/stuff/FY23Q1/scylla/care-pet/javascript/node_modules/cassandra-driver/lib/execution-profile.js:171:26)
    at Client._connect (/home/attila/Documents/stuff/FY23Q1/scylla/care-pet/javascript/node_modules/cassandra-driver/lib/client.js:515:31)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async getClient (/home/attila/Documents/stuff/FY23Q1/scylla/care-pet/javascript/src/db.js:16:5)
(node:96046) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:96046) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Relevant part (likely): UnhandledPromiseRejectionWarning: ArgumentError: 'localDataCenter' is not defined in Client options and also was not specified in constructor. At least one is required. Available DCs are: [datacenter1]

Any tips how to fix this? Let me know if you need more info from me!

Thank you!

PS: not related to the bug, but I could imagine this step being part of the setup process so users don't need to run it manually (at least for those who use Docker and not Cloud)

zseta commented 1 year ago

Looks like adding the --datacenter parameter solves this issue:

npm run migrate -- --hosts 172.24.0.4 --datacenter datacenter1
info: Bootstrapping database...
info: Creating keyspace...
info: Keyspace created
info: Migrating database...
info: Database migrated

Works for me

zseta commented 1 year ago

Later on in the tutorial, --datacenter is also needed when running the "pet collar simulation ":

npm run sensor -- --hosts 172.24.0.4 --measure 5s --buffer-interval 1m --datacenter datacenter1
DanielHe4rt commented 2 months ago

Fixed and merged!