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

Build error "AptContext has not been created" #795

Open
kdubb opened this issue Jan 8, 2024 · 15 comments
Open

Build error "AptContext has not been created" #795

kdubb opened this issue Jan 8, 2024 · 15 comments
Assignees

Comments

@kdubb
Copy link

kdubb commented Jan 8, 2024

With 6.5.0 I am getting a the following error listed below.

This is with our project using the sdk aligned Quarkus 3.6.4.

Previously, using 6.4.0 with Quarkus 3.5.3 (and the Fabric8 client version locked to 6.7.2) we weren't getting any issue during the build.

Execution failed for task ':cloud-vault-operator:quarkusAppPartsBuild'.
> There was a failure while executing work items
   > A failure occurred while executing io.quarkus.gradle.tasks.worker.BuildWorker
      > io.quarkus.builder.BuildException: Build failure: Build failed due to errors
                [error]: Build step io.quarkiverse.operatorsdk.deployment.CRDGenerationBuildStep#generateCRDs threw an exception: java.lang.IllegalStateException: AptContext has not been created, yet.
                at io.sundr.adapter.apt.AptContext.getContext(AptContext.java:95)
                at io.sundr.adapter.apt.AptLookup.forName(AptLookup.java:30)
                at io.sundr.adapter.api.TypeLookup.lambda$lookup$0(TypeLookup.java:30)
                at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
                at java.base/java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1950)
                at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
                at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
                at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
                at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
                at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
                at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
                at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
                at io.sundr.adapter.api.TypeLookup.lookup(TypeLookup.java:34)
                at io.sundr.model.functions.GetDefinition.lambda$apply$1(GetDefinition.java:47)
                at java.base/java.util.Optional.orElseGet(Optional.java:364)
                at io.sundr.model.functions.GetDefinition.apply(GetDefinition.java:47)
                at io.sundr.model.functions.GetDefinition.of(GetDefinition.java:36)
                at io.fabric8.crd.generator.utils.Types.typeDefFrom(Types.java:73)
                at io.fabric8.crd.generator.visitor.AnnotatedPropertyPathDetector.visitPropertiesClasses(AnnotatedPropertyPathDetector.java:86)
                at io.fabric8.crd.generator.visitor.AnnotatedPropertyPathDetector.visit(AnnotatedPropertyPathDetector.java:76)
                at io.fabric8.crd.generator.visitor.AnnotatedPropertyPathDetector.visit(AnnotatedPropertyPathDetector.java:34)
                at io.sundr.builder.Visitor.visit(Visitor.java:30)
                at io.sundr.builder.VisitorWiretap.visit(VisitorWiretap.java:79)
                at io.sundr.builder.Visitable.accept(Visitable.java:67)
                at io.sundr.builder.Visitable.lambda$accept$1(Visitable.java:81)
                at java.base/java.util.Optional.ifPresent(Optional.java:178)
                at io.sundr.builder.Visitable.accept(Visitable.java:73)
                at io.sundr.builder.Visitable.accept(Visitable.java:53)
                at io.sundr.builder.Visitable.accept(Visitable.java:30)
                at io.fabric8.crd.generator.visitor.AnnotatedPropertyPathDetector.visitPropertiesClasses(AnnotatedPropertyPathDetector.java:91)
                at io.fabric8.crd.generator.visitor.AnnotatedPropertyPathDetector.visit(AnnotatedPropertyPathDetector.java:76)
                at io.fabric8.crd.generator.visitor.AnnotatedPropertyPathDetector.visit(AnnotatedPropertyPathDetector.java:34)
                at io.sundr.builder.Visitor.visit(Visitor.java:30)
                at io.sundr.builder.VisitorWiretap.visit(VisitorWiretap.java:79)
                at io.sundr.builder.Visitable.accept(Visitable.java:67)
                at io.sundr.builder.Visitable.accept(Visitable.java:53)
                at io.sundr.builder.Visitable.accept(Visitable.java:30)
                at io.fabric8.crd.generator.visitor.AnnotatedPropertyPathDetector.visitPropertiesClasses(AnnotatedPropertyPathDetector.java:91)
                at io.fabric8.crd.generator.visitor.AnnotatedPropertyPathDetector.visit(AnnotatedPropertyPathDetector.java:76)
                at io.fabric8.crd.generator.visitor.AnnotatedPropertyPathDetector.visit(AnnotatedPropertyPathDetector.java:34)
                at io.sundr.builder.Visitor.visit(Visitor.java:30)
                at io.sundr.builder.VisitorWiretap.visit(VisitorWiretap.java:79)
                at io.sundr.builder.Visitable.accept(Visitable.java:67)
                at io.sundr.builder.Visitable.accept(Visitable.java:53)
                at io.sundr.builder.Visitable.accept(Visitable.java:30)
                at io.fabric8.crd.generator.AbstractCustomResourceHandler.visitTypeDefSequentially(AbstractCustomResourceHandler.java:116)
                at io.fabric8.crd.generator.AbstractCustomResourceHandler.visitTypeDef(AbstractCustomResourceHandler.java:109)
                at io.fabric8.crd.generator.AbstractCustomResourceHandler.handle(AbstractCustomResourceHandler.java:77)
                at io.fabric8.crd.generator.v1.CustomResourceHandler.handle(CustomResourceHandler.java:98)
                at io.fabric8.crd.generator.CRDGenerator.lambda$detailedGenerate$5(CRDGenerator.java:177)
                at java.base/java.util.HashMap$Values.forEach(HashMap.java:1073)
                at io.fabric8.crd.generator.CRDGenerator.detailedGenerate(CRDGenerator.java:177)
                at io.quarkiverse.operatorsdk.deployment.CRDGeneration.generate(CRDGeneration.java:83)
                at io.quarkiverse.operatorsdk.deployment.CRDGenerationBuildStep.generateCRDs(CRDGenerationBuildStep.java:91)
                at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
                at java.base/java.lang.reflect.Method.invoke(Method.java:580)
                at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
                at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
                at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
                at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
                at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
                at java.base/java.lang.Thread.run(Thread.java:1583)
                at org.jboss.threads.JBossThread.run(JBossThread.java:501)
