Skip to content
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

[#102] improvement: improve startup script #103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

orenccl
Copy link
Contributor

@orenccl orenccl commented Nov 7, 2024

What changes were proposed in this pull request?

  1. Removed the debug option set -x.
  2. Fixed warnings identified by IntelliJ, such as changing cd "${playground_dir}" >/dev/null to cd "${playground_dir}" >/dev/null || exit 1 to prevent failures when cd fails.
  3. Updated docker run --pull always hello-world >/dev/null 2>&1 to docker run --rm --pull always hello-world:latest >/dev/null 2>&1 to avoid pulling multiple images and ensure the container is removed after it finishes.
  4. Changed naming conventions and log formats for consistency.
  5. Added disk, RAM, and CPU checks.
  6. Added the --skip-checks option for a quicker startup.
  7. Corrected the log suffix format from %Y%m%d%H%m%s to %Y%m%d%H%M%s.
  8. Removed the unnecessary Confirm the requirement is available in your OS [Y/n]:.
  9. Combined port check status into one line instead of multiple lines.

Why are the changes needed?

To improve the user experience.
fix #102
fix #113

Does this PR introduce any user-facing change?

Added a new option --skip-checks|-s for a quicker startup.

How was this patch tested?

Tested with the following commands:

  • ./playground start
  • ./playground status
  • ./playground stop
  • ./playground start --skip-checks
  • ./playground start -s

These tests were run to ensure the script works as intended.

image

@orenccl orenccl marked this pull request as draft November 8, 2024 02:56
@orenccl orenccl force-pushed the improvement/startupScriptOptimize branch 2 times, most recently from f13393f to 68d5c63 Compare November 8, 2024 03:00
@orenccl orenccl marked this pull request as ready for review November 8, 2024 04:26
@orenccl
Copy link
Contributor Author

orenccl commented Nov 8, 2024

Hi @unknowntpo,

I've resolved the conflicts based on your recently merged PR #56.

Would you please review this? If possible, I would appreciate if you could also test it in your environment.

Thanks!

image

@unknowntpo
Copy link
Contributor

unknowntpo commented Nov 8, 2024

@orenccl
Okay, I'll take a look :)

playground.sh Outdated
docker run --pull always hello-world >/dev/null 2>&1
echo "[INFO] Testing Docker environment by running hello-world..."
# Use always to test network connection
docker run --rm --pull always hello-world:latest >/dev/null 2>&1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify hello-world fixed tag, do not use latest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.

playground.sh Outdated
checkDockerDisk
checkDockerRam
checkDockerCpu

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this blank line.

playground.sh Outdated

case "$runtime" in
k8s)
helm uninstall --namespace gravitino-playground gravitino-playground
helm uninstall --namespace gravitino-playground gravitino-playground
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think need to add spaces in the line head, keep code sytle.

playground.sh Outdated
Comment on lines 264 to 272
skipChecks=false

case "$3" in
--skip-checks)
skipChecks=true;
;;
-s)
skipChecks=true;
;;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need skipChecks startup param? It feels too complicated.
I think we must check docker or k8s envorinments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback. I'll remove the skipChecks parameter as suggested. The test didn't take much time, so this change should be straightforward.

@xunliu
Copy link
Member

xunliu commented Nov 8, 2024

hi @orenccl Thank you for your improve playground
I think we didn't neet specify docker|k8s param, we can check use environment,

  1. if user only have docker, then launch playground on Docker
  2. if use only have k8s, then launch playground on Docker
  3. if use both have docker and k8s, then output a menu, let use select one to launch.

@orenccl orenccl marked this pull request as draft November 8, 2024 09:57
@orenccl orenccl force-pushed the improvement/startupScriptOptimize branch from 44ee83f to 852bd35 Compare November 9, 2024 06:47
@orenccl
Copy link
Contributor Author

orenccl commented Nov 9, 2024

image

image

image

@orenccl orenccl marked this pull request as ready for review November 9, 2024 08:53
@unknowntpo
Copy link
Contributor

  • if user only have docker, then launch playground on Docker

  • if use only have k8s, then launch playground on Docker

  • if use both have docker and k8s, then output a menu, let use select one to launch.

@xunliu I think letting user to run both k8s and docker is more handy.

playground.sh Outdated

