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

Unify devservices datatabase, username and password and allow configuration #25288

Merged
merged 3 commits into from Jun 22, 2022

Conversation

newur
Copy link
Contributor

@newur newur commented May 1, 2022

I wanted to inspect the Postgres database started by devservices. While searching for the login credentials I noticed that different databases use different credentials and db names. I think it is nicer to use the same for all. Bonus, at least for Postgres the login via psql becomes shorter when the username and db name are equal

psql -h localhost -p <randomPort> -U quarkus

instead of

psql -h localhost -p <randomPort> -U quarkus -d default

I did not find the information how to connect to the devservices datasources in the docu. Would be worth to add it IMO. Any hints where I should put it?

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's indeed a very good idea, thanks.

Only one small gripe: we avoid star imports in Quarkus. Any chance you could remove them?

@gsmet
Copy link
Member

gsmet commented May 2, 2022

Also please squash all the commits when done.

@newur newur force-pushed the unify-devservices-datasource-names branch from 6cdefc9 to 0687d78 Compare May 2, 2022 09:57
@newur newur requested a review from gsmet May 2, 2022 09:59
@quarkus-bot

This comment has been minimized.

@gsmet gsmet force-pushed the unify-devservices-datasource-names branch from 0687d78 to 9631bfb Compare May 3, 2022 11:55
@gsmet
Copy link
Member

gsmet commented May 3, 2022

I force pushed a formatting fix to your branch.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@newur newur force-pushed the unify-devservices-datasource-names branch from 92194db to 9ac7195 Compare May 4, 2022 21:40
@newur
Copy link
Contributor Author

newur commented May 4, 2022

DB2 really putted on a fight. Will the light prevail now or is it another round? ¯_(ツ)_/¯

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments. There is a big mix up between username and password in the patch.

@@ -48,7 +48,7 @@ public void testDatasource() throws Exception {
fail("Datasource should not be null");
}
assertTrue(configuration.connectionFactoryConfiguration().jdbcUrl().contains("jdbc:postgresql:"));
assertEquals("quarkus", configuration.connectionFactoryConfiguration().principal().getName());
assertEquals("quarku_1", configuration.connectionFactoryConfiguration().principal().getName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you use the constants? BTW, this is a consequence of the mix you made between username and password. This should be the username here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would require adding a dependency.

@newur newur force-pushed the unify-devservices-datasource-names branch 2 times, most recently from 137fb26 to 2d6f47a Compare May 6, 2022 06:16
@quarkus-bot

This comment has been minimized.

@newur newur force-pushed the unify-devservices-datasource-names branch from 2d6f47a to 9e606d6 Compare May 6, 2022 16:32
@quarkus-bot

This comment has been minimized.

@newur
Copy link
Contributor Author

newur commented May 6, 2022

Not sure why this test fails. Works here with JDK 11 when I run it via mvn test.

@GavinRay97
Copy link
Contributor

Would this be a breaking change, for anyone who had manual connection strings specifying the database in their tests before?

@newur
Copy link
Contributor Author

newur commented May 7, 2022

Would this be a breaking change, for anyone who had manual connection strings specifying the database in their tests before?

I would not think so. The whole point of the dev services is that your app does not specify any connection details.

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some suggestions and questions. Could you have a look?

I want to make sure we don't do any mistakes here.

(I think we're nearly there)

"sa",
"sa",
DEFAULT_DATABASE_USERNAME,
DEFAULT_DATABASE_PASSWORD,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking but we have the full permissions when doing that and not using sa? I thought it had a special meaning? Given I don't see us defining permissions for the quarkus user, I'm wondering how this works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, if the database specified in the embedded URL does not yet exist, a new (empty) database is created automatically. The user that created the database automatically becomes the administrator of this database.

From H2 docu https://h2database.com/html/tutorial.html#creating_new_databases
sa is the abriviation for System Administrator, but seems to have no special permissions. It is just some default IMHO.

public static final String DEFAULT_DATABASE_USERNAME = "quarkus";

// mssql container enforces a 'strong' password with min 8 chars, upper/lowercase, number or special char
public static final String DEFAULT_DATABASE_PASSWORD = "quarkus1!";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would rather use quarkus for the password and have a STRONG_DEFAULT_DATABASE_PASSWORD for databases that requires it so only MSSQL for now.

Rationale is that in some cases you want to connect to the database while dev mode is running. And it's better to have a simple password if we can.

@newur newur force-pushed the unify-devservices-datasource-names branch from 9e606d6 to ec77b00 Compare May 20, 2022 16:15
@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@newur newur requested a review from gsmet May 28, 2022 06:17
@gastaldi gastaldi added the triage/needs-rebase This PR needs to be rebased first because it has merge conflicts label May 31, 2022
@gastaldi
Copy link
Contributor

This PR needs a rebase since the H2DevServicesProcessor class changed recently

@gsmet
Copy link
Member

gsmet commented Jun 21, 2022

I'm working on this as I want to make other changes in this area and thought it would be better to build on this one.

@gsmet gsmet changed the title Unify devservices datasource names Unify devservices datasource names and allow database, username and password configuration Jun 21, 2022
@gsmet gsmet changed the title Unify devservices datasource names and allow database, username and password configuration Unify devservices datatabase, username and password and allow configuration Jun 21, 2022
@gsmet gsmet added release/breaking-change release/noteworthy-feature and removed triage/needs-rebase This PR needs to be rebased first because it has merge conflicts labels Jun 21, 2022
@gsmet gsmet force-pushed the unify-devservices-datasource-names branch from 24b78ff to aee2dd8 Compare June 21, 2022 15:19
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a few adjustments for the doc and also added a commit to be able to easily override database names, usernames and passwords.

It's not obvious from the GitHub UI but authorship of the first commit has been preserved: Author: newur <newur@mailbox.org>. My guess is that there's a mismatch between email used in commit and emails declared on GitHub.

@gsmet gsmet added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jun 21, 2022
@quarkus-bot

This comment has been minimized.

Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failures seem related, probably because it needs to use the DEFAULT_DATABASE_STRONG_PASSWORD.

BTW I think the DEFAULT_DATABASE_STRONG_PASSWORD should be used in all databases instead of having just for MSSQL

Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failures seem related, probably because it needs to use the DEFAULT_DATABASE_STRONG_PASSWORD.

BTW I think the DEFAULT_DATABASE_STRONG_PASSWORD should be used in all databases instead of having just for MSSQL

@gastaldi
Copy link
Contributor

How about changing the password as something easier to remember? Like Quarkus#123?

@gsmet
Copy link
Member

gsmet commented Jun 21, 2022

I changed the password to Quarkus123. I think it's enough.

As for using the strong password everywhere, I don't think it's worth making things complicated for the small number of SQL Server users compared to the users of all the other databases.

Not all database containers support everything but it's implemented for
all everything that is supported.
@gsmet gsmet force-pushed the unify-devservices-datasource-names branch from aee2dd8 to c7b90ee Compare June 21, 2022 20:33
@gsmet gsmet merged commit fe1c236 into quarkusio:main Jun 22, 2022
@quarkus-bot quarkus-bot bot added this to the 2.11 - main milestone Jun 22, 2022
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jun 22, 2022
@gsmet
Copy link
Member

gsmet commented Jun 22, 2022

I merged it, it's a step in the right direction. Thanks @newur for starting this work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants