Skip to content

Commit 50b9a93

Browse files
[fix][fn] TLS args admin download command use zero arity (#20513)
### Motivation #20482 broke the function download command with this error: ``` Expected a command, got false Usage: pulsar-admin [options] [command] [command options] Options: --admin-url Admin Service URL to which to connect. Default: http://localhost:8080/ ``` The problem is that the TLS args for hostname verification and for insecure TLS are zero arity, and therefore, we should not add the `false` or the `true` arguments. ### Modifications * Correct the changes made to the TLS args passed to the `pulsar-admin` CLI tool ### Documentation - [x] `doc-not-needed`
1 parent 0a39b81 commit 50b9a93

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,12 @@ && isNotBlank(authConfig.getClientAuthenticationParameters())) {
885885
"--auth-params",
886886
authConfig.getClientAuthenticationParameters()));
887887
}
888-
cmd.addAll(Arrays.asList(
889-
"--tls-allow-insecure",
890-
Boolean.toString(authConfig.isTlsAllowInsecureConnection()),
891-
"--tls-enable-hostname-verification",
892-
Boolean.toString(authConfig.isTlsHostnameVerificationEnable())));
888+
if (authConfig.isTlsAllowInsecureConnection()) {
889+
cmd.add("--tls-allow-insecure");
890+
}
891+
if (authConfig.isTlsHostnameVerificationEnable()) {
892+
cmd.add("--tls-enable-hostname-verification");
893+
}
893894
if (isNotBlank(authConfig.getTlsTrustCertsFilePath())) {
894895
cmd.addAll(Arrays.asList(
895896
"--tls-trust-cert-path",

pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,6 @@ public void testCustomKubernetesDownloadCommandsWithAuth() throws Exception {
852852
V1StatefulSet spec = container.createStatefulSet();
853853
String expectedDownloadCommand = "pulsar-admin --admin-url " + pulsarAdminUrl
854854
+ " --auth-plugin com.MyAuth --auth-params {\"authParam1\": \"authParamValue1\"}"
855-
+ " --tls-allow-insecure false --tls-enable-hostname-verification false"
856855
+ " functions download "
857856
+ "--tenant " + TEST_TENANT
858857
+ " --namespace " + TEST_NAMESPACE
@@ -879,7 +878,6 @@ public void testCustomKubernetesDownloadCommandsWithAuthWithoutAuthSpec() throws
879878
V1StatefulSet spec = container.createStatefulSet();
880879
String expectedDownloadCommand = "pulsar-admin --admin-url " + pulsarAdminUrl
881880
+ " --auth-plugin com.MyAuth --auth-params {\"authParam1\": \"authParamValue1\"}"
882-
+ " --tls-allow-insecure false --tls-enable-hostname-verification false"
883881
+ " functions download "
884882
+ "--tenant " + TEST_TENANT
885883
+ " --namespace " + TEST_NAMESPACE
@@ -909,7 +907,7 @@ public void testCustomKubernetesDownloadCommandsWithAuthAndCustomTLSWithoutAuthS
909907
V1StatefulSet spec = container.createStatefulSet();
910908
String expectedDownloadCommand = "pulsar-admin --admin-url " + pulsarAdminUrl
911909
+ " --auth-plugin com.MyAuth --auth-params {\"authParam1\": \"authParamValue1\"}"
912-
+ " --tls-allow-insecure false --tls-enable-hostname-verification true"
910+
+ " --tls-enable-hostname-verification"
913911
+ " --tls-trust-cert-path /my/ca.pem"
914912
+ " functions download "
915913
+ "--tenant " + TEST_TENANT

0 commit comments

Comments
 (0)