TNO/knowledge-engine

Exception in renew loop of KnowledgeDirectoryConnectionManager

Sophietje opened this issue · 5 comments

In GitLab by @cdemulde.openmotics.com on Oct 26, 2023, 06:58

When running the KE, it keeps throwing errors related to the Knowledge Directory (see below). Functionality seems fine at least for our purpose (not making use of a remote of distributed KD), so just wondering if this is expected or something that should be dealt with. It does clog up the logs though, being quite annoying when troubleshooting (and also unnecessarily creating logs, again, at least for our purpose).

2023-10-26 06:36:57:372 +0000 [pool-6-thread-1] ERROR RemoteKerConnectionManager - Error while querying the Knowledge Directory
java.lang.IllegalStateException: Can only retrieve Knowledge Directory infomation when REGISTERED or INTERRUPETD
	at eu.knowledge.engine.smartconnector.runtime.messaging.KnowledgeDirectoryConnection.getKnowledgeEngineRuntimeConnectionDetails(KnowledgeDirectoryConnection.java:132)
	at eu.knowledge.engine.smartconnector.runtime.messaging.KnowledgeDirectoryConnection.getOtherKnowledgeEngineRuntimeConnectionDetails(KnowledgeDirectoryConnection.java:154)
	at eu.knowledge.engine.smartconnector.runtime.messaging.RemoteKerConnectionManager.queryKnowledgeDirectory(RemoteKerConnectionManager.java:84)
	at eu.knowledge.engine.smartconnector.runtime.messaging.RemoteKerConnectionManager.scheduleQueryKnowledgeDirectory(RemoteKerConnectionManager.java:70)
	at eu.knowledge.engine.smartconnector.runtime.messaging.RemoteKerConnectionManager.lambda$start$0(RemoteKerConnectionManager.java:56)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

and

2023-10-26 06:37:04:364 +0000 [pool-11-thread-1] ERROR KnowledgeDirectoryConnection - Exception in renew loop of KnowledgeDirectoryConnectionManager
java.lang.IllegalArgumentException: URI with undefined scheme
	at java.net.http/jdk.internal.net.http.common.Utils.newIAE(Unknown Source)
	at java.net.http/jdk.internal.net.http.HttpRequestBuilderImpl.checkURI(Unknown Source)
	at java.net.http/jdk.internal.net.http.HttpRequestBuilderImpl.<init>(Unknown Source)
	at java.net.http/java.net.http.HttpRequest.newBuilder(Unknown Source)
	at eu.knowledge.engine.smartconnector.runtime.messaging.KnowledgeDirectoryConnection.tryRegister(KnowledgeDirectoryConnection.java:173)
	at eu.knowledge.engine.smartconnector.runtime.messaging.KnowledgeDirectoryConnection.lambda$start$0(KnowledgeDirectoryConnection.java:85)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

In GitLab by @barry.nouwt.tno.nl on Oct 27, 2023, 08:09

Hi @cdemulde.openmotics.com, if I understand correctly you are seeing the above errors in the Knowledge Engine Runtime (KER) logs, but you did not configure the KD_URL environment variable? That is indeed strange, because the Knowledge Directory connection should only be enabled when the KD_URL variable is provided. Can you maybe share more information about how you start your KER? So we can try and reproduce the behavior?

Best regards,

Barry

In GitLab by @cdemulde.openmotics.com on Oct 27, 2023, 08:48

Hi @barry.nouwt.tno.nl, correct, the KD_URL variable in our environment file is empty (it does exist, it's just empty: KD_URL=). We start our knowledge engine as part of a docker setup, using the following in the docker compose file:

  knowledge-engine:
    image: "{{ knowledge_engine_image }}:1.1.3"
    container_name: {{ knowledge_engine_name }}
    ports:
      - 8280:8280
      - 8081:8081
    env_file:
      - .env.interconnect
    networks:
       - interconnect

with:

knowledge_engine_image: mynubodocker.azurecr.io/openmotics/knowledge-engine
knowledge_engine_name: knowledge-engine

In GitLab by @cdemulde.openmotics.com on Oct 27, 2023, 08:58

Testing locally, it seems like just removing the KD_URL variable altogether solves the issue, so feel free to close if you think that this indeed would be the solution @barry.nouwt.tno.nl

In GitLab by @barry.nouwt.tno.nl on Oct 27, 2023, 08:58

Hi @cdemulde.openmotics.com, the exceptions are caused by the empty KD_URL environment variable. If you remove that environment variable when starting the KER, the errors disappear. If the KD_URL exists, the KER is started in distributed mode and if it does not exists, it is started in non-distributive mode.

In GitLab by @barry.nouwt.tno.nl on Oct 27, 2023, 08:59

Hey @cdemulde.openmotics.com, yes, that was indeed my proposal above 👍.

I'll close this issue indeed.