Skip to content

Commit

Permalink
[KYUUBI #5987] Enhance KYUUBI_HOME detection in shell script to handl…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
Emor-nj authored and pan3793 committed Jan 17, 2024
1 parent e9e2d18 commit 7b38889
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion bin/beeline
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
## Kyuubi BeeLine Entrance
CLASS="org.apache.hive.beeline.KyuubiBeeLine"

export KYUUBI_HOME="$(cd "$(dirname "$0")"/..; pwd)"
if [ -z "${KYUUBI_HOME}" ]; then
KYUUBI_HOME="$(cd "`dirname "$0"`"/..; pwd)"
fi

. "${KYUUBI_HOME}/bin/load-kyuubi-env.sh" -s

Expand Down
4 changes: 3 additions & 1 deletion bin/kyuubi
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ function kyuubi_rotate_log() {
fi
}

export KYUUBI_HOME="$(cd "$(dirname "$0")"/..; pwd)"
if [ -z "${KYUUBI_HOME}" ]; then
KYUUBI_HOME="$(cd "`dirname "$0"`"/..; pwd)"
fi

if [[ $1 == "start" ]] || [[ $1 == "run" ]]; then
. "${KYUUBI_HOME}/bin/load-kyuubi-env.sh"
Expand Down
4 changes: 3 additions & 1 deletion bin/kyuubi-admin
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
## Kyuubi Admin Control Client Entrance
CLASS="org.apache.kyuubi.ctl.cli.AdminControlCli"

export KYUUBI_HOME="$(cd "$(dirname "$0")"/..; pwd)"
if [ -z "${KYUUBI_HOME}" ]; then
KYUUBI_HOME="$(cd "`dirname "$0"`"/..; pwd)"
fi

. "${KYUUBI_HOME}/bin/load-kyuubi-env.sh" -s

Expand Down
4 changes: 3 additions & 1 deletion bin/kyuubi-ctl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
## Kyuubi Control Client Entrance
CLASS="org.apache.kyuubi.ctl.cli.ControlCli"

export KYUUBI_HOME="$(cd "$(dirname "$0")"/..; pwd)"
if [ -z "${KYUUBI_HOME}" ]; then
KYUUBI_HOME="$(cd "`dirname "$0"`"/..; pwd)"
fi

. "${KYUUBI_HOME}/bin/load-kyuubi-env.sh" -s

Expand Down
5 changes: 3 additions & 2 deletions bin/kyuubi-zk-cli
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
## Zookeeper Shell Client Entrance
CLASS="org.apache.kyuubi.shaded.zookeeper.ZooKeeperMain"

export KYUUBI_HOME="$(cd "$(dirname "$0")"/..; pwd)"

if [ -z "${KYUUBI_HOME}" ]; then
KYUUBI_HOME="$(cd "`dirname "$0"`"/..; pwd)"
fi
. "${KYUUBI_HOME}/bin/load-kyuubi-env.sh" -s

if [[ -z ${JAVA_HOME} ]]; then
Expand Down
5 changes: 3 additions & 2 deletions bin/load-kyuubi-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
#


export KYUUBI_HOME="${KYUUBI_HOME:-"$(cd "$(dirname "$0")"/.. || exit; pwd)"}"

if [ -z "${KYUUBI_HOME}" ]; then
export KYUUBI_HOME="$(cd "$(dirname "$0")"/.. || exit; pwd)"
fi
export KYUUBI_CONF_DIR="${KYUUBI_CONF_DIR:-"${KYUUBI_HOME}"/conf}"

silent=0
Expand Down

0 comments on commit 7b38889

Please sign in to comment.