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

[OpenShift-Maven-Plugin] java.lang.ClassCastException during oc:build when OpenShift not present #815

Closed
rohanKanojia opened this issue Aug 2, 2021 · 1 comment · Fixed by #824
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rohanKanojia
Copy link
Member

Description

Info

In recent release v1.4.0, I notice that when OpenShift is not present; OpenShift Maven Plugin build goal fails with a ClassCastException:

[INFO] --- openshift-maven-plugin:1.4.0:build (default-cli) @ spring-boot-helm ---
[INFO] oc: Using OpenShift build with strategy S2I
[INFO] oc: Running in OpenShift mode
[INFO] oc: Running generator spring-boot
[INFO] oc: spring-boot: Using Docker image quay.io/jkube/jkube-java-binary-s2i:0.0.9 as base / builder
[ERROR] oc: Failed to execute the build [class io.fabric8.kubernetes.client.DefaultKubernetesClient cannot be cast to class io.fabric8.openshift.client.OpenShiftClient (io.fabric8.kubernetes.client.DefaultKubernetesClient and io.fabric8.openshift.client.OpenShiftClient are in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @74aa9c72)]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.249 s
[INFO] Finished at: 2021-08-02T15:22:24+05:30
[INFO] ------------------------------------------------------------------------

In v1.3.0, I used to get a correct message about OpenShift cluster not getting detected:

[INFO] --- openshift-maven-plugin:1.3.0:build (default-cli) @ spring-boot-helm ---
[INFO] oc: Using OpenShift build with strategy S2I
[INFO] oc: Running in OpenShift mode
[INFO] oc: Running generator spring-boot
[INFO] oc: spring-boot: Using Docker image quay.io/jkube/jkube-java-binary-s2i:0.0.9 as base / builder
[ERROR] oc: Failed to execute the build [OpenShift platform has been specified but OpenShift has not been detected!]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.661 s
[INFO] Finished at: 2021-08-02T15:22:36+05:30
[INFO] ------------------------------------------------------------------------
  • Eclipse JKube version : 1.4.0
  • Maven version (mvn -v) :
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /opt/apache-maven
Java version: 11.0.11, vendor: Oracle Corporation, runtime: /usr/java/jdk-11.0.11
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.13.4-200.fc34.x86_64", arch: "amd64", family: "unix"
  • Kubernetes / Red Hat OpenShift setup and version :

  • If it's a bug, how to reproduce : Go to any quickstart and build in openshift profile with openshift not present

  • If it's a feature request, what is your use case :

  • Sample Reproducer Project : [GitHub Clone URL]

@manusa manusa added the bug Something isn't working label Aug 2, 2021
@manusa manusa added this to the 1.5.0 milestone Aug 2, 2021
@manusa manusa added this to Planned in Sprint #205 + #206 Aug 2, 2021
@rohanKanojia rohanKanojia self-assigned this Aug 4, 2021
@rohanKanojia
Copy link
Member Author

My initial assumption was wrong. This issue doesn't seem to be caused by upgrading to KubernetesClient but a recent refactor related to BuildService (#772), see https://github.com/eclipse/jkube/pull/772/files#r682814511.

I confirmed this by doing a git bisect. Here are my logs:

git bisect start
# bad: [b25157bcafb4a9b6b738a0fce018fc3803e6b78e] refactor: remove code smells in KitLogger.java (#812)
git bisect bad b25157bcafb4a9b6b738a0fce018fc3803e6b78e
# good: [773a224e8c415f08beb27c504046369c447d3f36] [RELEASE] Updated project version to 1.3.0
git bisect good 773a224e8c415f08beb27c504046369c447d3f36
# good: [2a2c30a78dfb26afb89282c67e6c528429b9c34e] Fix #653: `k8s:watch` port-forward websocket error due to wrong arguments in PortForwardService
git bisect good 2a2c30a78dfb26afb89282c67e6c528429b9c34e
# bad: [7b5d157becc8ec3b734c4bdf51c27e6627f3f2f6] Fix #551: Add Configuration options to IngressEnricher
git bisect bad 7b5d157becc8ec3b734c4bdf51c27e6627f3f2f6
# bad: [97ea5f7c645188f32d9c1d27b2a5fd49bb5914a0] Fix #253: Refactor JKubeServiceHub's BuildService election mechanism
git bisect bad 97ea5f7c645188f32d9c1d27b2a5fd49bb5914a0
# good: [e2199a0a91f3dbf859a80196e464744675f101d1] adding missing @Override annotation
git bisect good e2199a0a91f3dbf859a80196e464744675f101d1
# good: [8b34b70a56e7c029d73bcb20917620e7d6553eef] Fix #756: Service re-apply error happening during `k8s:watch`
git bisect good 8b34b70a56e7c029d73bcb20917620e7d6553eef
# good: [f4059bb209db55f4e8bc1c3b13bae275fd98571c] Remove redundant code from Arguments.java (#766)
git bisect good f4059bb209db55f4e8bc1c3b13bae275fd98571c
# first bad commit: [97ea5f7c645188f32d9c1d27b2a5fd49bb5914a0] Fix #253: Refactor JKubeServiceHub's BuildService election mechanism

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Aug 4, 2021
…ift not present

Using OpenShiftClient to store result of `clusterAccess.createDefaultClient()` seems to
cause ClassCastException when return value is of type DefaultKubernetesClient.

Instead, Use a temporaty KubernetesClient variable for `clusterAccess.createDefaultClient()`
and type cast it to OpenShiftClient in case it's adaptable to OpenShiftClient interface.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@rohanKanojia rohanKanojia moved this from Planned to In progress in Sprint #205 + #206 Aug 5, 2021
@rohanKanojia rohanKanojia moved this from In progress to Review in Sprint #205 + #206 Aug 5, 2021
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Aug 5, 2021
…ift not present

Using OpenShiftClient to store result of `clusterAccess.createDefaultClient()` seems to
cause ClassCastException when return value is of type DefaultKubernetesClient.

Instead, Use a temporaty KubernetesClient variable for `clusterAccess.createDefaultClient()`
and type cast it to OpenShiftClient in case it's adaptable to OpenShiftClient interface.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Sprint #205 + #206 automation moved this from Review to Done Aug 5, 2021
manusa pushed a commit that referenced this issue Aug 5, 2021
Using OpenShiftClient to store result of `clusterAccess.createDefaultClient()` seems to
cause ClassCastException when return value is of type DefaultKubernetesClient.

Instead, Use a temporaty KubernetesClient variable for `clusterAccess.createDefaultClient()`
and type cast it to OpenShiftClient in case it's adaptable to OpenShiftClient interface.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants