-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Issue 6170][functions] add custom property option to functions #6348
[Issue 6170][functions] add custom property option to functions #6348
Conversation
Now we can submit a function with multiple custom properties as follows:
|
After a discussion with @sijie , the way this options work is as follows now:
both |
@nlu90 Hi, thanks for the work you did here :).
|
@KannarFr Thanks for your feedback
jar: ./pulsar-functions/java-examples/target/pulsar-functions-api-examples.jar
className: org.apache.pulsar.functions.api.examples.ExclamationFunction
tenant: public
namespace: default
name: exclamation
customProperties:
- prop1=PROP1_VALUE
- prop2=PROP2_VALUE
inputs:
- persistent://public/default/my-topic
output: persistent://public/default/exclamation and the submission command is: ./bin/pulsar-admin functions create --function-config-file ~/func-conf.yaml |
@nlu90 the change looks very good. although I think it might be worth thinking of the extensibility of this approach. We might be looking into some more generic variable binding approach that allows user dynamically generating the properties or values through variable bindings. Serverless provides a good example of how to load variable bindings through different formats (e.g. environment variables, cli options, and etc). |
@sijie We can create a new issue for the yaml file variable extension feature and add it in a separate PR. |
@nlu90 sounds good. do you want to create an issue for that? |
The goal is to use system env var defined and pass them to functions via
the yaml configuration file. Like myProp: $MY_PROP.
Le mar. 18 févr. 2020 à 20:40, Sijie Guo <notifications@github.com> a
écrit :
… @nlu90 <https://github.com/nlu90> actually looked into the description of
#6170 <#6170>, I think what
@KannarFr <https://github.com/KannarFr> is looking for might be similar
to a variable binding approach. Maybe let's ask @KannarFr
<https://github.com/KannarFr> for some clarifications.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6348?email_source=notifications&email_token=ABZLQJIO756ZVJTA6SNUK6LRDQ2RBA5CNFSM4KWWN7P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMD7FCY#issuecomment-587723403>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABZLQJIFEPS37EJEDGMK6PLRDQ2RBANCNFSM4KWWN7PQ>
.
|
Hi @KannarFr, Just want to confirm if the following solution meet your needs (Notice the last line of tenant: "test"
namespace: "test-namespace"
name: "example"
className: "org.apache.pulsar.functions.api.examples.ExclamationFunction"
inputs: ["test_src"]
userConfig:
"PublishTopic": "test_result"
output: "test_result"
autoAck: true
parallelism: 1
customRuntimeOptions: "-DmyProp=${MY_PROP} -Dother_option=other_value" and when you create function with this yaml file, the variable Let me know your thoughts. |
That's it! All seems perfect then.
Le mar. 18 févr. 2020 à 23:17, Neng Lu <notifications@github.com> a écrit :
… Hi @KannarFr <https://github.com/KannarFr>, Just want to confirm if the
following solution meet your needs (Notice the last line of
customRuntimeOptions):
tenant: "test"namespace: "test-namespace"name: "example"className: "org.apache.pulsar.functions.api.examples.ExclamationFunction"inputs: ["test_src"]userConfig:
"PublishTopic": "test_result"output: "test_result"autoAck: trueparallelism: 1customRuntimeOptions: "-DmyProp=${MY_PROP}"
and when you create function with this yaml file, the variable ${MY_PROP}
will be automatically replaced with the actual system property value.
Let me know your thoughts.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6348?email_source=notifications&email_token=ABZLQJIUSGWBTOZJTEDKAXTRDRM5ZA5CNFSM4KWWN7P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMFR7PQ#issuecomment-587931582>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABZLQJLM6ZDOB4UCTQBVIH3RDRM5ZANCNFSM4KWWN7PQ>
.
|
@sijie @KannarFr Now you can submit a function with the following yaml file. And jar: ./pulsar-functions/java-examples/target/pulsar-functions-api-examples.jar
className: org.apache.pulsar.functions.api.examples.ExclamationFunction
tenant: public
namespace: default
name: exclamation
inputs:
- persistent://public/default/my-topic
output: persistent://public/default/exclamation
customRuntimeOptions: "-Dprop1=${MY_PROP1} -Dprop2=${MY_PROP2}" One more question is currently if we fetch function info with the cli, it will show the actual value of |
@nlu90 Well considering logs are often exported to external services, I think we must hide them from logs. Thats being said, we can log the env var name like: |
@KannarFr Now no actual variable value will be logged into files. |
@nlu90 Perfect! Thanks for all the work you did here :). |
@sijie can we merge this? |
@nlu90 oh, there few tests issues, can you check them? |
/pulsarbot run-failure-checks |
…perty-to-functions
What is the status of this PR? |
@KannarFr Sorry for the late reply, I was busy with some other projects. After a discussion with @sijie , now the changes enable you put the env variable in an example yaml would be: jar: ./pulsar-functions/java-examples/target/pulsar-functions-api-examples.jar
className: org.apache.pulsar.functions.api.examples.ExclamationFunction
tenant: public
namespace: default
name: exclamation
inputs:
- persistent://public/default/my-topic
output: persistent://public/default/exclamation
userConfig:
"prop1": "$MY_PROP" and you can access the actual value for |
@nlu90 Thanks for your answer. So
reads |
Yes. |
Awesome! |
Docs have been added here. |
…he#6348) Fixes apache#6170 ### Motivation Allow users set custom system properties while submitting functions. This can be used to pass credentials via system property. ### Modifications - pulsar-admin client tool to accept multiple `--custom-property` options while creating the function - function's java runtime to append these provided properties.
Fixes #6170
Motivation
Allow users set custom system properties while submitting functions. This can be used to pass credentials via system property.
Modifications
--custom-property
options while creating the functionVerifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation