You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/07/17 10:47:34 UTC

[GitHub] [pulsar] freeznet commented on issue #4746: [go function] fix: go function should parse conf content first

freeznet commented on issue #4746: [go function] fix: go function should parse conf content first
URL: https://github.com/apache/pulsar/pull/4746#issuecomment-512203165
 
 
   @sijie 
   
   Here is the background, we compiled a test golang function and use `pulsar-admin` to create the function to pulsar (ref: https://pulsar.apache.org/docs/en/functions-quickstart/#write-and-run-a-go-function) , once function created & triggered, we get an panic error 
   
   ```
   10:24:15.909 [function-timer-thread-90-1] INFO  org.apache.pulsar.functions.runtime.ProcessRuntime - ProcessBuilder starting the process with args /tmp/pulsar_functions/public/default/gofunc/0/examplepulsar -instance-conf {"pulsarServiceURL":"pulsar://131c8e643d19:6650","instanceID":0,"funcID":"6d46110a-084a-4ef4-b021-53f90028bedc","funcVersion":"afa67c9f-1061-469b-8f82-6b15acee5401","maxBufTuples":1024,"port":0,"clusterName":"standalone","killAfterIdleMs":0,"tenant":"public","nameSpace":"default","name":"gofunc","className":"","logTopic":"","processingGuarantees":0,"secretsMap":"","runtime":0,"autoAck":true,"parallelism":1,"subscriptionType":0,"timeoutMs":0,"subscriptionName":"","cleanupSubscription":true,"sourceSpecsTopic":"persistent://public/default/backwards","sourceSchemaType":"","receiverQueueSize":0,"sinkSpecsTopic":"persistent://public/default/forwards","sinkSchemaType":"","cpu":1.0,"ram":1073741824,"disk":10737418240,"maxMessageRetries":0,"deadLetterTopic":"","regexPatternSubscription":false}
   10:24:15.915 [function-timer-thread-90-1] INFO  org.apache.pulsar.functions.runtime.ProcessRuntime - Started process successfully
   2019/07/17 10:24:15.930 log.go:76: [error] not found conf file, err:open /root/github.com/apache/pulsar/pulsar-function-go/conf/conf.yaml: no such file or directory
   panic: config file is nil.
   ```
   
   from the log i traced to `pulsar-function-go/conf` package. After some code digging, i noticed that `instance-conf-path` will always remain to the default value (`HOME_PATH+github.com/apache/pulsar/pulsar-function-go/conf/conf.yaml`) according to (ref: https://github.com/apache/pulsar/blob/6ff1bbae0fe230eb72d62574d7685a745f884416/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java#L223 ) and (ref: https://github.com/apache/pulsar/blob/6ff1bbae0fe230eb72d62574d7685a745f884416/pulsar-function-go/conf/conf.go#L126 ).
   
   Then i got following problems:
   
   - the default settings comes from `HOME_PATH+github.com/apache/pulsar/pulsar-function-go/conf/conf.yaml`, which normally not exist in production env, so i assume this `conf.yaml` is not default settings. Also, the default path is quite strange for production use.
   - if the default settings file is not exist, then `yamlFile, err := ioutil.ReadFile(confFilePath)` will throw a panic error with `not found conf file`, and the function failed.
   
   Apparently, when golang function triggered with process runtime, no `instance-conf-path` will pass to function executable, and the default path will always cause panic under production env unless user manually create the strange path config file.
   
   As the result, i committed this PR to solve the problem we got. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services