Skip to content

Support ignoring artigacts when running re-augmentation - #20976

Merged
pedroigor merged 1 commit into
keycloak:mainfrom
pedroigor:issue-20974
Jul 5, 2023
Merged

Support ignoring artigacts when running re-augmentation#20976
pedroigor merged 1 commit into
keycloak:mainfrom
pedroigor:issue-20974

Conversation

@pedroigor

Copy link
Copy Markdown
Contributor

Closes #20974

@pedroigor
pedroigor requested a review from a team June 13, 2023 15:16
@pedroigor
pedroigor requested review from a team as code owners June 13, 2023 15:16
@pedroigor pedroigor changed the title Avoid loading classes and resources from jpa store if current store is enabled Avoid loading classes and resources from jpa store if legacy store is enabled Jun 13, 2023
@ghost ghost added the flaky-test label Jun 13, 2023
@mabartos
mabartos self-requested a review June 14, 2023 13:57
@mabartos

Copy link
Copy Markdown
Member

@pedroigor The issue is super valid. Code LGTM. However, there are still some insufficiencies as the tests failed.

@pedroigor

pedroigor commented Jun 16, 2023

Copy link
Copy Markdown
Contributor Author

@mabartos Looks like we can make this much simpler. @aloubyansky is working on a change to Quarkus.

Initial tests show that it is enough to solve our problem. The main change on our side would be to set quarkus.class-loading.removed-artifacts before running the re-augmentation in the Build command to force removing new store (and vice-versa) when running build steps.

@ghost

ghost commented Jun 16, 2023

Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.ui.account2.LinkedAccountsTest#linkAccountTest

Keycloak CI - Account Console IT (firefox)

java.lang.AssertionError: Expected LinkedAccountsPage but was Keycloak Account Management (https://localhost:8543/auth/realms/test/account/#/security/linked-accounts&state=62bc3da3-22a9-4de1-9b7e-eda628a88002&session_state=1e7b2df3-c5fb-4ba4-9167-4f0a4e14e6bc&code=49bcc294-8e3f-4be2-8288-d34a20f43cb9.1e7b2df3-c5fb-4ba4-9167-4f0a4e14e6bc.d502b72b-4fac-4629-b403-8ddd025a130d)
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.keycloak.testsuite.page.AbstractPage.assertCurrent(AbstractPage.java:110)
	at jdk.internal.reflect.GeneratedMethodAccessor103.invoke(Unknown Source)
...

Report flaky test

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@pedroigor pedroigor added the status/hold PR should not be merged. On hold for later. label Jun 19, 2023
@pedroigor

Copy link
Copy Markdown
Contributor Author

The fix from quarkusio/quarkus#34107 should help to remove the workarounds in hibernate (e.g.: duplicate of the Integrator SPI impl in dist runtime module).

Based on discussions with @aloubyansky, we should be able to get this change before 22.

@vmuzikar

Copy link
Copy Markdown
Contributor

@pedroigor Is it still valid we want this change to get to 22?

@aloubyansky

Copy link
Copy Markdown

Just FYI, io.quarkus:quarkus-bom:3.2.0.Final is available on Central now.

@hmlnarik

Copy link
Copy Markdown
Contributor

@pedroigor Is it still valid we want this change to get to 22?

Would be good to have this change for 22 as long as it can be based on the Quarkus 3.2.0 changes so that the whole modules can be ignored upon build. Then this PR would be cleaner, without the need to override the EventListenerIntegrator class.

@vmuzikar

Copy link
Copy Markdown
Contributor

If I understand correctly, this is then effectively waiting for Quarkus 3.2, correct?

@aloubyansky

Copy link
Copy Markdown

See my previous comment, it's already available. Not the platform but you are not using the platform BOM anyway.

@vmuzikar

Copy link
Copy Markdown
Contributor

@aloubyansky Yeah, I meant waiting for us to upgrade to 3.2. ;)

@vmuzikar

vmuzikar commented Jul 3, 2023

Copy link
Copy Markdown
Contributor

Since #21352 was merged, we can continue with this PR.

@ghost

ghost commented Jul 3, 2023

Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.forms.ResetPasswordTest#resetPasswordWrongSmtp

Keycloak CI - Forms IT (firefox)

