xenit-eu / nuntio

A bridge between Docker containers and the Consul service catalog.
2 stars 0 forks source link

Service registration fails during startup: envvars without = #5

Closed vierbergenlars closed 2 years ago

vierbergenlars commented 2 years ago
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    | 2022-02-23 11:40:01.538  INFO 1 --- [           main] e.x.n.i.s.NuntioApplicationNormalStartup : Running existing services registration at application startup
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    | 2022-02-23 11:40:01.578 ERROR 1 --- [           main] e.x.n.i.s.NuntioApplicationNormalStartup : Failed to register services at startup. Waiting for registration to complete before continuing.
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    | 
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    | java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.platform.docker.config.parser.InspectContainerMetadata.getEnvironment(InspectContainerMetadata.java:39) ~[nuntio-platform-docker-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.platform.docker.config.parser.RegistratorCompatibleParser.toServiceConfigurations(RegistratorCompatibleParser.java:32) ~[nuntio-platform-docker-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.platform.docker.config.parser.SwitchingServiceConfigurationParser.toServiceConfigurations(SwitchingServiceConfigurationParser.java:17) ~[nuntio-platform-docker-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.platform.docker.DockerContainerServiceDescriptionFactory.createConfiguration(DockerContainerServiceDescriptionFactory.java:45) ~[nuntio-platform-docker-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.platform.docker.DockerContainerServiceDescriptionFactory.createConfiguration(DockerContainerServiceDescriptionFactory.java:32) ~[nuntio-platform-docker-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.platform.docker.DockerContainerServiceDescriptionFactory.createServiceDescription(DockerContainerServiceDescriptionFactory.java:27) ~[nuntio-platform-docker-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.platform.docker.DockerPlatform.find(DockerPlatform.java:49) ~[nuntio-platform-docker-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.platform.docker.DockerPlatform.findAll(DockerPlatform.java:38) ~[nuntio-platform-docker-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.engine.PlatformServicesSynchronizer.syncServices(PlatformServicesSynchronizer.java:26) ~[nuntio-engine-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.integration.startup.NuntioApplicationNormalStartup.lambda$run$1(NuntioApplicationNormalStartup.java:32) ~[nuntio-integration-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at io.github.resilience4j.retry.Retry.lambda$decorateSupplier$2(Retry.java:213) ~[resilience4j-retry-1.7.1.jar!/:1.7.1]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at io.github.resilience4j.retry.Retry.executeSupplier(Retry.java:430) ~[resilience4j-retry-1.7.1.jar!/:1.7.1]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.integration.startup.NuntioApplicationNormalStartup.run(NuntioApplicationNormalStartup.java:29) ~[nuntio-integration-0.1.0.jar!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:782) ~[spring-boot-2.5.4.jar!/:2.5.4]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:772) ~[spring-boot-2.5.4.jar!/:2.5.4]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at org.springframework.boot.SpringApplication.run(SpringApplication.java:345) ~[spring-boot-2.5.4.jar!/:2.5.4]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.4.jar!/:2.5.4]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.4.jar!/:2.5.4]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at eu.xenit.nuntio.app.NuntioCoreApplication.main(NuntioCoreApplication.java:19) ~[classes!/:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[nuntio-app-0.1.0.jar:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[nuntio-app-0.1.0.jar:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[nuntio-app-0.1.0.jar:na]
nuntio_prod_nuntio.0.jyekkwlzkd0u@infra-08    |     at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[nuntio-app-0.1.0.jar:na]
vierbergenlars commented 2 years ago

The cause is that there are some containers with environment variables without value.

            "Env": [
                "http_proxy",
                "https_proxy",
                "no_proxy",
                "SERVICE_8052_NAME=awx2",
                "SERVICE_8052_TAGS=proxy-http,infra",
                "LDAPTLS_REQCERT=never",
                "PATH=/usr/pgsql-10/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=en_US.UTF-8",
                "LANGUAGE=en_US:en",
                "LC_ALL=en_US.UTF-8",
                "HOME=/var/lib/awx"
            ],

In InspectContainerMetadata these values are split by = and they are expected to result in 2 parts. This appears not to be true in all cases.

https://github.com/xenit-eu/nuntio/blob/964be094f914ec0e959145ea7c3b1f545401dbe1/nuntio-platform-docker/src/main/java/eu/xenit/nuntio/platform/docker/config/parser/InspectContainerMetadata.java#L39

vierbergenlars commented 2 years ago

The cause is that there are some containers with environment variables without value.

            "Env": [
                "http_proxy",
                "https_proxy",
                "no_proxy",
                "SERVICE_8052_NAME=awx2",
                "SERVICE_8052_TAGS=proxy-http,infra",
                "LDAPTLS_REQCERT=never",
                "PATH=/usr/pgsql-10/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=en_US.UTF-8",
                "LANGUAGE=en_US:en",
                "LC_ALL=en_US.UTF-8",
                "HOME=/var/lib/awx"
            ],