SnuK87 / keycloak-kafka

Keycloak module to produce events to kafka

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configuration is not visible to KafkaEventListenerProviderFactory

ievgenii-shepeliuk opened this issue · comments

Hello

I'm using Keycloak in Kubernetes, using this Helm chart

I'm using add-kafka-config.cli (adjustting config file name) - the configs are added.
Also, I've added environment variables to the pod.

When finally I put a jar into deployments - I receive an error

[org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."keycloak-kafka-1.1.0-jar-with-dependencies.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."keycloak-kafka-1.1.0-jar-with-dependencies.jar".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "keycloak-kafka-1.1.0-jar-with-dependencies.jar"
        at org.jboss.as.server@15.0.1.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:189)
        at org.jboss.msc@1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
        at org.jboss.msc@1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
        at org.jboss.msc@1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1363)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NullPointerException: topic must not be null.
        at deployment.keycloak-kafka-1.1.0-jar-with-dependencies.jar//com.github.snuk87.keycloak.kafka.KafkaEventListenerProviderFactory.init(KafkaEventListenerProviderFactory.java:56)
        at org.keycloak.keycloak-services@14.0.0//org.keycloak.services.DefaultKeycloakSessionFactory.loadFactories(DefaultKeycloakSessionFactory.java:297)
        at org.keycloak.keycloak-services@14.0.0//org.keycloak.services.DefaultKeycloakSessionFactory.deploy(DefaultKeycloakSessionFactory.java:154)
        at org.keycloak.keycloak-services@14.0.0//org.keycloak.provider.ProviderManagerRegistry.deploy(ProviderManagerRegistry.java:42)
        at org.keycloak.keycloak-wildfly-server-subsystem@14.0.0//org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor.deploy(KeycloakProviderDeploymentProcessor.java:58)
        at org.jboss.as.server@15.0.1.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:182)
        ... 8 more

Basically Scope config is empty in KafkaEventListenerProviderFactory.init(..)

I've pathced the plugin to read configs parameters directly from environment variables via System.getenv(..) - and this version works just fine.

Could you please help on the issue ? I can use patched version, but I'd prefer to help debugging and fixing it.

In fact, I can propose a workaround for this

topicEvents = config.get("topicEvents", System.getenv("KAFKA_TOPIC"));
clientId = config.get("clientId", System.getenv("KAFKA_CLIENT_ID"));
bootstrapServers = config.get("bootstrapServers", System.getenv("KAFKA_BOOTSTRAP_SERVERS"));
topicAdminEvents = config.get("topicAdminEvents", System.getenv("KAFKA_ADMIN_TOPIC"));		
String eventsString = config.get("events", System.getenv("KAFKA_EVENTS"));

@ievgenii-shepeliuk Thanks for you feedback and sorry for my late response. I have been on vacation.

I will test this in a non k8s environment later and apply the changes.