java.lang.AssertionError: Expected ErrorPage but was Sign in to test (https://localhost:8543/auth/realms/test/login-actions/reset-credentials?client_id=test-app&tab_id=Z35EXfACAfY)
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.keycloak.testsuite.pages.AbstractPage.assertCurrent(AbstractPage.java:47)
	at jdk.internal.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
...
org.openqa.selenium.TimeoutException: 
Navigation timed out after 10000 ms
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'fv-az548-577', ip: '10.1.0.158', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1040-azure', java.version: '17.0.7'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
...

Report flaky test

org.keycloak.testsuite.model.session.OfflineSessionPersistenceTest#testPersistenceMultipleNodesClientSessionsAtRandomNode

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (TIMED_WAITING): locked on java.util.concurrent.FutureTask@705af15f waiting for 98343 ms blocked for 8576 ms
	at java.base@17.0.7/jdk.internal.misc.Unsafe.park(Native Method)
	at java.base@17.0.7/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
	at java.base@17.0.7/java.util.concurrent.FutureTask.awaitDone(FutureTask.java:444)
...

Report flaky test

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@ghost

ghost commented Jul 3, 2023

Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.forms.ResetPasswordTest#resetPasswordWrongSmtp

Keycloak CI - Forms IT (firefox)

java.lang.AssertionError: Expected ErrorPage but was Sign in to test (https://localhost:8543/auth/realms/test/login-actions/reset-credentials?client_id=test-app&tab_id=Z35EXfACAfY)
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.keycloak.testsuite.pages.AbstractPage.assertCurrent(AbstractPage.java:47)
	at jdk.internal.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
...
org.openqa.selenium.TimeoutException: 
Navigation timed out after 10000 ms
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'fv-az548-577', ip: '10.1.0.158', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1040-azure', java.version: '17.0.7'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
...

Report flaky test

org.keycloak.testsuite.model.session.OfflineSessionPersistenceTest#testPersistenceMultipleNodesClientSessionsAtRandomNode

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (TIMED_WAITING): locked on java.util.concurrent.FutureTask@705af15f waiting for 98343 ms blocked for 8576 ms
	at java.base@17.0.7/jdk.internal.misc.Unsafe.park(Native Method)
	at java.base@17.0.7/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
	at java.base@17.0.7/java.util.concurrent.FutureTask.awaitDone(FutureTask.java:444)
...

Report flaky test

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@ghost

ghost commented Jul 3, 2023

Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.forms.ResetPasswordTest#resetPasswordWrongSmtp

Keycloak CI - Forms IT (firefox)

java.lang.AssertionError: Expected ErrorPage but was Sign in to test (https://localhost:8543/auth/realms/test/login-actions/reset-credentials?client_id=test-app&tab_id=Z35EXfACAfY)
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.keycloak.testsuite.pages.AbstractPage.assertCurrent(AbstractPage.java:47)
	at jdk.internal.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
...
org.openqa.selenium.TimeoutException: 
Navigation timed out after 10000 ms
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'fv-az548-577', ip: '10.1.0.158', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1040-azure', java.version: '17.0.7'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
...

Report flaky test

org.keycloak.testsuite.model.session.OfflineSessionPersistenceTest#testPersistenceMultipleNodesClientSessionsAtRandomNode

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (TIMED_WAITING): locked on java.util.concurrent.FutureTask@705af15f waiting for 98343 ms blocked for 8576 ms
	at java.base@17.0.7/jdk.internal.misc.Unsafe.park(Native Method)
	at java.base@17.0.7/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
	at java.base@17.0.7/java.util.concurrent.FutureTask.awaitDone(FutureTask.java:444)
...

Report flaky test

@pedroigor
pedroigor marked this pull request as ready for review July 3, 2023 22:41
@pedroigor pedroigor changed the title Avoid loading classes and resources from jpa store if legacy store is enabled Support ignoring artigacts when running re-augmentation Jul 3, 2023
@vmuzikar
vmuzikar requested a review from hmlnarik July 4, 2023 08:55

@mabartos mabartos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pedroigor Code looks good to me, nice job! I've put only one comment below.

As the IGNORE_ARTIFACTS option is hidden, does it mean it's intended to use only internally, right? As users cannot use the property class-loader-ignore-artifacts to ignore other artifacts, right?

If that's the case, it works as expected as the user is not capable to ignore other artifacts via the property.

However, we could maybe consider providing such a capability as users could also ignore some artifacts for their deployments.

@pedroigor WDYT?

@pedroigor

Copy link
Copy Markdown
Contributor Author

@mabartos Regarding making it a user-facing option, I would keep it hidden for now and only available internally. Not sure about the use cases we are going to address with it.

@mabartos

mabartos commented Jul 4, 2023

Copy link
Copy Markdown
Member

Regarding making it a user-facing option, I would keep it hidden for now and only available internally. Not sure about the use cases we are going to address with it.

Agree to have it hidden for now.

@mabartos mabartos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pedroigor LGTM

Comment on lines +99 to +102
if (ignoredArtifacts != null && StringUtil.isNotBlank(ignoredArtifacts.getValue())) {
// ignored artifacts must be set prior to starting re-augmentation
System.setProperty("quarkus.class-loading.removed-artifacts", ignoredArtifacts.getValue());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity, why do we need this if we already have mapping here:

public static PropertyMapper[] getMappers() {
return new PropertyMapper[] {
fromOption(ClassLoaderOptions.IGNORE_ARTIFACTS)
.to("quarkus.class-loading.removed-artifacts")
.transformer(ClassLoaderPropertyMappers::resolveIgnoredArtifacts)
.build()
};
}

Can't we remove either of them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@vmuzikar To leverage the related fix from Quarkus, we need to make sure the build class loader is built taking this property into account so that the artifacts are ignored accordingly.

By keeping only within our mapping layer, it is too late because the build class loader was already built.

We could potentially keep everything within the Build command but I did not test it. Also, I think keeping the resolution within our configuration is more natural and aligned with what we are doing for others.

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

Labels

flaky-test status/hold PR should not be merged. On hold for later. team/cloud-native

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid loading classes and resources from new store if legacy is enabled

5 participants