testK8s() {
echo "[INFO] Testing K8s environment..."
kubectl cluster-info
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to check if there exists kubectl first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the start, status, or stop commands are run, the checkCurrentRuntime function will be executed.

The checkCurrentRuntime function checks whether kubectl is present.

image

image

playground.sh Outdated
@@ -64,140 +127,277 @@ checkHelm() {
if [ $isExist ]; then
true # Placeholder, do nothing
else
echo "ERROR: Helm command not found, Please install helm v3."
echo "[ERROR] Helm check failed: Helm command not found, Please install helm v3."
exit
fi
# check version
# version will be like:
# Version:"v3.15.2"
regex="Version:\"(v[0-9]\.[0-9]+\.[0-9])\""
version=$(helm version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we needs check if exist helm first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section checks if Helm exists:

isExist=$(command -v helm)
if [ "$isExist" ]; then

I've unified the usage of which and command -v to use command -v for consistent style.

if command -v helm >/dev/null 2>&1; then

--set projectRoot=$(pwd)
;;
docker)
logSuffix=$(date +%Y%m%d%H%m%s)
docker-compose up --detach
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker-compose or docker compose
My macOS only have docker-compose.
docker compose is Linux OS?
Please check it.

Maybe you needs to check operation OS, and add different process.

Copy link
Contributor Author

@orenccl orenccl Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not about the OS; it's about the Docker version. Newer versions of Docker have a built-in docker compose command, whereas older versions do not. For older versions, you need to use docker-compose, which is no longer being actively updated.

I added a function to automatically detect the appropriate Docker Compose command.

Reference:
Docker Compose Migration Guide

@orenccl orenccl marked this pull request as draft November 11, 2024 09:02
@orenccl orenccl marked this pull request as ready for review November 11, 2024 10:01
@orenccl
Copy link
Contributor Author

orenccl commented Nov 11, 2024

Update this PR:

  1. Unified port number for Docker and Kubernetes.
  2. update readme

Please let me know if there are any problems.

@jerryshao
Copy link
Contributor

Hi @orenccl would you please rebase this PR to fix the conflicts?

@danhuawang
Copy link
Contributor

danhuawang commented Nov 18, 2024

Update this PR:

  1. Unified port number for Docker and Kubernetes.
  2. update readme

Please let me know if there are any problems.

@orenccl Can you help check this issue when I ran the fileset example in jupyter? By the way ,we have 4 examples in jupyter, can you help verify them by access http://localhost:18888 ,especially k8s runtime.

image

@orenccl orenccl marked this pull request as draft November 18, 2024 07:33
@orenccl orenccl force-pushed the improvement/startupScriptOptimize branch from 025cd68 to 9c324df Compare November 18, 2024 07:34
@orenccl
Copy link
Contributor Author

orenccl commented Nov 18, 2024

Hi @danhuawang,

Sorry about this. I found that the commit Unified port number for Docker and Kubernetes actually caused some issues with internal communication within the Kubernetes cluster.

This should be addressed in a separate issue, so I have reverted it and focused on the original problem. I've also updated the README to clarify the container and host port mapping, so users won't be confused about which port to forward.

Could you review this when you have free time?

image

@orenccl orenccl marked this pull request as ready for review November 18, 2024 13:55
playground.sh Outdated
else
echo "ERROR: There was an issue running kubectl cluster-info, please check you K8s cluster."
# Check available space in the root partition if the directory doesn't exist (special case for WSL)
availableSpaceKB=$(df --output=avail / | awk 'NR==2 {print $1}')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I encounter this issue when I launch with docker runtime. (MacOS)

df: unrecognized option `--output=avail'
usage: df [--libxo] [-b | -g | -H | -h | -k | -m | -P] [-acIilnY] [-,] [-T type] [-t type]
          [file | filesystem ...]
./playground.sh: line 90: / 1024 / 1024: syntax error: operand expected (error token is "/ 1024 / 1024")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that macOS does not support --output=avail. Refer to https://ss64.com/mac/df.html.

Instead of using --output=avail, change it to -k so that it works on both macOS and Linux. Refer to https://linuxcommand.org/lc3_man_pages/df1.html.

However, I don't have a macOS environment. Could you check this for me?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked macOS ,it's ok now.

playground.sh Outdated
exit 1
fi

case "${runtime}" in
k8s)
kubectl -n gravitino-playground get pods -o wide
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to replace hard code namespace with ${playgroundRuntimeName} like the helm install command in start method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@danhuawang
Copy link
Contributor

@orenccl conflicts need to be resolved.

@orenccl orenccl marked this pull request as draft November 20, 2024 12:45
@orenccl orenccl force-pushed the improvement/startupScriptOptimize branch 3 times, most recently from bcb81b6 to 6dd049a Compare November 20, 2024 14:00
@orenccl orenccl marked this pull request as ready for review November 20, 2024 14:01
@danhuawang
Copy link
Contributor

@qqqttt123 Any comments?

@xunliu
Copy link
Member

xunliu commented Nov 26, 2024

hi @orenccl
We plan to remove helm support, #110
So, maybe this PR needs to wait for review.

@orenccl orenccl marked this pull request as draft November 26, 2024 01:13
@orenccl
Copy link
Contributor Author

orenccl commented Nov 26, 2024

@xunliu
Sure, no problem.

@orenccl
Copy link
Contributor Author

orenccl commented Dec 17, 2024

I will update this PR soon since #110 has already been merged.

@orenccl orenccl force-pushed the improvement/startupScriptOptimize branch from 6dd049a to 122639c Compare December 18, 2024 13:57
@orenccl orenccl marked this pull request as ready for review December 18, 2024 13:58
@orenccl
Copy link
Contributor Author

orenccl commented Dec 18, 2024

@xunliu @danhuawang
Ready for review now! Please take a look when you have time

@orenccl orenccl marked this pull request as draft December 23, 2024 14:12
@orenccl orenccl force-pushed the improvement/startupScriptOptimize branch from 122639c to 5b762bc Compare December 23, 2024 14:12
@orenccl orenccl marked this pull request as ready for review December 23, 2024 14:19
@orenccl orenccl requested a review from danhuawang December 23, 2024 14:19
@orenccl orenccl force-pushed the improvement/startupScriptOptimize branch from 5b762bc to 201e3a0 Compare December 25, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants