kafka-ops / julie

A solution to help you build automation and gitops in your Apache Kafka deployments. The Kafka gitops!
MIT License
417 stars 113 forks source link

Throws java.lang.IllegalArgumentException while execute the julie command #559

Open VICT0RW0NG opened 1 year ago

VICT0RW0NG commented 1 year ago

Describe the bug We are trying to use Julie to manage the Kafka artifacts and RBAC rules for Confluent 7.1.1. About the RBAC setting in Confluent we are using User / Group Principle to set the rules for different artifacts (e.g, topic , connectors etc.). Once we execute the julie script, it throws Throws java.lang.IllegalArgumentException , suspect that we have some special characters has been set in the group principle shown in the reproduce section. After that we based on the API shown in the error log and perform API testing via postman , we can get the principle details.

To Reproduce Steps to reproduce the behavior:

  1. Run the command docker run --network host -v /mnt/c/julie/foo_demo/production:/foo_demo purbon/kafka-topology-builder:4.4.1 julie-ops-cli.sh --clientConfig /foo_demo/project-config.properties --topology /foo_demo/topology.yaml --brokers hk01lconfbkr01vp.aswatson.net:9093,hk01lconfbkr02vp.aswatson.net:9093,hk01lconfbkr03vp.aswatson.net:9093
  2. Console error log
    09:48:27.498 [main] DEBUG org.apache.kafka.clients.admin.KafkaAdminClient - [AdminClient clientId=adminclient-1] Kafka admin client closed.
    java.lang.IllegalArgumentException: Illegal character in path at index 107: https://hk01lconfbkr01vp.aswatson.net:8090/security/1.0/principals/Group:s-ConRBAC.PROD.Techlab,OU=Security Groups,OU=Groups,OU=HK,OU=Regions,DC=aswgroup/roles/DeveloperRead/resources
        at java.base/java.net.URI.create(URI.java:883)
        at com.purbon.kafka.topology.clients.JulieHttpClient.setupARequest(JulieHttpClient.java:71)
        at com.purbon.kafka.topology.clients.JulieHttpClient.postRequest(JulieHttpClient.java:176)
        at com.purbon.kafka.topology.clients.JulieHttpClient.doPost(JulieHttpClient.java:171)
        at com.purbon.kafka.topology.api.mds.MDSApiClient.lookupResources(MDSApiClient.java:292)
        at com.purbon.kafka.topology.api.mds.MDSApiClient.lookupResourcesForKafka(MDSApiClient.java:274)
        at com.purbon.kafka.topology.roles.RBACProvider.listAcls(RBACProvider.java:72)
        at com.purbon.kafka.topology.AccessControlManager.printCurrentState(AccessControlManager.java:393)
        at com.purbon.kafka.topology.JulieOps.run(JulieOps.java:216)
        at com.purbon.kafka.topology.JulieOps.run(JulieOps.java:227)
        at com.purbon.kafka.topology.CommandLineInterface.processTopology(CommandLineInterface.java:212)
        at com.purbon.kafka.topology.CommandLineInterface.run(CommandLineInterface.java:161)
        at com.purbon.kafka.topology.CommandLineInterface.main(CommandLineInterface.java:147)
    Caused by: java.net.URISyntaxException: Illegal character in path at index 107: https://hk01lconfbkr01vp.aswatson.net:8090/security/1.0/principals/Group:s-ConRBAC.PROD.Techlab,OU=Security Groups,OU=Groups,OU=HK,OU=Regions,DC=aswgroup/roles/DeveloperRead/resources
        at java.base/java.net.URI$Parser.fail(URI.java:2913)
        at java.base/java.net.URI$Parser.checkChars(URI.java:3084)
        at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3166)
        at java.base/java.net.URI$Parser.parse(URI.java:3114)
        at java.base/java.net.URI.<init>(URI.java:600)
        at java.base/java.net.URI.create(URI.java:881)
        ... 12 more

Expected behavior Expected that would not throws an error, we have tried to attempt the same API via postman, it can return successfully,

Screenshots Error throws in the Console image

Postman image

Runtime (please complete the following information): Julie version: 4.4.1 Docker

dwimsey commented 1 year ago

Looks like the space in between the Security Groups OU is likely the problem - its not being URI encoded before being passed to the Http request library.

https://github.com/kafka-ops/julie/blob/3d25f29da9bed39cc2ce2b6c8363e31398e73e32/src/main/java/com/purbon/kafka/topology/api/mds/MDSApiClient.java#L291

URI encoding for these values will need to be done to fix this problem