-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Update telemetry entry sh to support k8s start and keep compatible with systemd start flow #24061
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
Changes from 1 commit
2709f1e
8aa0b04
79c31ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,8 +1,44 @@ | ||||
| #!/usr/bin/env bash | ||||
|
|
||||
| # Control with env var launch_by, only used if container is launched via k8s | ||||
| if [[ "${launch_by:-}" == "k8s" ]]; then | ||||
| echo "Running Part 1 because launch_by=k8s" | ||||
|
|
||||
| set -euo pipefail | ||||
|
|
||||
| # --- Create /usr/share/sonic/hwsku symlink (single-ASIC) --- | ||||
| ENV_FILE="/etc/sonic/sonic-environment" | ||||
| [[ -r "$ENV_FILE" ]] || { echo "ERROR: $ENV_FILE missing or unreadable."; exit 1; } | ||||
| # shellcheck source=/dev/null | ||||
| . "$ENV_FILE" | ||||
| [[ -n "${PLATFORM:-}" && -n "${HWSKU:-}" ]] || { echo "ERROR: PLATFORM/HWSKU not set in $ENV_FILE."; exit 1; } | ||||
|
|
||||
| resolve() { for p in "$@"; do [[ -e "$p" ]] && { printf '%s\n' "$p"; return 0; }; done; return 1; } | ||||
| SRC_PLATFORM="$(resolve "/usr/share/sonic/device/${PLATFORM}" "/usr/share/sonic/device/device/${PLATFORM}")" \ | ||||
|
||||
| || { echo "ERROR: platform dir not found for PLATFORM=$PLATFORM."; exit 1; } | ||||
| SRC_HWSKU="$(resolve "/usr/share/sonic/device/${PLATFORM}/${HWSKU}" "/usr/share/sonic/device/device/${PLATFORM}/${HWSKU}")" \ | ||||
| || { echo "ERROR: hwsku dir not found for HWSKU=$HWSKU."; exit 1; } | ||||
|
|
||||
| mkdir -p /usr/share/sonic | ||||
|
|
||||
| DST="/usr/share/sonic/platform" | ||||
| rm -rf -- "$DST" | ||||
| ln -s -- "$SRC_PLATFORM" "$DST" | ||||
|
|
||||
| DST="/usr/share/sonic/hwsku" | ||||
| rm -rf -- "$DST" | ||||
| ln -s -- "$SRC_HWSKU" "$DST" | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why you need to create symlinks? Is it relating to k8s features? #Closed
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not for k8s feature, this was used in currently telemetry.sh
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. k8s can only have the volume name as static instead of generating volume based on label of the node - so we create the symlink at run time based on the node's sku/platform.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 2 DST folders above are RO mounted folder. I do not understand why you need to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added this logic to first remove the symlink/file/directory at DST in case they're not expected and then run "ln -s" just once. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @qiluo-msft - the DST folders are not mounted. the mounted folder is /usr/share/sonic/device/ |
||||
|
|
||||
| [[ "$(readlink -f /usr/share/sonic/platform)" == "$(readlink -f "$SRC_PLATFORM")" ]] || { echo "ERROR: platform symlink verification failed."; exit 1; } | ||||
| [[ "$(readlink -f /usr/share/sonic/hwsku)" == "$(readlink -f "$SRC_HWSKU")" ]] || { echo "ERROR: hwsku symlink verification failed."; exit 1; } | ||||
| else | ||||
| echo "Skipping Part 1 (launch_by=${launch_by:-unset})" | ||||
| fi | ||||
|
|
||||
| # ---check FEATURE table for switch --- | ||||
| while true; do | ||||
| STATE=$(redis-cli -n 4 HGET "FEATURE|telemetry" state) | ||||
| if [ "$STATE" == "enabled" ]; then | ||||
| STATE=$(redis-cli -n 4 HGET "FEATURE|telemetry" state || true) | ||||
| if [[ "${STATE}" == "enabled" ]]; then | ||||
| echo "Telemetry is enabled. Starting service..." | ||||
| break | ||||
| else | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.
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.
how do you pass in the environment variable? this is started by supervisord but I assume the environment variable set by k8s will also be available? #Closed
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.
This env will not be set by default so that existing mgmt test will keep working as originally, when k8s rollout telemetry image this env will be set via daemonset config