Skip to content

Support custom LogType drivers #783

Closed

Description

@jontro

When using the docker rempote api against synology dsm it looks like they have implemented their own log driver named "db"

Currently inspecting a container gives the following exception

Caused by: com.fasterxml.jackson.databind.JsonMappingException: No enum constant class com.github.dockerjava.api.model.LogConfig$LoggingType.db (through reference chain: com.github.dockerjava.api.command.InspectContainerResponse["HostConfig"]->com.github.dockerjava.api.model.HostConfig["LogConfig"]->com.github.dockerjava.api.model.LogConfig["Type"])
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210)
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1474)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:260)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
	at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:520)
	at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:258)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
	at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:520)
	at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:258)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
	at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1470)
	at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:912)
	at com.fasterxml.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:811)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:256)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:235)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
	at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085)
	at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:874)
	at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:808)
	at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:326)
	at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:806)
	... 25 more
Caused by: java.lang.IllegalArgumentException: No enum constant class com.github.dockerjava.api.model.LogConfig$LoggingType.db
	at com.github.dockerjava.api.model.LogConfig$LoggingType$Deserializer.deserialize(LogConfig.java:116)
	at com.github.dockerjava.api.model.LogConfig$LoggingType$Deserializer.deserialize(LogConfig.java:102)
	at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:520)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:258)

Output of synology docker version

Client:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.4.2
 Git commit:   0ee7c49-synology
 Built:        Tue Dec 20 00:21:53 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.4.2
 Git commit:   0ee7c49-synology
 Built:        Tue Dec 20 00:21:53 2016
 OS/Arch:      linux/amd64

Relevant part of docker inspect

        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "db",
                "Config": {}
            },

It would be great if this could pass without throwing an exception. A log warning that it's dropped and changed to null would suffice.

There is a comment on Line 26 https://github.com/docker-java/docker-java/blob/master/src/main/java/com/github/dockerjava/api/model/LogConfig.java#L26 about unsupported drivers.

Activity

  1. jontro commented on Mar 1, 2017

    @jontro
    ContributorAuthor

    I can submit a pull request if this approach would be ok

  2. KostyaSha commented on Mar 30, 2017

    @KostyaSha
    Member

    Or maybe we need switch to String instead enum? enum could still exist as enum of Strings?

  3. jontro commented on Mar 30, 2017

    @jontro
    ContributorAuthor

    @KostyaSha Wouldn't that break backwards compatibility? Current users using getType() and setType(...) will have compile errors

  4. KostyaSha commented on Mar 30, 2017

    @KostyaSha
    Member

    It will, but i want soon make 3.1.0 with swarm support. For now i think we can simply add new log type name.

  5. jontro commented on Mar 31, 2017

    @jontro
    ContributorAuthor

    Great, I did this to solve the problem
    Weightpoint@20994a0
    Do you want me to submit it as a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions