You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "bowenliang123 (via GitHub)" <gi...@apache.org> on 2023/11/24 05:52:15 UTC

[PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

bowenliang123 opened a new pull request, #5767:
URL: https://github.com/apache/kyuubi/pull/5767

   
   # :mag: Description
   ## Issue References ๐Ÿ”—
   <!-- Append the issue number after #. If there is no issue for you to link create one or -->
   <!-- If there are no issues to link, please provide details here. -->
   
   As described.
   
   ## Describe Your Solution ๐Ÿ”ง
   
   - Avoid using magic string value "--conf" in each processbuilder
   - Extract common utils for assembling key value pairs with config option prefix in processbuilder
   - NO changes in expected string value for processbuilder command assertions in test suites
   
   ## Types of changes :bookmark:
   <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
   - [ ] Bugfix (non-breaking change which fixes an issue)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   
   ## Test Plan ๐Ÿงช
   
   #### Behavior Without This Pull Request :coffin:
   No behavior changes.
   
   #### Behavior With This Pull Request :tada:
   No behavior changes.
   
   #### Related Unit Tests
   Added `CommandUtilsSuite`.
   
   ---
   
   # Checklists
   ## ๐Ÿ“ Author Self Checklist
   <!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
   <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
   - [x] My code follows the [style guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html) of this project
   - [x] I have performed a self-review
   - [x] I have commented my code, particularly in hard-to-understand areas
   - [ ] I have made corresponding changes to the documentation
   - [ ] My changes generate no new warnings
   - [x] I have added tests that prove my fix is effective or that my feature works
   - [ ] New and existing unit tests pass locally with my changes
   - [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)
   
   ## ๐Ÿ“ Committer Pre-Merge Checklist
   
   - [ ] Pull request title is okay.
   - [ ] No license issues.
   - [ ] Milestone correctly set?
   - [ ] Test coverage is ok
   - [ ] Assignees are selected.
   - [ ] Minimum number of approvals
   - [ ] No changes are requested
   
   
   **Be nice. Be informative.**
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#issuecomment-1836274902

   overall LGTM, feel free to merge after addressing minor comments and passing CI.
   Have good weekend~


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412224843


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala:
##########
@@ -51,13 +52,12 @@ class SparkBatchProcessBuilder(
     // tag batch application
     KyuubiApplicationManager.tagApplication(batchId, "spark", clusterManager(), batchKyuubiConf)
 
-    (batchKyuubiConf.getAll ++
-      sparkAppNameConf() ++
-      engineLogPathConf() ++
-      appendPodNameConf(batchConf)).foreach { case (k, v) =>
-      buffer += CONF
-      buffer += s"${convertConfigKey(k)}=$v"
-    }
+    val allConfigs = Seq(
+      batchKyuubiConf.getAll,
+      sparkAppNameConf(),
+      engineLogPathConf(),
+      appendPodNameConf(batchConf)).flatten
+    buffer ++= confKeyValues(allConfigs)

Review Comment:
   Sure. Avoided using `Seq.flatten`.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412218818


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala:
##########
@@ -51,13 +52,12 @@ class SparkBatchProcessBuilder(
     // tag batch application
     KyuubiApplicationManager.tagApplication(batchId, "spark", clusterManager(), batchKyuubiConf)
 
-    (batchKyuubiConf.getAll ++
-      sparkAppNameConf() ++
-      engineLogPathConf() ++
-      appendPodNameConf(batchConf)).foreach { case (k, v) =>
-      buffer += CONF
-      buffer += s"${convertConfigKey(k)}=$v"
-    }
+    val allConfigs = Seq(
+      batchKyuubiConf.getAll,
+      sparkAppNameConf(),
+      engineLogPathConf(),
+      appendPodNameConf(batchConf)).flatten
+    buffer ++= confKeyValues(allConfigs)

Review Comment:
   Have consider the style you suggest. Maybe I would prefer separating the configs assembling and the command buffer assembling, easier for readability and  further modification in configs assembling.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#issuecomment-1831496862

   Would you like to double-check this PR? Some changes after your last review. @pan3793 


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412202913


##########
kyuubi-server/src/test/scala/org/apache/kyuubi/engine/flink/FlinkProcessBuilderSuite.scala:
##########
@@ -73,7 +74,7 @@ class FlinkProcessBuilderSuite extends KyuubiFunSuite {
   private def confStr: String = {
     sessionModeConf.clone.getAll
       .filter(!_._1.equals(KYUUBI_ENGINE_CREDENTIALS_KEY))
-      .map { case (k, v) => s"\\\\\\n\\t--conf $k=$v" }
+      .map { case (k, v) => s"\\\\\\n\\t${confKeyValueStr(k, v)}" }

Review Comment:
   use raw string literal in suite



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#issuecomment-1836567480

   Thanks, merged to master and branch-1.8 (1.8.1)


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412211865


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/trino/TrinoProcessBuilder.scala:
##########
@@ -113,18 +108,16 @@ class TrinoProcessBuilder(
     if (commands == null) {
       super.toString
     } else {
-      Utils.redactCommandLineArgs(conf, commands).map {
-        case arg if arg.contains(ENGINE_TRINO_CONNECTION_PASSWORD.key) =>
-          s"${ENGINE_TRINO_CONNECTION_PASSWORD.key}=$REDACTION_REPLACEMENT_TEXT"
-        case arg if arg.contains(ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD.key) =>
-          s"${ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD.key}=$REDACTION_REPLACEMENT_TEXT"
-        case arg if arg.contains(ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD.key) =>
-          s"${ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD.key}=$REDACTION_REPLACEMENT_TEXT"
-        case arg => arg
-      }.map {
-        case arg if arg.startsWith("-") => s"\\\n\t$arg"
-        case arg => arg
-      }.mkString(" ")
+      redactConfValues(
+        Utils.redactCommandLineArgs(conf, commands),
+        Set(
+          ENGINE_TRINO_CONNECTION_PASSWORD,
+          ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD,
+          ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD).map(_.key))

Review Comment:
   simply use 
   ```suggestion
           Set(
             ENGINE_TRINO_CONNECTION_PASSWORD.key,
             ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD.key,
             ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD.key))
   ```
   otherwise would broken if we want to add a string literal later



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412214179


##########
kyuubi-server/src/test/scala/org/apache/kyuubi/engine/flink/FlinkProcessBuilderSuite.scala:
##########
@@ -73,7 +74,7 @@ class FlinkProcessBuilderSuite extends KyuubiFunSuite {
   private def confStr: String = {
     sessionModeConf.clone.getAll
       .filter(!_._1.equals(KYUUBI_ENGINE_CREDENTIALS_KEY))
-      .map { case (k, v) => s"\\\\\\n\\t--conf $k=$v" }
+      .map { case (k, v) => s"\\\\\\n\\t${confKeyValueStr(k, v)}" }

Review Comment:
   Nice catch, resolved.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1406556565


##########
kyuubi-util-scala/src/main/scala/org/apache/kyuubi/util/command/CommandLineUtils.scala:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.util.command
+
+import java.io.File
+
+object CommandLineUtils {
+  val CONF = "--conf"
+  val JAVA_CLASSPATH = "-cp"
+
+  /**
+   * Assemble key value pair with "=" seperator
+   *
+   * @param key
+   * @param value
+   * @return
+   */

Review Comment:
   Remove unused Javadocs
   
   ```suggestion
     /**
      * Assemble key value pair with "=" seperator
      */
   ```



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412215991


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala:
##########
@@ -51,13 +52,12 @@ class SparkBatchProcessBuilder(
     // tag batch application
     KyuubiApplicationManager.tagApplication(batchId, "spark", clusterManager(), batchKyuubiConf)
 
-    (batchKyuubiConf.getAll ++
-      sparkAppNameConf() ++
-      engineLogPathConf() ++
-      appendPodNameConf(batchConf)).foreach { case (k, v) =>
-      buffer += CONF
-      buffer += s"${convertConfigKey(k)}=$v"
-    }
+    val allConfigs = Seq(
+      batchKyuubiConf.getAll,
+      sparkAppNameConf(),
+      engineLogPathConf(),
+      appendPodNameConf(batchConf)).flatten
+    buffer ++= confKeyValues(allConfigs)

Review Comment:
   how about?
   ```suggestion
       buffer ++= confKeyValues(
         batchKyuubiConf.getAll ++
         sparkAppNameConf() ++
         engineLogPathConf() ++
         appendPodNameConf(batchConf))
   ```



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#issuecomment-1825941907

   ## [Codecov](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: `5 lines` in your changes are missing coverage. Please review.
   > Comparison is base [(`ba5cb24`)](https://app.codecov.io/gh/apache/kyuubi/commit/ba5cb249e2faafe9c124ef5687b38eeaf03c2853?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 61.35% compared to head [(`299baa7`)](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 61.33%.
   > Report is 4 commits behind head on master.
   
   | [Files](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...ommon/src/main/scala/org/apache/kyuubi/Utils.scala](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9VdGlscy5zY2FsYQ==) | 33.33% | [0 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...apache/kyuubi/engine/chat/ChatProcessBuilder.scala](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvY2hhdC9DaGF0UHJvY2Vzc0J1aWxkZXIuc2NhbGE=) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [.../org/apache/kyuubi/util/command/CommandUtils.scala](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-a3l1dWJpLXV0aWwtc2NhbGEvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvdXRpbC9jb21tYW5kL0NvbW1hbmRVdGlscy5zY2FsYQ==) | 85.71% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #5767      +/-   ##
   ============================================
   - Coverage     61.35%   61.33%   -0.03%     
     Complexity       23       23              
   ============================================
     Files           607      608       +1     
     Lines         35914    35912       -2     
     Branches       4926     4931       +5     
   ============================================
   - Hits          22036    22026      -10     
   - Misses        11490    11497       +7     
   - Partials       2388     2389       +1     
   ```
   
   
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/kyuubi/pull/5767?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1407406801


##########
kyuubi-util-scala/src/main/scala/org/apache/kyuubi/util/command/CommandLineUtils.scala:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.util.command
+
+import java.io.File
+
+object CommandLineUtils {
+  val CONF = "--conf"
+  val JAVA_OPTION_CLASSPATH = "-cp"

Review Comment:
   ```suggestion
     val CP = "-cp"
   ```



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#issuecomment-1836276520

   > overall LGTM, feel free to merge after addressing minor comments and passing CI. Have good weekend~
   
   Thanks for the review on weekend nights.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "turboFei (via GitHub)" <gi...@apache.org>.
turboFei commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1550056463


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala:
##########
@@ -51,13 +52,11 @@ class SparkBatchProcessBuilder(
     // tag batch application
     KyuubiApplicationManager.tagApplication(batchId, "spark", clusterManager(), batchKyuubiConf)
 
-    (batchKyuubiConf.getAll ++
+    val allConfigs = batchKyuubiConf.getAll ++
       sparkAppNameConf() ++
       engineLogPathConf() ++
-      appendPodNameConf(batchConf)).foreach { case (k, v) =>
-      buffer += CONF
-      buffer += s"${convertConfigKey(k)}=$v"

Review Comment:
   broken issue, the key is not converted with `convertConfigKey`, fix it in https://github.com/apache/kyuubi/pull/6256



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1406555918


##########
kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/command/CommandUtilsSuite.scala:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kyuubi.util.command
+
+// scalastyle:off
+import org.scalatest.funsuite.AnyFunSuite
+
+import org.apache.kyuubi.util.command.CommandLineUtils._
+class CommandUtilsSuite extends AnyFunSuite {
+  // scalastyle:on

Review Comment:
   minimize to scope
   
   ```suggestion
   // scalastyle:off
   import org.scalatest.funsuite.AnyFunSuite
   // scalastyle:on
   import org.apache.kyuubi.util.command.CommandLineUtils._
   
   // scalastyle:off
   class CommandUtilsSuite extends AnyFunSuite {
   // scalastyle:on
   ```



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412222805


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/trino/TrinoProcessBuilder.scala:
##########
@@ -113,18 +108,16 @@ class TrinoProcessBuilder(
     if (commands == null) {
       super.toString
     } else {
-      Utils.redactCommandLineArgs(conf, commands).map {
-        case arg if arg.contains(ENGINE_TRINO_CONNECTION_PASSWORD.key) =>
-          s"${ENGINE_TRINO_CONNECTION_PASSWORD.key}=$REDACTION_REPLACEMENT_TEXT"
-        case arg if arg.contains(ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD.key) =>
-          s"${ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD.key}=$REDACTION_REPLACEMENT_TEXT"
-        case arg if arg.contains(ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD.key) =>
-          s"${ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD.key}=$REDACTION_REPLACEMENT_TEXT"
-        case arg => arg
-      }.map {
-        case arg if arg.startsWith("-") => s"\\\n\t$arg"
-        case arg => arg
-      }.mkString(" ")
+      redactConfValues(
+        Utils.redactCommandLineArgs(conf, commands),
+        Set(
+          ENGINE_TRINO_CONNECTION_PASSWORD,
+          ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD,
+          ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD).map(_.key))

Review Comment:
   Fixed.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1407407061


##########
kyuubi-util-scala/src/main/scala/org/apache/kyuubi/util/command/CommandLineUtils.scala:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.util.command
+
+import java.io.File
+
+object CommandLineUtils {
+  val CONF = "--conf"
+  val JAVA_OPTION_CLASSPATH = "-cp"
+
+  /**
+   * Assemble key value pair with "=" seperator
+   */
+  def genKeyValuePair(key: String, value: String): String = s"$key=$value".trim
+
+  /**
+   * Assemble key value pair with config option prefix
+   *
+   * @param key
+   * @param value
+   * @return

Review Comment:
   ```suggestion
      * Assemble key value pair with config option prefix
   ```



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412222054


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala:
##########
@@ -51,13 +52,12 @@ class SparkBatchProcessBuilder(
     // tag batch application
     KyuubiApplicationManager.tagApplication(batchId, "spark", clusterManager(), batchKyuubiConf)
 
-    (batchKyuubiConf.getAll ++
-      sparkAppNameConf() ++
-      engineLogPathConf() ++
-      appendPodNameConf(batchConf)).foreach { case (k, v) =>
-      buffer += CONF
-      buffer += s"${convertConfigKey(k)}=$v"
-    }
+    val allConfigs = Seq(
+      batchKyuubiConf.getAll,
+      sparkAppNameConf(),
+      engineLogPathConf(),
+      appendPodNameConf(batchConf)).flatten
+    buffer ++= confKeyValues(allConfigs)

Review Comment:
   that's fine, but prefer to keep `++` instead of `Seq.flatten`



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 closed pull request #5767: Extract common utils for assembling key value pairs with config option prefix in processbuilder
URL: https://github.com/apache/kyuubi/pull/5767


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412218818


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala:
##########
@@ -51,13 +52,12 @@ class SparkBatchProcessBuilder(
     // tag batch application
     KyuubiApplicationManager.tagApplication(batchId, "spark", clusterManager(), batchKyuubiConf)
 
-    (batchKyuubiConf.getAll ++
-      sparkAppNameConf() ++
-      engineLogPathConf() ++
-      appendPodNameConf(batchConf)).foreach { case (k, v) =>
-      buffer += CONF
-      buffer += s"${convertConfigKey(k)}=$v"
-    }
+    val allConfigs = Seq(
+      batchKyuubiConf.getAll,
+      sparkAppNameConf(),
+      engineLogPathConf(),
+      appendPodNameConf(batchConf)).flatten
+    buffer ++= confKeyValues(allConfigs)

Review Comment:
   Have considered the style that you suggest. Maybe I would prefer separating the configs assembling and the command buffer assembling, easier for readability and the further modifications in configs assembling.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Extract common utils for assembling key value pairs with config option prefix in processbuilder [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #5767:
URL: https://github.com/apache/kyuubi/pull/5767#discussion_r1412215213


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/trino/TrinoProcessBuilder.scala:
##########
@@ -113,18 +108,16 @@ class TrinoProcessBuilder(
     if (commands == null) {
       super.toString
     } else {
-      Utils.redactCommandLineArgs(conf, commands).map {
-        case arg if arg.contains(ENGINE_TRINO_CONNECTION_PASSWORD.key) =>
-          s"${ENGINE_TRINO_CONNECTION_PASSWORD.key}=$REDACTION_REPLACEMENT_TEXT"
-        case arg if arg.contains(ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD.key) =>
-          s"${ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD.key}=$REDACTION_REPLACEMENT_TEXT"
-        case arg if arg.contains(ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD.key) =>
-          s"${ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD.key}=$REDACTION_REPLACEMENT_TEXT"
-        case arg => arg
-      }.map {
-        case arg if arg.startsWith("-") => s"\\\n\t$arg"
-        case arg => arg
-      }.mkString(" ")
+      redactConfValues(
+        Utils.redactCommandLineArgs(conf, commands),
+        Set(
+          ENGINE_TRINO_CONNECTION_PASSWORD,
+          ENGINE_TRINO_CONNECTION_KEYSTORE_PASSWORD,
+          ENGINE_TRINO_CONNECTION_TRUSTSTORE_PASSWORD).map(_.key))

Review Comment:
   No problem. Let me change the style here and for other process builders.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org