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

Completely disable all relevant build steps of extensions (except FeatureBuildItem production) when their "enabled" configuration switch is set to false #26966

Merged
merged 4 commits into from
Aug 10, 2022

Conversation

yrodiere
Copy link
Member

@yrodiere yrodiere commented Jul 27, 2022

In particular, when such an extension is disabled:

  • Don't display the feature in logs on startup => changed following comments, see conversation below.
  • Don't enable SSL
  • Don't add reflective classes in native mode

EDIT: Also, regardless of whether the extension is enabled or not, always display the feature in logs on startup.

Creating this PR as draft, because it's based on #26965 , which must be merged first. => Done

I separated this PR from #26965 because #26965 doesn't alter the behavior of any extension, while this PR does (but for the better, IMO).

@quarkus-bot
Copy link

quarkus-bot bot commented Jul 27, 2022

/cc @brunobat, @ebullient, @jmartisk, @radcortez

@gsmet
Copy link
Member

gsmet commented Jul 27, 2022

Don't display the feature in logs on startup

Can't say I'm excited about this particular one. For me, it's important to know that the feature has actually be detected by Quarkus even if not active.

@yrodiere
Copy link
Member Author

yrodiere commented Jul 27, 2022

Can't say I'm excited about this particular one. For me, it's important to know that the feature has actually be detected by Quarkus even if not active.

We'll have to make up our minds then, because other extensions (Micrometer, ...) hide the feature when they are disabled:

@BuildStep(onlyIf = MicrometerEnabled.class)
FeatureBuildItem feature() {
return new FeatureBuildItem(Feature.MICROMETER);
}

For context, here's the log message we're talking about:

2022-07-27 15:31:25,238 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [agroal, cdi, hibernate-orm, hibernate-orm-panache, hibernate-search-elasticsearch, jdbc-postgresql, narayana-jta, resteasy-reactive, resteasy-reactive-jackson, smallrye-context-propagation, vertx]

We can argue whether it's clear that "installed" doesn't mean "enabled". Personally I find the distinction too confusing and I would hide the extensions when they are disabled, but in the end I don't really care either way, as long as we're consistent across Quarkus.

FWIW, we also use FeatureBuildItem to forbid having two (enabled?) extensions with the same name:

List<String> featureNames = new ArrayList<>();
for (FeatureBuildItem feature : features) {
if (featureNames.contains(feature.getName())) {
throw new IllegalStateException(
"Multiple extensions registered a feature of the same name: " + feature.getName());
}
featureNames.add(feature.getName());
}

Not sure what to think about that. We probably wouldn't want to have two extensions providing the same feature even if one is disabled?

EDIT: Though that could be useful for users who end up having two (incompatible) extensions in the classpath that provide the same feature... Two alternative implementations with a common API maybe, but integrating with different technologies/environments? I don't know...

@gsmet
Copy link
Member

gsmet commented Jul 27, 2022

Well I don't know about Micrometer but the purpose of this message has always been to inform about the features detected by Quarkus.
Enabled or not, that's a matter of config.

We can decide to change that. But... my personal opinion is that it's not a good idea. Knowing that an extension has actually been detected is an important piece of information and why we have this line in the log.

FWIW, we also use FeatureBuildItem to forbid having two (enabled?) extensions with the same name

I think this is probably something that predates capabilities. But it's still a good thing in my opinion as having 2 features with the same name would be confusing.

@yrodiere yrodiere requested a review from sberyozkin July 28, 2022 09:21
@yrodiere yrodiere force-pushed the disable-completely branch 2 times, most recently from 8fd0b8d to 7821b5e Compare July 29, 2022 09:36
@yrodiere yrodiere changed the title Completely disable all relevant build steps of extensions when their "enabled" configuration switch is set to false Completely disable all relevant build steps of extensions (except FeatureBuildItem production) when their "enabled" configuration switch is set to false Aug 1, 2022
@yrodiere yrodiere force-pushed the disable-completely branch 2 times, most recently from f9fa839 to 0c869e7 Compare August 2, 2022 06:33
@yrodiere yrodiere force-pushed the disable-completely branch from 0c869e7 to a7a1590 Compare August 5, 2022 07:47
@yrodiere
Copy link
Member Author

yrodiere commented Aug 5, 2022

@sberyozkin could you please confirm this isn't a problem for the various oidc extensions?

Hey @sberyozkin, bump :) Any opinion on this change for the oidc extensions? If you don't particularly care either way, I think we'll go ahead, since other extension owners agree with the change.

