Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Bug in Abort deserialization #64

Closed
hypnoce opened this issue May 10, 2019 · 6 comments
Closed

Bug in Abort deserialization #64

hypnoce opened this issue May 10, 2019 · 6 comments

Comments

@hypnoce
Copy link

hypnoce commented May 10, 2019

Hi,

First, thanks for this library. It is a great help for us.
I was trying to register a virtual service using istio-client 1.1.0-Beta3 on istio 1.1.4.

VirtualService virtualService = istioClient.virtualService()
                .createNew()
                .withNewMetadata().withName("foo")
                .endMetadata()
                .withNewSpec()
                .addNewHost("foo")
                .addNewHttp()
                .withNewFault()
                .withNewAbort()
                .withNewPercentage(100.).withNewHttpStatusErrorType(500)
                .endAbort()
                .endFault()
                .addNewRoute()
                .withNewDestination()
                .withNewHost("foo")
                .endDestination()
                .endRoute()
                .endHttp()
                .endSpec().done();

I got the following error :

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unknown field 'percentage' (through reference chain: me.snowdrop.istio.api.networking.v1alpha3.VirtualService["spec"]->me.snowdrop.istio.api.networking.v1alpha3.VirtualServiceSpec["http"]->java.util.ArrayList[0]->me.snowdrop.istio.api.networking.v1alpha3.HTTPRoute["fault"]->me.snowdrop.istio.api.networking.v1alpha3.HTTPFaultInjection["abort"])
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:353)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1711)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:290)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3077)
	at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:241)
	... 54 more
Caused by: java.lang.IllegalArgumentException: Unknown field 'percentage'
	at me.snowdrop.istio.api.internal.ClassWithInterfaceFieldsRegistry.getFieldInfo(ClassWithInterfaceFieldsRegistry.java:115)
	at me.snowdrop.istio.api.internal.ClassWithInterfaceFieldsDeserializer.deserialize(ClassWithInterfaceFieldsDeserializer.java:78)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	... 70 more

It seems there is a discrepency between https://github.com/snowdrop/istio-java-api/blob/master/istio-common/src/main/resources/classes-with-interface-fields.yml and the auto generated me.snowdrop.istio.api.networking.v1alpha3.Abort class :

package me.snowdrop.istio.api.networking.v1alpha3;

import java.io.Serializable;
import javax.validation.Valid;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.fabric8.kubernetes.api.model.Doneable;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.sundr.builder.annotations.Buildable;
import io.sundr.builder.annotations.BuildableReference;
import io.sundr.builder.annotations.Inline;
import lombok.EqualsAndHashCode;
import lombok.ToString;


/**
 * 
 * 
 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonDeserialize(using = me.snowdrop.istio.api.internal.ClassWithInterfaceFieldsDeserializer.class)
@JsonPropertyOrder({
    "apiVersion",
    "kind",
    "metadata",
    "errorType",
    "percent",
    "percentage"
})
@ToString
@EqualsAndHashCode
@Buildable(editableEnabled = false, validationEnabled = true, generateBuilderPackage = true, builderPackage = "io.fabric8.kubernetes.api.builder", inline = {
    @Inline(type = Doneable.class, prefix = "Doneable", value = "done")
}, refs = {
    @BuildableReference(ObjectMeta.class)
})
public class Abort implements Serializable
{

    @JsonProperty("errorType")
    @JsonUnwrapped
    private me.snowdrop.istio.api.networking.v1alpha3.Abort.ErrorType errorType;
    /**
     * 
     * 
     */
    @JsonProperty("percent")
    @JsonPropertyDescription("")
    private Integer percent;
    /**
     * 
     * 
     */
    @JsonProperty("percentage")
    @JsonPropertyDescription("")
    @Valid
    private Percent percentage;
    private final static long serialVersionUID = 7121060348015116201L;

    /**
     * No args constructor for use in serialization
     * 
     */
    public Abort() {
    }

    /**
     * 
     * @param errorType
     * @param percentage
     * @param percent
     */
    public Abort(me.snowdrop.istio.api.networking.v1alpha3.Abort.ErrorType errorType, Integer percent, Percent percentage) {
        super();
        this.errorType = errorType;
        this.percent = percent;
        this.percentage = percentage;
    }

    @JsonProperty("errorType")
    public me.snowdrop.istio.api.networking.v1alpha3.Abort.ErrorType getErrorType() {
        return errorType;
    }

    @JsonProperty("errorType")
    public void setErrorType(me.snowdrop.istio.api.networking.v1alpha3.Abort.ErrorType errorType) {
        this.errorType = errorType;
    }

    /**
     * 
     * 
     */
    @JsonProperty("percent")
    public Integer getPercent() {
        return percent;
    }

    /**
     * 
     * 
     */
    @JsonProperty("percent")
    public void setPercent(Integer percent) {
        this.percent = percent;
    }

    /**
     * 
     * 
     */
    @JsonProperty("percentage")
    public Percent getPercentage() {
        return percentage;
    }

    /**
     * 
     * 
     */
    @JsonProperty("percentage")
    public void setPercentage(Percent percentage) {
        this.percentage = percentage;
    }

    public interface ErrorType extends Serializable
    {


    }

}

Thanks !

@hypnoce hypnoce changed the title Discrepency Bug in Abort deserialization May 10, 2019
@metacosm
Copy link
Member

I will take a look as soon as possible

@metacosm
Copy link
Member

@hypnoce there is indeed a bug that should be addressed soon. Thank you for the report and the investigation!

metacosm added a commit that referenced this issue May 10, 2019
@metacosm
Copy link
Member

This issue should be fixed now, I will release a new beta version.

@hypnoce
Copy link
Author

hypnoce commented May 10, 2019

Thanks !

@metacosm
Copy link
Member

@hypnoce
Copy link
Author

hypnoce commented May 11, 2019

I'm using it to programmatically inject faults in a controlled way to simulate failure scenarios and validate the behavior of our services. I use it in conjunction with selenium to drive the application and the base k8s fabric8 client to retrieve logs and control lifecycle of pods.

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

No branches or pull requests

2 participants