Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User will be lost if tinode-mysql container will be redeployed #157

Closed
pwFoo opened this issue Sep 22, 2018 · 25 comments
Closed

User will be lost if tinode-mysql container will be redeployed #157

pwFoo opened this issue Sep 22, 2018 · 25 comments

Comments

@pwFoo
Copy link

pwFoo commented Sep 22, 2018

I redeploy the tinode app container and lose all my users. Auth error 401. Existing user (database isn't deleted and container still exists and is used) can be re-registered.
I think it refresh the database during update / (re-)deploy?

Is there a way to keep the existing data / user during tinode update / redeploy?

@or-else
Copy link
Contributor

or-else commented Sep 22, 2018

There were no changes to the way database is refreshed with the docker container. It works exactly like it worked before.

Here is how the entrypoint.sh decides if the database needs to be refreshed:

if [ ! -f /botdata/.tn-cookie ] || [ "$RESET_DB" = true ] ; then

Make sure the /botdata/.tn-cookie is located on an external mount.

If you want it to be done differently, please send a pull request. Thanks.

@pwFoo
Copy link
Author

pwFoo commented Sep 22, 2018

So /botdata should be a named volume to have persist data?
Could you add it to the documentation?

@or-else
Copy link
Contributor

or-else commented Sep 22, 2018

Yes. It is in the documentation.
Maybe it's not clear enough.

or-else added a commit that referenced this issue Sep 25, 2018
@or-else
Copy link
Contributor

or-else commented Sep 25, 2018

I've changed how data is reset when the new container is run:
https://github.com/tinode/chat/tree/devel/docker#resetting-the-database
The new logic is released in 0.15.7-rc1.

@pwFoo
Copy link
Author

pwFoo commented Oct 1, 2018

Tried to clean up users / db with latest image, but tinode server won't start after (re-)deploy with following error:

$ docker logs tinode
2018/10/01 10:03:58 Failed to init DB adapter:Error 1049: Unknown database 'tinode'

Any idea why the database isn't created during deploy / install any more?

@or-else
Copy link
Contributor

or-else commented Oct 1, 2018

Could you please describe the exact steps?

@pwFoo
Copy link
Author

pwFoo commented Oct 1, 2018

First I just deletet tinode+mysql container and mysql container volume mounted to /var/lib/mysql.

During redeploy the tinode-server container stops with the posted error message.

Then I tried to clean up all the dependent volumes (mysql, botdata) with the containers ans deployed it again. Same error

So I tried second step (delete containers and volumes) with the -e RESET_DB=true flag to force the initialization.

Each time I get the same error message and can't get the tinode server online again.

@or-else
Copy link
Contributor

or-else commented Oct 1, 2018

Looking into it now.

@or-else
Copy link
Contributor

or-else commented Oct 1, 2018

Fixed in 1abcb1d#diff-39609fead6600716424c5e74a2fd001cR111

Will release docker later today.

@or-else
Copy link
Contributor

or-else commented Oct 1, 2018

v0.15.7-rc3 released.

@pwFoo
Copy link
Author

pwFoo commented Oct 1, 2018

Thanks @or-else
Sure it works as expected?
Container stops every time

2018/10/01 18:38:39 Database exists, DB version is correct. All done. mysql

@pwFoo
Copy link
Author

pwFoo commented Oct 1, 2018

docker logs with reset db

2018/10/01 18:40:33 Database reset requested
2018/10/01 18:40:35 Generating users...
2018/10/01 18:40:36 Generating group topics...
2018/10/01 18:40:36 Generating P2P subscriptions...
2018/10/01 18:40:36 Generating group subscriptions...
2018/10/01 18:40:36 Inserting messages...
2018/10/01 18:40:38 All done.

@or-else
Copy link
Contributor

or-else commented Oct 1, 2018

I just checked on a fresh mysql:5.7 image and it worked just fine. What exactly is not working?

@pwFoo
Copy link
Author

pwFoo commented Oct 1, 2018

After "all done" tinode server container stops without more information.

@or-else
Copy link
Contributor

or-else commented Oct 1, 2018

What are the steps, like "start container x", "stop container y..."?

@pwFoo
Copy link
Author

pwFoo commented Oct 1, 2018

Running clear mysql Database.
Start new tinode container

Tried with reset DB too. Logs are okay, but container stops.

@or-else
Copy link
Contributor

or-else commented Oct 1, 2018

I followed instructions on https://github.com/tinode/chat/tree/master/docker for running a mysql:5.7 and tinode/tinode-mysql:0.15.7-rc3 and it worked fine:

docker run --name mysql --network tinode-net --env MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql:5.7
docker run -p 6060:18080 -d --name tinode-srv --network tinode-net tinode/tinode-mysql:0.15.7-rc3

What are your docker commands?

@or-else
Copy link
Contributor

or-else commented Oct 2, 2018

I played some more - stopping, starting, deleting, running again. It works fine. Please show the sequence of docker commands that reproduces the problem.

@pwFoo
Copy link
Author

pwFoo commented Oct 2, 2018

Delete old containers

docker rm -f tinode tinode-mysql

Delete volumes (not fcm volume!)

docker volume rm tinode-botdata tinode-mysql tinode-logs

Start mysql container

docker run --name tinode-mysql --env MYSQL_ALLOW_EMPTY_PASSWORD=yes -v tinode-mysql:/var/lib/mysql -d mysql:5.7 

Start tinode container
CADDY_PROXY_OPTS, VIRTUAL_HOST, VIRTUAL_PORT = reverse proxy

docker run --rm -ti --name tinode -e VIRTUAL_HOST=<DOMAIN> -e VIRTUAL_PORT=18080 -e CADDY_PROXY_OPTS=websocket --link tinode-mysql:mysql -e SMTP_SERVER=<SMTP_SERVER> -e SMTP_PORT=25 -e SMTP_SENDER=<EMAIL_ADDRESS> -e SMTP_PASSWORD=<PW> -e SMTP_HOST_URL=https://<DOMAIN> -v tinode-fcm:/fcm/ -e FCM_PROJECT_ID=<FCM_ID> -e FCM_CRED_FILE=/fcm/<FCM_JSON_FILE> -v tinode-logs:/var/log -v tinode-botdata:/botdata -e FCM_SENDER_ID=<FCM_SENDER_ID> -e FCM_VAPID_KEY=<FCM_VAPID_KEY> tinode/tinode-mysql:0.15.7-rc3

Started with --rm to see output until container stops.

2018/10/02 07:13:24 Database not found. Creating. Database not initialized
2018/10/02 07:13:25 Generating users...
2018/10/02 07:13:26 Generating group topics...
2018/10/02 07:13:27 Generating P2P subscriptions...
2018/10/02 07:13:27 Generating group subscriptions...
2018/10/02 07:13:27 Inserting messages...
2018/10/02 07:13:29 All done.
$

And so the container stops instead of running tinode server.
tinode logs:

2018/10/02 07:13:29 Server v0.15:/opt/tinode/tinode:v0.15.7-rc3; db: 'mysql'; pid 41; 2 process(es)
2018/10/02 07:13:29 Using config from '/opt/tinode/working.config'
2018/10/02 07:13:29 Running as a standalone server.
2018/10/02 07:13:29 Failed to init validator 'email': read /opt/tinode: is a directory

Ok, last line is new. Haven't seen a init validator problem before...?!
Email part is unchanged and there was no such error yesterday in the evening with the same docker command.

@or-else
Copy link
Contributor

or-else commented Oct 2, 2018

This part is fine:

2018/10/02 07:13:24 Database not found. Creating. Database not initialized
2018/10/02 07:13:25 Generating users...
2018/10/02 07:13:26 Generating group topics...
2018/10/02 07:13:27 Generating P2P subscriptions...
2018/10/02 07:13:27 Generating group subscriptions...
2018/10/02 07:13:27 Inserting messages...
2018/10/02 07:13:29 All done.

That means the database is successfully generated.

This is probably why it stops:

2018/10/02 07:13:29 Failed to init validator 'email': read /opt/tinode: is a directory

In other words, it has nothing to do with database initialization. I' looking into the new error.

@or-else
Copy link
Contributor

or-else commented Oct 2, 2018

OK, I see why it fails. Fix is coming.

@pwFoo
Copy link
Author

pwFoo commented Oct 2, 2018

Thanks!
Strange... yesterday the "right" error Message wasn't in the log...

@or-else
Copy link
Contributor

or-else commented Oct 2, 2018

v0.15.7-rc4 released

@pwFoo
Copy link
Author

pwFoo commented Oct 2, 2018

Fixed with rc4. Thanks!

But new / old bugs there g Search user by username / tag / email doen't work anymore?

@or-else
Copy link
Contributor

or-else commented Oct 2, 2018

Search works for me.

I'm going to close this issue. If you see another problem, please open a new issue. Thanks!

@or-else or-else closed this as completed Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants