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

Sundrio bump to 0.101.3 causes problems with cert-manager generated code (getClass) #5564

Closed
manusa opened this issue Nov 2, 2023 · 4 comments · Fixed by #5566
Closed

Sundrio bump to 0.101.3 causes problems with cert-manager generated code (getClass) #5564

manusa opened this issue Nov 2, 2023 · 4 comments · Fixed by #5566
Assignees
Milestone

Comments

@manusa
Copy link
Member

manusa commented Nov 2, 2023

Description

Relates to

When bumping the sundrio dependency to the latest release that overcomes the Type inference problem, the cert-manager integration test no longer compiles:

2023-11-01T12:26:06.8677565Z [INFO] [INFO] -------------------------------------------------------------
2023-11-01T12:26:06.8678902Z [INFO] [ERROR] COMPILATION ERROR : 
2023-11-01T12:26:06.8680067Z [INFO] [INFO] -------------------------------------------------------------
2023-11-01T12:26:06.8687080Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/acme/v1/challengespec/solver/http01/IngressFluent.java:[43,17] getClass() in io.cert_manager.acme.v1.challengespec.solver.http01.IngressFluent cannot override getClass() in java.lang.Object
2023-11-01T12:26:06.8771968Z [INFO]   overridden method is final
2023-11-01T12:26:06.8777241Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/acme/v1/challengespec/solver/http01/IngressFluent.java:[164,33] incomparable types: java.lang.String and java.lang.Class<capture#1 of ? extends java.lang.Object>
2023-11-01T12:26:06.8783749Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/v1/clusterissuerspec/acme/solvers/http01/IngressFluent.java:[43,17] getClass() in io.cert_manager.v1.clusterissuerspec.acme.solvers.http01.IngressFluent cannot override getClass() in java.lang.Object
2023-11-01T12:26:06.8787257Z [INFO]   overridden method is final
2023-11-01T12:26:06.8790763Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/v1/clusterissuerspec/acme/solvers/http01/IngressFluent.java:[164,33] incomparable types: java.lang.String and java.lang.Class<capture#2 of ? extends java.lang.Object>
2023-11-01T12:26:06.8797114Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/v1/issuerspec/acme/solvers/http01/IngressFluent.java:[43,17] getClass() in io.cert_manager.v1.issuerspec.acme.solvers.http01.IngressFluent cannot override getClass() in java.lang.Object
2023-11-01T12:26:06.8800469Z [INFO]   overridden method is final
2023-11-01T12:26:06.8803880Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/v1/issuerspec/acme/solvers/http01/IngressFluent.java:[164,33] incomparable types: java.lang.String and java.lang.Class<capture#3 of ? extends java.lang.Object>
2023-11-01T12:26:06.8807678Z [INFO] [INFO] 6 errors 
2023-11-01T12:26:06.8808559Z [INFO] [INFO] -------------------------------------------------------------
2023-11-01T12:26:06.8809742Z [INFO] [INFO] ------------------------------------------------------------------------
2023-11-01T12:26:06.8810513Z [INFO] [INFO] BUILD FAILURE
2023-11-01T12:26:06.8811304Z [INFO] [INFO] ------------------------------------------------------------------------
2023-11-01T12:26:06.8812099Z [INFO] [INFO] Total time:  32.722 s
2023-11-01T12:26:06.8812784Z [INFO] [INFO] Finished at: 2023-11-01T12:26:06Z
2023-11-01T12:26:06.8813707Z [INFO] [INFO] ------------------------------------------------------------------------
2023-11-01T12:26:06.8815990Z [INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project cert-manager-extension: Compilation failure: Compilation failure: 
2023-11-01T12:26:06.8821047Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/acme/v1/challengespec/solver/http01/IngressFluent.java:[43,17] getClass() in io.cert_manager.acme.v1.challengespec.solver.http01.IngressFluent cannot override getClass() in java.lang.Object
2023-11-01T12:26:06.8824515Z [INFO] [ERROR]   overridden method is final
2023-11-01T12:26:06.8828022Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/acme/v1/challengespec/solver/http01/IngressFluent.java:[164,33] incomparable types: java.lang.String and java.lang.Class<capture#1 of ? extends java.lang.Object>
2023-11-01T12:26:06.8834398Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/v1/clusterissuerspec/acme/solvers/http01/IngressFluent.java:[43,17] getClass() in io.cert_manager.v1.clusterissuerspec.acme.solvers.http01.IngressFluent cannot override getClass() in java.lang.Object
2023-11-01T12:26:06.8838056Z [INFO] [ERROR]   overridden method is final
2023-11-01T12:26:06.8841688Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/v1/clusterissuerspec/acme/solvers/http01/IngressFluent.java:[164,33] incomparable types: java.lang.String and java.lang.Class<capture#2 of ? extends java.lang.Object>
2023-11-01T12:26:06.8854216Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/v1/issuerspec/acme/solvers/http01/IngressFluent.java:[43,17] getClass() in io.cert_manager.v1.issuerspec.acme.solvers.http01.IngressFluent cannot override getClass() in java.lang.Object
2023-11-01T12:26:06.8861046Z [INFO] [ERROR]   overridden method is final
2023-11-01T12:26:06.8864686Z [INFO] [ERROR] /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/target/generated-sources/annotations/io/cert_manager/v1/issuerspec/acme/solvers/http01/IngressFluent.java:[164,33] incomparable types: java.lang.String and java.lang.Class<capture#3 of ? extends java.lang.Object>
2023-11-01T12:26:06.8867846Z [INFO] [ERROR] -> [Help 1]
2023-11-01T12:26:06.8868313Z [INFO] [ERROR] 
2023-11-01T12:26:06.8869213Z [INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
2023-11-01T12:26:06.8870572Z [INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2023-11-01T12:26:06.8871416Z [INFO] [ERROR] 
2023-11-01T12:26:06.8872396Z [INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
2023-11-01T12:26:06.8873997Z [INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
2023-11-01T12:26:06.9164574Z [INFO] run post-build script verify.groovy
2023-11-01T12:26:06.9189486Z [INFO] Running post-build script: /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/verify.groovy
2023-11-01T12:26:07.9145035Z [INFO] Finished post-build script: /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/verify.groovy
2023-11-01T12:26:07.9151666Z [INFO]   The build exited with code 1. See /home/runner/work/kubernetes-client/kubernetes-client/java-generator/it/target/it/cert-manager/build.log for details.
2023-11-01T12:26:07.9159467Z [INFO]           cert-manager/pom.xml ............................. FAILED (35.31 s)

I'm going to disable this test to bump the Sunrio depenency, but should be fixed and reenabled before releasing 6.9.2.

/cc @andreaTP

@manusa manusa added this to the 6.9.2 milestone Nov 2, 2023
@manusa manusa moved this to Planned in Eclipse JKube Nov 2, 2023
@manusa manusa changed the title Sundrio bump to 0.101.3 cuases problems with cert-manager generated code Sundrio bump to 0.101.3 cuases problems with cert-manager generated code (getClass) Nov 2, 2023
@manusa manusa self-assigned this Nov 2, 2023
@manusa manusa moved this from Planned to In Progress in Eclipse JKube Nov 2, 2023
@manusa
Copy link
Member Author

manusa commented Nov 2, 2023

For some reason, the compiled Ingress class is getting generated with the proper sanitized fields but it includes an extra-setter:

@JsonInclude(Include.NON_NULL)
@JsonPropertyOrder({"class", "ingressTemplate", "name", "podTemplate", "serviceType"})
@JsonDeserialize(
  using = JsonDeserializer.None.class
)
public class Ingress implements KubernetesResource {
//...
  @JsonProperty("class")
  @JsonPropertyDescription("The ingress class to use when creating Ingress resources to solve ACME challenges that use this challenge solver. Only one of 'class' or 'name' may be specified.")
  @JsonSetter(
    nulls = Nulls.SKIP
  )
  private String _class;
//...
  public Ingress() {
  }

  public String get_class() {
    return this._class;
  }

  public void set_class(String _class) {
    this._class = _class;
  }
//...
  @JsonProperty("class")
  @JsonSetter(
    nulls = Nulls.SKIP
  )
  public void setClass(String _class) {
    this._class = _class;
  }
}

I'm trying to reproduce the behavior in a test (Approval), but I'm not able to. In the test, the extra-setter is not created.

@manusa
Copy link
Member Author

manusa commented Nov 2, 2023

OK, I think that the root-cause for this is the usage of the:

@lombok.Setter()
@lombok.experimental.Accessors(prefix = {
    "_",
    ""
})

annotations that now work properly (probably after sundrio/sundrio#439)

@manusa
Copy link
Member Author

manusa commented Nov 2, 2023

So the problem lies on Sundrio and is specific to this configuration combination.

The following list summarizes the problem:

  • A CRD contains a field/property with a reserved keyword (such as class)
  • The CRD generator is configured to add the sundrio+lombok annotations
  • The class is generated
    • The reserved keyword is properly sanitized and a _ is prepended
    • Getters and Setters are properly generated (for example get_class and set_class)
    • The class is annotated with:
      @lombok.Setter()
      @lombok.experimental.Accessors(prefix = {"_",""})
      @io.sundr.builder.annotations.Buildable
      
  • When the class is compiled:
    • ?? lombok creates the extra-setter (for example setClass)
    • Sundrio generates a Fluent with the illegal getter overriding the one for Object (public String getClass())

@manusa
Copy link
Member Author

manusa commented Nov 2, 2023

I think we can remove those lombok annotations now.

In #5384, we introduced getter/setter creation. Trying this as a fix now.

@manusa manusa changed the title Sundrio bump to 0.101.3 cuases problems with cert-manager generated code (getClass) Sundrio bump to 0.101.3 causes problems with cert-manager generated code (getClass) Nov 2, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Eclipse JKube Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant