I have followed linkerd-plugin-dev doc and developed a marathon-namer that resolves apps (services) based on the hostnames.
My configuration is as below:
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'io.buoyant.marathonHostNamer' into a subtype of [simple type, class io.buoyant.namer.NamerConfig]: known type ids = [NamerConfig, io.l5d.consul, io.l5d.curator, io.l5d.fs, io.l5d.k8s, io.l5d.k8s.external, io.l5d.marathon, io.l5d.rewrite, io.l5d.serversets, io.l5d.zkLeader]
at [Source: java.io.StringReader@6b587673; line: 9, column: 9] (through reference chain: io.buoyant.linkerd.Linker$LinkerConfig["namers"]->com.fasterxml.jackson.module.scala.deser.BuilderWrapper[0])
at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:42)
at com.fasterxml.jackson.databind.DeserializationContext.unknownTypeIdException(DeserializationContext.java:1477)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownTypeId(DeserializationContext.java:1170)
at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._handleUnknownTypeId(TypeDeserializerBase.java:282)
at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:156)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:112)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:97)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:142)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:289)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:259)
at com.fasterxml.jackson.module.scala.deser.SeqDeserializer.deserialize(SeqDeserializerModule.scala:78)
at com.fasterxml.jackson.module.scala.deser.SeqDeserializer.deserialize(SeqDeserializerModule.scala:61)
at com.fasterxml.jackson.module.scala.deser.OptionDeserializer.deserialize(OptionDeserializerModule.scala:60)
at com.fasterxml.jackson.module.scala.deser.OptionDeserializer.deserialize(OptionDeserializerModule.scala:11)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:499)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeWithErrorWrapping(BeanDeserializer.java:511)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:396)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1197)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:314)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:148)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2880)
at com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper$class.readValue(ScalaObjectMapper.scala:190)
at io.buoyant.config.Parser$$anon$1.readValue(Parser.scala:79)
at io.buoyant.linkerd.Linker$.parse(Linker.scala:81)
at io.buoyant.linkerd.Main$.loadLinker(Main.scala:61)
at io.buoyant.linkerd.Main$.main(Main.scala:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:176)
at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:175)
at scala.Option.foreach(Option.scala:257)
at com.twitter.app.App$class.nonExitingMain(App.scala:175)
at io.buoyant.linkerd.Main$.nonExitingMain(Main.scala:20)
at com.twitter.app.App$class.main(App.scala:141)
at io.buoyant.linkerd.Main$.main(Main.scala:20)
at io.buoyant.linkerd.Main.main(Main.scala)
Exception thrown in main on startup
It looks like linkerd is not loading your plugin. Is your plugin jar in the $L5D_HOME/plugins directory? Are you passing the L5D_HOME env variable to linkerd?
Yes I have set $L5D_HOME and ensure that the jar is in $L5D_HOME/plugins. I have followed the header classfier example and deployed an identifier successfully. But unable to deploy a custom namer.
Ok. The next thing Iâd check is whether linkerd is loading the plugin at all. If you start linkerd with -log.level=DEBUG it will print all loaded plugins on startup. Beyond that, itâs hard to debug without being able to see the plugin jar or the source code.
LoadService: loaded instance of class io.buoyant.namer.marathon.Marathon2Initializer for requested service io.buoyant.namer.NamerInitializer
But still I am getting the below error;
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id âio.buoyant.marathonHostNamerâ into a subtype of [simple type, class io.buoyant.namer.NamerConfig]: known type ids = [NamerConfig, io.l5d.consul, io.l5d.curator, io.l5d.fs, io.l5d.k8s, io.l5d.k8s.external, io.l5d.marathon, io.l5d.rewrite, io.l5d.serversets, io.l5d.zkLeader]
I observe that the service is loading but when I use the marathonHostNamer as in the below config
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id âio.buoyant.marathonHostNamerâ into a subtype of [simple type, class io.buoyant.namer.NamerConfig]: known type ids = [NamerConfig, io.l5d.consul, io.l5d.curator, io.l5d.fs, io.l5d.k8s, io.l5d.k8s.external, io.l5d.marathon, io.l5d.rewrite, io.l5d.serversets, io.l5d.zkLeader]
at [Source: java.io.StringReader@878537d; line: 2, column: 10] (through reference chain: io.buoyant.linkerd.Linker$LinkerConfig[ânamersâ]->com.fasterxml.jackson.module.scala.deser.BuilderWrapper[0])
at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:42)
at com.fasterxml.jackson.databind.DeserializationContext.unknownTypeIdException(DeserializationContext.java:1477)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownTypeId(DeserializationContext.java:1170)
at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._handleUnknownTypeId(TypeDeserializerBase.java:282)
at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:156)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:112)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:97)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:142)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:289)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:259)
at com.fasterxml.jackson.module.scala.deser.SeqDeserializer.deserialize(SeqDeserializerModule.scala:78)
at com.fasterxml.jackson.module.scala.deser.SeqDeserializer.deserialize(SeqDeserializerModule.scala:61)
at com.fasterxml.jackson.module.scala.deser.OptionDeserializer.deserialize(OptionDeserializerModule.scala:60)
at com.fasterxml.jackson.module.scala.deser.OptionDeserializer.deserialize(OptionDeserializerModule.scala:11)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:499)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeWithErrorWrapping(BeanDeserializer.java:511)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:396)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1197)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:314)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:148)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2880)
at com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper$class.readValue(ScalaObjectMapper.scala:190)
at io.buoyant.config.Parser$$anon$1.readValue(Parser.scala:79)
at io.buoyant.linkerd.Linker$.parse(Linker.scala:81)
at io.buoyant.linkerd.Main$.loadLinker(Main.scala:61)
at io.buoyant.linkerd.Main$.main(Main.scala:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:176)
at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:175)
at scala.Option.foreach(Option.scala:257)
at com.twitter.app.App$class.nonExitingMain(App.scala:175)
at io.buoyant.linkerd.Main$.nonExitingMain(Main.scala:20)
at com.twitter.app.App$class.main(App.scala:141)
at io.buoyant.linkerd.Main$.main(Main.scala:20)
at io.buoyant.linkerd.Main.main(Main.scala)
Exception thrown in main on startup
Itâs great that weâre seeing the LoadService line now!
It strikes me that youâre defining a io.buoyant.namer.marathon.MarathonConfig type, which conflicts with another class on the classpath (defined in linkerd). Iâd try moving the whole project out of io.buoyant to a separate namespace like com.bethleha.linkerd to avoid namespace collision. At the very least, it will make things slightly simpler to debug
Hey @bethleha â I grabbed your source code and was able to successfully build and load it as a linkerd plugin. To do so, I had to add an sbt build file and an sbt plugin for generating an assembly jar. I also reorganized your project to put everything in a separate com.bethleha package. Hereâs the updated source code: https://linkerd.slack.com/files/kl/F5NQUPD2B/marathon-namer.zip
Once youâve downloaded the update source code, build the plugin jar by running: ./sbt assembly. That will produce a jar file in target/scala-2.12/marathon-namer-assembly-0.1-SNAPSHOT.jar.
After that, download the the latest linkerd release tarball, and extract it to a new directory, with the following commands:
wget https://github.com/linkerd/linkerd/releases/download/1.0.2/linkerd-1.0.2.tgz
tar xzvf linkerd-1.0.2.tgz
cd linkerd-1.0.2
Once youâre in the linkerd directory, youâll need to create a new directory, plugins, and copy the plugin jar that you build into that directory. Something like:
When I run that command, I see the following line in the linkerd log:
D 0602 18:11:19.009 UTC THREAD1: LoadService: loaded instance of class com.bethleha.linkerd.marathon.Marathon2Initializer for requested service io.buoyant.namer.NamerInitializer
And that indicates that the plugin has successfully loaded. Give it a shot and let us know if youâre able to get everything working.