@metacosm
Copy link
Member

Hi @kdubb, is there a way for me to replicate the issue?
To be clear, you're using QOSDK 6.5.0 with Quarkus 3.6.4, correct? Are you using the Quarkus platform BOM or the QOSDK BOM? Which version of java are you using?

@metacosm metacosm self-assigned this Jan 10, 2024
@kdubb
Copy link
Author

kdubb commented Mar 4, 2024

@metacosm Sorry for not responding. I thought I had.

Yes QOSDK 6.5.0 and Quarkus 3.6.4. It also happens now with QOSDK 6.6.2 and Quarkus 3.7.1.

We are using the Quarkus platform BOM and Java 17.

@metacosm
Copy link
Member

metacosm commented Mar 4, 2024

Would you be able to share your model since it seems to happen during CRD generation?

@kdubb
Copy link
Author

kdubb commented Mar 14, 2024

@metacosm You're onto something here. We have to subprojects in a Gradle build that share a common "operators" dependency. One is a trust operator for generating certificate bundles and projecting them into needed namespaces handling rotation; it's pretty simple. The other is a Vault operator that manages Vault items required by our services; it's much more in-depth and has a lot of model objects.

I'm just realizing that the Vault operator project is where we get the failure. If I attempt to build the simpler trust operator project it builds fine with no error.

Our build is scattered across common deps, a common operator dep and then the operator projects themselves; it won't be easy to rip it apart and get it to build in a manner I can share.

Any thoughts, based on the stacktrace and this new information, on what exactly might be causing this? Remember it worked with previous Q and QOSDK versions (which we're attempting to move off of). So it must be a change introduced after this setup

QOSDK 6.4.0 with Quarkus 3.5.3 (and the Fabric8 client version locked to 6.7.2 because of a Q dep change)

@kdubb
Copy link
Author

kdubb commented Mar 14, 2024

@metacosm By deleting model files until I don't get the error, I was able to narrow it down to a "spec" class that has multiple properties derived from the same base class.

E.g. (in kotlin)

abstract class Config {}
class SomeConfig: Config {}
class OtherConfig: Config {}

class SomeSpec(
  val someConfig: SomeConfig?
  val otherConfig: OtherConfig?
)

If I remove either someConfig or otherConfig it does not produce the error.

@kdubb
Copy link
Author

kdubb commented Mar 14, 2024

Note that if I change one of the properties to use a different class hierarchy it does not produce the error...

E.g. (in kotlin)

abstract class AConfig {}
class SomeConfig: AConfig {}

abstract class BConfig {}
class OtherConfig: BConfig {}

class SomeSpec(
  val someConfig: SomeConfig?
  val otherConfig: OtherConfig?
)

@metacosm
Copy link
Member

Just to make sure, you're not locking the fabric8 version anymore, right?

@kdubb
Copy link
Author

kdubb commented Mar 14, 2024

No not locked anymore. Currently testing with Q/3.7.2 and QOSDK/6.6.3

@iocanel
Copy link
Contributor

iocanel commented Mar 14, 2024

The issue happens because AptContext the code attempts to use AptContext without AptContext being created.

IMHO, AptContext should never be used outside of annotation processors and it's sundrio's fault that it does when GetDefinition is called or at least. I'll try to address that next week.

@metacosm
Copy link
Member

Thank you, @iocanel!

@metacosm
Copy link
Member

Any update on this, @iocanel?

@kdubb
Copy link
Author

kdubb commented Apr 19, 2024

@iocanel Any news? Sorry to ping again, but this has stopped us for a while.

@iocanel
Copy link
Contributor

iocanel commented Apr 23, 2024

@kdubb: created sundrio/sundrio#472

@kdubb
Copy link
Author

kdubb commented Jun 20, 2024

@iocanel Do you know if this has landed in Quarkus, if so, what version?

@metacosm
Copy link
Member

Hi @kdubb, is this still an issue?

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

No branches or pull requests

3 participants