Launching linkerd in Intellij


#1

Hi,
I am trying to launch/debug from intellij. I compiled the source from ./compile and run tests with /tests in sbt console. Still when I try to launch Main - I get the following errors. Any idea?

Error:(10, 12) Router is already defined as case class Router
case class Router(
Error:(17, 8) Router is already defined as object Router
object Router {
Error:(124, 12) Counter is already defined as case class Counter
case class Counter(
Error:(129, 8) Counter is already defined as object Counter
object Counter {
Error:(196, 12) Gauge is already defined as case class Gauge
case class Gauge(
Error:(201, 8) Gauge is already defined as object Gauge
object Gauge {
Error:(268, 12) UsageMessage is already defined as case class UsageMessage
case class UsageMessage(
Error:(282, 8) UsageMessage is already defined as object UsageMessage
object UsageMessage {


#2

If I delete that folder, the compilation error goes away. But running in to the following error
I 0731 05:58:36.228 UTC THREAD1: linkerd 1.1.2-SNAPSHOT (rev=aafd44a53259fd35f55b986b29b32b0072f796ca) built at 20170731-112833
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id ‘http’ into a subtype of [simple type, class io.buoyant.linkerd.RouterConfig]: known type ids = [RouterConfig]


#3

Hi @rama,

This is because IntelliJ has a hard time dealing with the source code generated from compiled Protocol Buffers in Linkerd.

You have a couple of options here:

  • Use SBT to compile Linkerd: Add an SBT task configuration to IntelliJ to run the sbt compile task, and then modify the configuration you’re trying to run to call the sbt compile task rather than using IntelliJ’s built in “Build” task. This may take longer to compile than if you let IntelliJ do it, and you won’t get IntelliJ’s nice GUI error messages, but it should work.
  • Remove the compiled protobufs from IntelliJ’s sources: Open up the “Project Structure” window in IntelliJ, select the “linkerd-core” module, and remove all paths containing src_managed from the “Sources” section. This will allow you to compile Linkerd using IntelliJ’s “Build” task. However, since IntelliJ will no longer know about the compiled protobuf sources, if you open any files that use symbols defined in protobufs, IntelliJ will mark them as unknown. This isn’t a big problem, as you can just dismiss these errors, but don’t be alarmed.

Unless you’re planning on making changes to protobuf definitions, you’ll probably be better off with the second option.

Please let me know if you have any additional questions!


#4

Thanks. As I mentioned in my earlier reply, if I delete the folder (Option 2) in your mail, that error goes away. Now I get the following error
But running in to the following error
I 0731 05:58:36.228 UTC THREAD1: linkerd 1.1.2-SNAPSHOT (rev=aafd44a53259fd35f55b986b29b32b0072f796ca) built at 20170731-112833
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id ‘http’ into a subtype of [simple type, class io.buoyant.linkerd.RouterConfig]: known type ids = [RouterConfig]

My config is
admin:
port: 7080

routers:

  • protocol: http
    label: outgoing_http1
    servers:
  • port: 7081
    ip: 0.0.0.0
    originator: true

#5

Hi again @rama,

You don’t want to delete the folder – you need it to compile Linkerd. You want to tell IntelliJ not to mark it as sources, from the “Project Structure” window.

Let me know if that works!


#6

This indicates that you’re probably not picking up the resource folders. Each protocol is defined as a linkerd plugin and this suggests that you probably don’t have any plugins loaded. Using sbt (or having intelliJ use sbt) is the officially supported way of building Linkerd.


#7

Alex,
Thanks. I did try to run with sbt as follows

./sbt “project linkerd-main” “run-main io.buoyant.linkerd.Main linkerd.yaml”

But still I get the same error. How do I load the resources/plugins you
were mentioning? Sorry it may be a trivial question but I am new to Scala.

Thanks,

Rama


#8

The recommended way to run linkerd from sbt is

./sbt 'linkerd/bundle:run linkerd/examples/http.yaml'

#9

Awesome. Thanks. I am able to run linkerd with this locally