1

I am working with akka clustering and trying to setup two different configs for different environments.

  • one for my local setup where I would be using seed nodes to start up my application
  • two for my production Kubernetes setup.

I tried the Config Docs from Akka that mention about the -Dconfig.resource=/dev.conf and include application in the conf files but it still keep asking for akka.discovery.method in application.conf

Below are my two config files:

application.conf

akka {
  log-config-on-start = off

  stdout-loglevel = "DEBUG"
  loglevel = "INFO"
  loggers = ["akka.event.slf4j.Slf4jLogger"]
  logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"

  log-dead-letters = on
  log-dead-letters-during-shutdown = off

  actor {
    provider = "cluster"
  }


  cluster {
    down-removal-margin = 7s

    sharding {
      least-shard-allocation-strategy {
        rebalance-threshold = 1

        max-simultaneous-rebalance = 5
      }
    }
  }
}

akka.http.server.idle-timeout = 900s
akka.http.client.idle-timeout = 900s

application-seed.conf

include "application"

akka {

  actor {
    provider = "cluster"
    serializers {
      jackson-json = "akka.serialization.jackson.JacksonJsonSerializer"
    }
  }

  discovery.method = config

  remote.artery {
    canonical {
      hostname = "127.0.0.1"
      port = 2551
    }
  }

  cluster {
    seed-nodes = [
      "akka://MyCluster@127.0.0.1:2551"]
  }
}

When I run the code with the parameter:

-D config.resource=/application-seed.conf

it throws me the error:

No default service discovery implementation configured in akka.discovery.method. Make sure to configure this setting to your preferred implementation such as 'akka-dns' in your application.conf (from the akka-discovery module).

Has anyone done this kind of a setup before?

iam.Carrot
  • 4,976
  • 2
  • 24
  • 71
  • That should work, perhaps the `application-seed.conf` doesn't end up where you think it does on the classpath? One thing you can do to debug is to enable `akka.log-config-on-start = on` in your `application.conf` and see if that gives any hints. – johanandren Jan 02 '20 at 13:34

1 Answers1

0

This looks like the values in your application-seed.conf are not overriding the values in application.conf. That is, both specify

akka {
  actor {
    provider = cluster
  }
}

However, only the application-seed.conf has the discovery method to use. Which hints to me that it's the application-seed.conf which is not being parsed properly (or not overriding the earlier statements in the application.conf).

One thing that jumps out at me, is that I see that the HOCON specification for the include keyword at https://github.com/lightbend/config/blob/master/HOCON.md#includes states that

An included file must contain an object, not an array. This is significant because both JSON and HOCON allow arrays as root values in a document.

and your application.conf contains:

akka { 
  ... stuff
}
akka.http.server.idle-timeout = 900s
akka.http.client.idle-timeout = 900s

which may be interpreted as an array? I'm not sure if they mean 'array' here to mean just in the file contents (e.g. a three element array as you have there) OR in the fully parsed configuration object (the akka.http. being merged into the main akka object.

scot
  • 1,194
  • 14
  • 26