filecoin-project / dealbot

🤖🤝 A bot for making deals
Apache License 2.0
32 stars 10 forks source link

dealbot drain - how to use it? #363

Closed kuchaguangjie closed 2 years ago

kuchaguangjie commented 2 years ago

I've started a dealbot controller with --listen :8764, and started a dealbot daemon with --id 1,

Then call: dealbot drain -e http://127.0.0.1:8764 --id 1

The first time it succeed, but the daemon is still running.

So I called it again, and get error:

2022-02-11T21:24:35.576+0800    INFO    controller  client/client.go:40 dealbot controller client initialized   {"addr": "http://127.0.0.1:8764"}
2022-02-11T21:24:35.577+0800    FATAL   dealbot dealbot/main.go:94  Request failed: Bad Request

The controller also got error:

2022-02-11T21:24:35.577+0800    ERROR   controller  controller/tasks.go:104 drain worker DB error   {"err": "pq: duplicate key value violates unique constraint \"drained_workers_pkey\""}

Then I check table drained_workers, via sql:

select * from drained_workers limit 5;

and found the value 1 exists, I guess that caused duplicate key.


So, the questions are:

willscott commented 2 years ago

The first time it succeed, but the daemon is still running.

yes, the daemon will still be running.

drain will cause the controller to do the following:

  1. stop providing any more tasks to the daemon
  2. wait for the daemon to finish it's current tasks
  3. mark the daemon's tasks as 'complete' - publishing them publicly.

Once the command returns / is complete the daemon can be safely stopped.

kuchaguangjie commented 2 years ago

@willscott Thanks, as my understanding:

  1. The drain, stop further task, and publish current tasks; but don't actually stop daemon, need to stop the daemon afterwards by hand.
  2. Once a --id of daemon is drained, the id can never be used again, since it's recorded in database, and no task will be assign to it. Unless that id is removed by hand from table drained_workers?

Not sure am I understanding correctly.