Open cmoulliard opened 4 months ago
The error is coming from the *
value of the CRD ManagementPolicies enums that f8/sundrio tries to map to a class.
If we remove from the CRD the *
, that works but now we got another error as no values are declared:
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `io.crossplane.helm.v1beta1.ReleaseSpec$ManagementPolicies` from String "*": not one of the valu
es accepted for Enum class: [Update, Delete, Create, LateInitialize, Observe]
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 996] (through reference chain: io.crossplane.helm.v1beta1.Release["spec"]->io.crossplane.helm.v1beta1
.ReleaseSpec["managementPolicies"]->java.util.ArrayList[0])
at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67)
at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1958)
at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:1245)
at com.fasterxml.jackson.databind.deser.std.EnumDeserializer._deserializeAltString(EnumDeserializer.java:440)
at com.fasterxml.jackson.databind.deser.std.EnumDeserializer._fromString(EnumDeserializer.java:304)
at com.fasterxml.jackson.databind.deser.std.EnumDeserializer.deserialize(EnumDeserializer.java:273)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:359)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at io.fabric8.kubernetes.model.jackson.SettableBeanPropertyDelegate.deserializeAndSet(SettableBeanPropertyDelegate.java:134)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:310)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at io.fabric8.kubernetes.model.jackson.SettableBeanPropertyDelegate.deserializeAndSet(SettableBeanPropertyDelegate.java:134)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:310)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2125)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1501)
at io.fabric8.kubernetes.client.utils.KubernetesSerialization.unmarshal(KubernetesSerialization.java:254)
... 62 more
Is there a trick ?
@aureamunoz @iocanel
The error message still mentions '*'. So, it seems that it does creep in from somewhere. Maybe the CR? To be more specific I need more context about the error and ideally a full stack trace.
a full stack trace.
Comment updated with fullstack trace.
So the issue is coming from the Release CRD definition: https://github.com/halkyonio/primaza-poc/blob/fecbea0bd9eb8e7907001878a29f341a68d78632/app/src/main/crds/helm.crossplane.io_releases.yaml and more specially the field ManagementPolicies
No matter if you set the default value as - '*'
or - Create
:
managementPolicies:
default:
- '*'
or
managementPolicies:
default:
- Create
we got the error:
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class io.crossplane.helm.v1beta1.ReleaseSpec$ManagementPolicies (java.lang.String is in module java.base of loader 'b
ootstrap'; io.crossplane.helm.v1beta1.ReleaseSpec$ManagementPolicies is in unnamed module of loader io.quarkus.bootstrap.runner.RunnerClassLoader @475530b9)
at io.crossplane.helm.v1beta1.ReleaseSpecFluent.withManagementPolicies(ReleaseSpecFluent.java:337)
Issue
When we try to create a Crossplane Helm Release CR which is what the Primaza service (KubernetesClientService -> method: createCrossplaneHelmRelease(Cluster cluster, io.halkyon.model.Service service) do during the binding, then we got an error HTTP 500 from Primaza log
The error reported is
Code: https://github.com/halkyonio/primaza-poc/blob/ecf2f80da0f48b010b2ceef29c69a7c7a30cfb35/app/src/main/java/io/halkyon/services/KubernetesClientService.java#L246
Remark: I dont really understand why it complains about the ManagementPolicies - https://github.com/crossplane/crossplane-runtime/blob/master/apis/common/v1/policies.go as the object that we are creating which is a
Release
do not include it: https://github.com/crossplane-contrib/provider-helm/blob/master/apis/release/v1beta1/types.goFrom @iocanel
"Ioannis Canellos: It seems to me that this is an issue with the generator. TBH, I've used that in that past (quarkus-kubevirt) and didn't have issues with enums.
The problem with the code is that it deserizes some code into a List however it doesn't populate the list with ManagementPolicies but with strings instead. So eventually it causes a class cast exception later on as this is unexpected."
Originally posted by @cmoulliard in https://github.com/halkyonio/primaza-poc/issues/475#issuecomment-2090306748