@pedroigor
Copy link
Contributor

pedroigor commented Aug 5, 2022

@yrodiere I'm really happy to see this change happening. It would help a lot Keycloak and open the doors to lot of improvements. For instance, quarkiverse/quarkus-vault#12 (comment). AFAIK, this PR should help with that.

As per the security extensions, I would leave it to @sberyozkin. But I don't see an issue for keycloak-authorization.

@pedroigor
Copy link
Contributor

@yrodiere I guess the changes here are not yet allowing disabling build steps conditionally, right? For instance, Keycloak is basically a Quarkus extension and we would like to conditionally disable build steps depending on the user configuration when running re-augmentation.

@yrodiere
Copy link
Member Author

yrodiere commented Aug 5, 2022

@yrodiere I'm really happy to see this change happening. It would help a lot Keycloak and open the doors to lot of improvements. For instance, quarkiverse/quarkus-vault#12 (comment). AFAIK, this PR should help with that.

I'm not sure it will, since this PR only disables a few build steps when the (existing) *.enabled configuration properties are set to false. The @BuildSteps annotation has already been merged in a previous PR, so you can probably already experiment with it. It's mostly just syntactic sugar, though; see #26965 / #26980 .

As to disabling extensions at runtime, which I think was mentioned in the issue you linked, that's still not possible, unfortunately. But maybe @BuildSteps alone is enough?

@yrodiere
Copy link
Member Author

yrodiere commented Aug 5, 2022

@yrodiere I guess the changes here are not yet allowing disabling build steps conditionally, right?

This PR doesn't change anything regarding that, no.

For instance, Keycloak is basically a Quarkus extension and we would like to conditionally disable build steps depending on the user configuration when running re-augmentation.

That was already possible, I think? Just use @BuildStep(onlyIf = MyCondition.class) on that step and have the relevant configuration injected in MyCondition. See https://quarkus.io/guides/writing-extensions#conditional-step-inclusion

Recently I added @BuildSteps (with a trailing s) that can be applied at the type level, which is more convenient, but is just syntactic sugar.

@pedroigor
Copy link
Contributor

pedroigor commented Aug 5, 2022

Recently I added @BuildSteps (with a trailing s) that can be applied at the type level, which is more convenient, but is just syntactic sugar.

Yeah, using a condition to a BuildStep works and we are using that. But I did not know about the top-level class BuildSteps.

Can I expect that when a class is using BuildSteps the ExtensionLoader won't even try to resolve methods from the build class using reflection?

@pedroigor
Copy link
Contributor

Btw, also related to what we are looking for #22122.

@yrodiere
Copy link
Member Author

yrodiere commented Aug 5, 2022

Can I expect that when an extension is using BuildSteps the ExtensionLoader won't even try to resolve methods from the build class using reflection?

No, reflection will still happen. Conditions are evaluated after ExtensionLoader does its job (which is, in particular, determining what the condition classes are, but does not include evaluating the conditions).

I don't know if your suggestion can be implemented either: I'm not too familiar with this code, and there's so many levels of callbacks in this code that it's hard to say what's going on for sure :) But someone obviously made the choice to delay evaluation of conditions, and I'm guessing there's a reason for that.

Maybe it would be better to open a dedicated issue to discuss that.

@pedroigor
Copy link
Contributor

@yrodiere Sure, thanks for your input. This change is still valuable and we should be looking at how adapt to it.

@gsmet
Copy link
Member

gsmet commented Aug 9, 2022

@yrodiere I think we should pursue with this before we end up with conflicts.

@yrodiere
Copy link
Member Author

@sberyozkin could you please confirm this isn't a problem for the various oidc extensions?

Hey @sberyozkin, bump :) Any opinion on this change for the oidc extensions? If you don't particularly care either way, I think we'll go ahead, since other extension owners agree with the change.

No answer, so I'll assume it's good to go.

Thanks everyone! Merging

@yrodiere yrodiere marked this pull request as ready for review August 10, 2022 05:50
@yrodiere
Copy link
Member Author

... I'll let CI run first though :-)

@yrodiere yrodiere added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Aug 10, 2022
@yrodiere yrodiere merged commit af4f067 into quarkusio:main Aug 10, 2022
@quarkus-bot quarkus-bot bot added this to the 2.12 - main milestone Aug 10, 2022
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Aug 10, 2022
@yrodiere yrodiere deleted the disable-completely branch October 28, 2022 08:09
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.

6 participants