openanalytics / shinyproxy-operator

Easily run ShinyProxy on a Kubernetes cluster
https://shinyproxy.io
Apache License 2.0
36 stars 9 forks source link

KubernetesManifestsRemover NullPointerException #41

Closed gimmw closed 2 months ago

gimmw commented 11 months ago

Trying to deploy the basic unmodified 1-namespaced deployment on Kubernetes 1.26, I'm seeing the Java errors below from the sp-shinyproxy-rs-.. logs. I've tried the 3-namespaced-app-ns deployment (vanilla, or adapted to my environment with the correct proxy.kubernetes.url) with the same results.

Any clue what may be causing this or how best to further troubleshoot this issue?

2023-08-09 02:16:16.525  WARN 1 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appRecoveryFilter': Unsatisfied dependency expressed through field 'appRecoveryService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appRecoveryService': Unsatisfied dependency expressed through field 'containerBackend'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'containerBackendFactory' defined in URL [jar:file:/opt/shinyproxy/shinyproxy.jar!/BOOT-INF/lib/containerproxy-1.0.1.jar!/eu/openanalytics/containerproxy/backend/ContainerBackendFactory.class]: Invocation of init method failed; nested exception is java.lang.NullPointerException
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'containerBackendFactory' defined in URL [jar:file:/opt/shinyproxy/shinyproxy.jar!/BOOT-INF/lib/containerproxy-1.0.1.jar!/eu/openanalytics/containerproxy/backend/ContainerBackendFactory.class]: Invocation of init method failed; nested exception is java.lang.NullPointerException
...
Caused by: java.lang.NullPointerException: null
    at eu.openanalytics.containerproxy.backend.kubernetes.KubernetesManifestsRemover.lambda$getApiResources$4(KubernetesManifestsRemover.java:89) ~[containerproxy-1.0.1.jar!/:1.0.1]
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) ~[na:na]
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) ~[na:na]
...
LEDfan commented 11 months ago

Hi

The KubernetesManifestsRemover class is checking which Kubernetes resources it can access, so that it can also delete resources created by the kubernetes-additional-manifest properties. I think this is failing because you have some additional CustomResourceDefinition which does not contain the expected properties.

I created a new snapshot version openanalytics/shinyproxy-snapshot:3.1.0-SNAPSHOT-20230810.092934, can you try running this version? It should not throw the above error. However, it will also log a message similar to:

!!! ApiResource is null: persistentvolumeclaims/status, v1 !!!
gimmw commented 11 months ago

Using the snapshot version I can confirm this is working now! Thanks so much

LEDfan commented 11 months ago

Great that this releases fixes it. Could you maybe check the logs and report back if you see a line similar too:

!!! ApiResource is null: persistentvolumeclaims/status, v1 !!!

It would be good to know which CRD is causing this issue, such that we can prevent similar issues in the future.

gimmw commented 11 months ago

Yes, there are a bunch of those, all relating to KubeVirt CRDs (virtualmachineinstances.kubevirt.io, virtuavirtualmachines.kubevirt.io); e.g.:

2023-08-12 20:18:27.186  INFO 1 --- [           main] e.o.c.b.k.KubernetesManifestsRemover     : !!! ApiResource is null: expand-vm-spec, subresources.kubevirt.io/v1 !!!
2023-08-12 20:18:27.187  INFO 1 --- [           main] e.o.c.b.k.KubernetesManifestsRemover     : !!! ApiResource is null: virtualmachineinstances/vnc, subresources.kubevirt.io/v1 !!!
2023-08-12 20:18:27.187  INFO 1 --- [           main] e.o.c.b.k.KubernetesManifestsRemover     : !!! ApiResource is null: virtualmachineinstances/console, subresources.kubevirt.io/v1 !!!
2023-08-12 20:18:27.187  INFO 1 --- [           main] e.o.c.b.k.KubernetesManifestsRemover     : !!! ApiResource is null: virtualmachineinstances/portforward, subresources.kubevirt.io/v1 !!!
2023-08-12 20:18:27.187  INFO 1 --- [           main] e.o.c.b.k.KubernetesManifestsRemover     : !!! ApiResource is null: virtualmachineinstances/pause, subresources.kubevirt.io/v1 !!!
...etc
LEDfan commented 2 months ago

Hi, we released the ShinyProxy Operator 2.1.0 today, which solves this issue. I'll close this issue, please open a new issue or re-open this issue if you are still experiencing an issue.