First, I changed the âDeploy to qa serverâ to be synchronous, so you can see the deployment logs.
I donât know what evidence you have to say to say that qa-refapp is failing due to database update, the logs you sent are unrelated to qa-refapp. Did you check the application logs at all?
The database is recreated from scratch on every deployment. Nothing is kept between runs.
The red job is not with QA-refapp. Itâs to build the standalone, and the error is:
[WARNING] The POM for org.openmrs.api:openmrs-api:jar:2.3.0-SNAPSHOT is missing, no dependency information available
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:2.0.5:update (empty-database-create-schema) on project referenceapplication-standalone: Execution empty-database-create-schema of goal org.liquibase:liquibase-maven-plugin:2.0.5:update failed: Plugin org.liquibase:liquibase-maven-plugin:2.0.5 or one of its dependencies could not be resolved: Could not find artifact org.openmrs.api:openmrs-api:jar:2.3.0-SNAPSHOT -> [Help 1]
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set liquibase-update-to-latest.xml::TRUNK-5672-201910211105::Mritunjay:
Reason: liquibase.exception.DatabaseException: Error executing SQL UPDATE `users` SET `username` = 'admin' WHERE system_id='admin': admin user account is locked:
Caused By: Error executing SQL UPDATE `users` SET `username` = 'admin' WHERE system_id='admin': admin user account is locked:
Caused By: admin user account is locked
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:347)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
at org.openmrs.util.DatabaseUpdater$1OpenmrsUpdateVisitor.visit(DatabaseUpdater.java:191)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at org.openmrs.util.DatabaseUpdater.executeChangelog(DatabaseUpdater.java:220)
at org.openmrs.util.DatabaseUpdater.executeChangelog(DatabaseUpdater.java:150)
... 2 more
Caused by: liquibase.exception.DatabaseException: Error executing SQL UPDATE `users` SET `username` = 'admin' WHERE system_id='admin': admin user account is locked
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:104)
at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1091)
at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:1075)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
... 7 more
Caused by: java.sql.SQLException: admin user account is locked
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2480)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2438)
at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:845)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:745)
at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
... 11 more
org.openmrs.util.DatabaseUpdateException: There was an error while updating the database to the latest. file: liquibase-update-to-latest.xml. Error: Migration failed for change set liquibase-update-to-latest.xml::TRUNK-5672-201910211105::Mritunjay:
Reason: liquibase.exception.DatabaseException: Error executing SQL UPDATE `users` SET `username` = 'admin' WHERE system_id='admin': admin user account is locked:
All our servers block in the SQL level to update the admin user to prevent users from changing the admin user. That was the magical incantation that has been passed over and over.
We donât need anyone changing it to confuse our test servers.
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER users_update BEFORE UPDATE ON users FOR EACH ROW
IF OLD.user_id = 1 THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'admin user account is locked';
END IF */;;
DELIMITER ;
It was never a requirement that an SQL would now change it.
What can be the new requirement?
here is the commit that has caused problems ,
is there are way we can add another pre-condition , so that ,that change set doesnt run on our servers ??
cc @dkayiwa
Look, I donât want to leave open for others to change the adminâs username in our servers.
I could just change the sql to have âadminâ as the username, BUT the SQL I have was generated from the SDK. I wonder if it should have been fixed there instead of do a migration. Iâm not even sure if this needs to be a data migration or if the intent was only fix the demo server.
Hello, The fix was provided by me and the reason was we needed the admin user to have a username. For some reason it was never present and was using the system-id.
But the question is: was the problem only relevant on the demo server? Was there any benefit to updating that in all OpenMRS instances when upgrading it? Wouldnât it be better to just change the initial data instead?
Our problem was not regarding the demo server. I had given that as a reference in the talk. In our implementation, we were using the session API to fetch the username of the logged-in user and use it further.
We figured out it was not working because of admin user not having a username and we raised a fix. Was it not given a username intentionally?
Username was designed as a convenient moniker for users to use in place of their system ID for login. The super user account most likely never got a username because it had a convenient/special system ID (âadminâ). I donât think there is any harm to this account having a username other than the special case of our infrastructure locking down the account to prevent abuse (e.g., changing the password) of public systems.
What we missed in adding the username was ensuring this was done by default in the SDK (rather than relying on the liquibase change). If the SDK generates an admin user with a username, the problem will resolve.
I agree with Burke, it sounds confusing to me to create the data without username, and then fix it via liquibase.
If we change the data creation, it would cover any new instance of OpenMRS. My question is: is there any need to fix existing OpenMRS instances? (note that all our test services are recreated every couple of days, so itâs just a new server).
@permissionerror I do plan on doing this tonight, but if you are free you can do it before that.
So we need to go to the sql in all refapp and platform environments , and edit the SQL to add a username to the âadminâ user. Weâll roll it out using ansible as usual.
Weâll have to destroy and recreate all environments after that.