-
Notifications
You must be signed in to change notification settings - Fork 919
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
[KYUUBI #5987] Enhance KYUUBI_HOME detection in shell script to handle softlink cases #5988
Conversation
… environment variable.
cc @pan3793 |
The change makes sense to me, mind supplying poistive/negative test cases in the PR description? |
seems we have the same issue on the other scripts. actually, what we want to do here is to follow the soft link to find the real file, then locale the |
I checked Spark's scripts, let's simply use this pattern
|
Good idea! Here's the modified line: |
Is the intention to maintain consistency with Spark by prioritizing the use of environment variables rather than directly obtaining the absolute path? |
is
I haven't seen users report similar issues to Spark, thus I suppose the approach Spark used is reliable, it always is my first fallback candidate if no better options. |
Get it, let's align with Spark. I will uniformly modify all related scripts. |
bin/beeline
Outdated
@@ -19,7 +19,9 @@ | |||
## Kyuubi BeeLine Entrance | |||
CLASS="org.apache.hive.beeline.KyuubiBeeLine" | |||
|
|||
export KYUUBI_HOME="${KYUUBI_HOME:-"$(cd "$(dirname "$0")"/.. || exit; pwd)"}" | |||
if [ -z "${KYUUBI_HOME}" ]; then | |||
export KYUUBI_HOME="$(cd "`dirname "$0"`"/..; pwd)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export is not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
57504e1
to
a101428
Compare
bin/load-kyuubi-env.sh
Outdated
@@ -18,7 +18,7 @@ | |||
|
|||
|
|||
if [ -z "${KYUUBI_HOME}" ]; then | |||
export ${KYUUBI_HOME:-"$(cd "$(dirname "$0")"/.. || exit; pwd)"} | |||
export KYUUBI_HOME="${KYUUBI_HOME:-"$(cd "$(dirname "$0")"/.. || exit; pwd)"}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KYUUBI_HOME is always empty
export KYUUBI_HOME="${KYUUBI_HOME:-"$(cd "$(dirname "$0")"/.. || exit; pwd)"}" | |
export KYUUBI_HOME="$(cd "$(dirname "$0")"/.. || exit; pwd)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get it, thanks
…e softlink cases # 🔍 Description ## Issue References 🔗 This pull request fixes #5987 Modify the logic in the beeline script that specifies the KYUUBI_HOME environment variable. ## Describe Your Solution 🔧 If the environment has already declared KYUUBI_HOME, it should use the pre-declared KYUUBI_HOME instead of forcefully specifying the parent directory of the current one. ## Types of changes 🔖 - [ ] 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 ⚰️ 1. set soft link: `ln -s /opt/soft/kyuubi/kyuubi/bin/beeline /usr/bin/kyuubi-beeline` 2. set env like: `export KYUUBI_HOME=/opt/soft/kyuubi/kyuubi` 3. run kyuubi-beeline: `kyuubi-beeline -u "jdbc:hive2://xx.xx.xx.xx:2181,xx.xx.xx.xx:2181,xx.xx.xx.xx:2181/tmp;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi;principal=hive/_HOSTxxx"` 4. command will fail: `/bin/kyuubi-beeline: line 27: //bin/load-kyuubi-env.sh: No such file or directory Error: JAVA_HOME IS NOT SET! CANNOT PROCEED.` #### Behavior With This Pull Request 🎉 1. set soft link: `ln -s /opt/soft/kyuubi/kyuubi/bin/beeline /usr/bin/kyuubi-beeline` 2. set env like: `export KYUUBI_HOME=/opt/soft/kyuubi/kyuubi` 3. run kyuubi-beeline: `kyuubi-beeline -u "jdbc:hive2://xx.xx.xx.xx:2181,xx.xx.xx.xx:2181,xx.xx.xx.xx:2181/tmp;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi;principal=hive/_HOSTxxx"` 4. command will success #### Related Unit Tests --- # Checklist 📝 - [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #5988 from Emor-nj/kyuubi-beeline. Closes #5987 3a988e0 [Emor-nj] fix KYUUBI_HOME is always empty in load-kyuubi-env.sh cc70387 [Emor-nj] fix load-kyuubi-env.sh a101428 [Emor-nj] Remove unnecessary exports. f48db3f [Emor-nj] uniformly modify all related scripts. 35215b9 [Emor-nj] Modify the logic in the beeline script that specifies the KYUUBI_HOME environment variable. Authored-by: Emor-nj <[email protected]> Signed-off-by: Cheng Pan <[email protected]> (cherry picked from commit 7b38889) Signed-off-by: Cheng Pan <[email protected]>
Thanks, merged to master/1.8 |
… handle softlink cases # 🔍 Description ## Issue References 🔗 This pull request fixes apache#5987 Modify the logic in the beeline script that specifies the KYUUBI_HOME environment variable. ## Describe Your Solution 🔧 If the environment has already declared KYUUBI_HOME, it should use the pre-declared KYUUBI_HOME instead of forcefully specifying the parent directory of the current one. ## Types of changes 🔖 - [ ] 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 ⚰️ 1. set soft link: `ln -s /opt/soft/kyuubi/kyuubi/bin/beeline /usr/bin/kyuubi-beeline` 2. set env like: `export KYUUBI_HOME=/opt/soft/kyuubi/kyuubi` 3. run kyuubi-beeline: `kyuubi-beeline -u "jdbc:hive2://xx.xx.xx.xx:2181,xx.xx.xx.xx:2181,xx.xx.xx.xx:2181/tmp;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi;principal=hive/_HOSTxxx"` 4. command will fail: `/bin/kyuubi-beeline: line 27: //bin/load-kyuubi-env.sh: No such file or directory Error: JAVA_HOME IS NOT SET! CANNOT PROCEED.` #### Behavior With This Pull Request 🎉 1. set soft link: `ln -s /opt/soft/kyuubi/kyuubi/bin/beeline /usr/bin/kyuubi-beeline` 2. set env like: `export KYUUBI_HOME=/opt/soft/kyuubi/kyuubi` 3. run kyuubi-beeline: `kyuubi-beeline -u "jdbc:hive2://xx.xx.xx.xx:2181,xx.xx.xx.xx:2181,xx.xx.xx.xx:2181/tmp;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi;principal=hive/_HOSTxxx"` 4. command will success #### Related Unit Tests --- # Checklist 📝 - [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes apache#5988 from Emor-nj/kyuubi-beeline. Closes apache#5987 3a988e0 [Emor-nj] fix KYUUBI_HOME is always empty in load-kyuubi-env.sh cc70387 [Emor-nj] fix load-kyuubi-env.sh a101428 [Emor-nj] Remove unnecessary exports. f48db3f [Emor-nj] uniformly modify all related scripts. 35215b9 [Emor-nj] Modify the logic in the beeline script that specifies the KYUUBI_HOME environment variable. Authored-by: Emor-nj <[email protected]> Signed-off-by: Cheng Pan <[email protected]>
… handle softlink cases # 🔍 Description ## Issue References 🔗 This pull request fixes apache#5987 Modify the logic in the beeline script that specifies the KYUUBI_HOME environment variable. ## Describe Your Solution 🔧 If the environment has already declared KYUUBI_HOME, it should use the pre-declared KYUUBI_HOME instead of forcefully specifying the parent directory of the current one. ## Types of changes 🔖 - [ ] 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 ⚰️ 1. set soft link: `ln -s /opt/soft/kyuubi/kyuubi/bin/beeline /usr/bin/kyuubi-beeline` 2. set env like: `export KYUUBI_HOME=/opt/soft/kyuubi/kyuubi` 3. run kyuubi-beeline: `kyuubi-beeline -u "jdbc:hive2://xx.xx.xx.xx:2181,xx.xx.xx.xx:2181,xx.xx.xx.xx:2181/tmp;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi;principal=hive/_HOSTxxx"` 4. command will fail: `/bin/kyuubi-beeline: line 27: //bin/load-kyuubi-env.sh: No such file or directory Error: JAVA_HOME IS NOT SET! CANNOT PROCEED.` #### Behavior With This Pull Request 🎉 1. set soft link: `ln -s /opt/soft/kyuubi/kyuubi/bin/beeline /usr/bin/kyuubi-beeline` 2. set env like: `export KYUUBI_HOME=/opt/soft/kyuubi/kyuubi` 3. run kyuubi-beeline: `kyuubi-beeline -u "jdbc:hive2://xx.xx.xx.xx:2181,xx.xx.xx.xx:2181,xx.xx.xx.xx:2181/tmp;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi;principal=hive/_HOSTxxx"` 4. command will success #### Related Unit Tests --- # Checklist 📝 - [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes apache#5988 from Emor-nj/kyuubi-beeline. Closes apache#5987 3a988e0 [Emor-nj] fix KYUUBI_HOME is always empty in load-kyuubi-env.sh cc70387 [Emor-nj] fix load-kyuubi-env.sh a101428 [Emor-nj] Remove unnecessary exports. f48db3f [Emor-nj] uniformly modify all related scripts. 35215b9 [Emor-nj] Modify the logic in the beeline script that specifies the KYUUBI_HOME environment variable. Authored-by: Emor-nj <[email protected]> Signed-off-by: Cheng Pan <[email protected]>
🔍 Description
Issue References 🔗
This pull request fixes #5987
Modify the logic in the beeline script that specifies the KYUUBI_HOME environment variable.
Describe Your Solution 🔧
If the environment has already declared KYUUBI_HOME, it should use the pre-declared KYUUBI_HOME instead of forcefully specifying the parent directory of the current one.
Types of changes 🔖
Test Plan 🧪
Behavior Without This Pull Request ⚰️
ln -s /opt/soft/kyuubi/kyuubi/bin/beeline /usr/bin/kyuubi-beeline
export KYUUBI_HOME=/opt/soft/kyuubi/kyuubi
kyuubi-beeline -u "jdbc:hive2://xx.xx.xx.xx:2181,xx.xx.xx.xx:2181,xx.xx.xx.xx:2181/tmp;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi;principal=hive/_HOST@xxx"
/bin/kyuubi-beeline: line 27: //bin/load-kyuubi-env.sh: No such file or directory Error: JAVA_HOME IS NOT SET! CANNOT PROCEED.
Behavior With This Pull Request 🎉
ln -s /opt/soft/kyuubi/kyuubi/bin/beeline /usr/bin/kyuubi-beeline
export KYUUBI_HOME=/opt/soft/kyuubi/kyuubi
kyuubi-beeline -u "jdbc:hive2://xx.xx.xx.xx:2181,xx.xx.xx.xx:2181,xx.xx.xx.xx:2181/tmp;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi;principal=hive/_HOST@xxx"
Related Unit Tests
Checklist 📝
Be nice. Be informative.