Title
#fleet
Esteban

Esteban

07/01/2021, 11:33 AM
Hello, I've updated to the last version. I've changed the old env variables (KOLIDE_ format) to new format. But when doing the migration it gives me this error:
2021/07/01 11:29:41 FAIL 20210601000001_CreateTeamsTables.go (alter hosts: Error 1005: Can't create table `fleet`.`hosts` (errno: 121 "Duplicate key on write or update")), quitting migration.
zwass

zwass

07/01/2021, 3:23 PM
Which version are you upgrading from? What version of MySQL are you running?
Esteban

Esteban

07/01/2021, 4:07 PM
I don't remember, previous to 4.0.0
4:07 PM
I was still using KOLIDE_ env variables
4:08 PM
MySQL Version: 5.7
zwass

zwass

07/01/2021, 6:27 PM
I can see now that the identifier we use in this migration violates the global uniqueness requirement as mentioned in the MySQL docs (https://dev.mysql.com/doc/refman/5.7/en/create-table-foreign-keys.html)
The CONSTRAINT symbol value, if defined, must be unique in the database. A duplicate symbol results in an error similar to: ERROR 1005 (HY000): Can't create table 'test.fk1' (errno: 121).
I am not sure why this migration works in our development and testing environments. Let us think about how to best address this and make a 4.0.1 release.
6:28 PM
Can you give me any more information about your MySQL database? It would be helpful if we could understand what configuration causes this issue so that we can reproduce it locally.
Esteban

Esteban

07/01/2021, 6:50 PM
I'm using a Docker Container with MariaDB. I've tried to use a plain new database and i've got the same error
zwass

zwass

07/01/2021, 6:53 PM
Ah, maybe MariaDB enforces it and plain MySQL doesn't. Let me see if that helps me reproduce.
Esteban

Esteban

07/01/2021, 6:57 PM
I'll try with a mysql container in the same machine
7:23 PM
With mysql container it's working with the last version.
zwass

zwass

07/01/2021, 10:52 PM
Super helpful, thank you. I was able to reproduce it locally and fix the issue. Going to cut a 4.0.1 when this is merged https://github.com/fleetdm/fleet/pull/1280
Esteban

Esteban

07/02/2021, 12:01 AM
Your welcome, glad to help!
zwass

zwass

07/02/2021, 12:17 AM
We published 4.0.1, please give it a try now 🙂
Esteban

Esteban

07/02/2021, 12:47 AM
Did you publish the docker image? I'm using the fleetdm/fleet image
11:26 AM
Hello, now there's another error
2021/07/02 11:26:08 FAIL 20210601000002_AddRolesToInvites.go (create invite_teams: Error 1005: Can't create table `fleet`.`invite_teams` (errno: 121 "Duplicate key on write or update")), quitting migration.
r

Ricardo Santos

07/02/2021, 2:27 PM
Same error here.. using binary. Database: mysql Ver 15.1 Distrib 10.3.28-MariaDB, for Linux (x86_64) using readline 5.1
{"component":"service","err":"list users: missing destination name global_role in *[]*kolide.User","level":"info","method":"ListUsers","took":"698.826µs","ts":"2021-07-02T14:26:11.197380836Z","user":"none"}
Error fetching setup requirement: list users: missing destination name global_role in *[]*kolide.User
2:33 PM
This error is when I start the old version...
Esteban

Esteban

07/02/2021, 2:39 PM
Maybe it's happening before 4.0?
r

Ricardo Santos

07/02/2021, 3:00 PM
I tried to upgrade from previous version, with 4.0.0 same error as yours.. with 4.0.1 same error as yours, but now fleet (previous version) can't start... seems like it is between versions.
zwass

zwass

07/03/2021, 12:34 AM
My apologies. It looks like you both ended up in a state that is only possible after hitting the error in v4.0.0 and then upgrading to v4.0.1. Things should be fixed in v4.0.1 for any MariaDB users that did not try v4.0.0. To fix your current issue, please run the following query in your database and then run the v4.0.1 migrations again.
ALTER TABLE user_teams DROP FOREIGN KEY fk_team_id, ADD FOREIGN KEY fk_user_teams_team_id (team_id) REFERENCES teams (id) ON DELETE CASCADE ON UPDATE CASCADE;
r

Ricardo Santos

07/05/2021, 9:47 AM
No problem. Thank you for this product. It solved my problem. It worked for me... just having an error with the auth_jwt_key on the new version...
9:53 AM
Started successfully without the auth_jwt_key option. Haven't tried to enroll a new agent still.
Esteban

Esteban

07/05/2021, 11:41 AM
That worked great. Thanks!