Skip to content

Update telemetry entry sh to support k8s start and keep compatible with systemd start flow#24061

Merged
qiluo-msft merged 3 commits intosonic-net:masterfrom
FengPan-Frank:telemetrysh
Sep 26, 2025
Merged

Update telemetry entry sh to support k8s start and keep compatible with systemd start flow#24061
qiluo-msft merged 3 commits intosonic-net:masterfrom
FengPan-Frank:telemetrysh

Conversation

@FengPan-Frank
Copy link
Copy Markdown
Contributor

@FengPan-Frank FengPan-Frank commented Sep 20, 2025

Why I did it

Update telemetry entry sh to support k8s start and keep compatible with systemd start flow

How I did it

With k8s start, it will contains below env

sudo docker run -d --rm -it --privileged
--net=host --pid=host --ipc=host
--tmpfs /usr/share/sonic:rw
-v /usr/share/sonic/device:/usr/share/sonic/device:ro
-v /etc/sonic:/etc/sonic:ro
-v /etc/localtime:/etc/localtime:ro
-v /host/reboot-cause:/host/reboot-cause
-v /var/run/redis:/var/run/redis
-v /var/run/redis-chassis:/var/run/redis-chassis:ro
-v /usr/share/sonic/templates/rsyslog-container.conf.j2:/usr/share/sonic/templates/rsyslog-container.conf.j2:ro
-e RUNTIME_OWNER=kube
-e SYSLOG_TARGET_IP=127.0.0.1
-e NAMESPACE_PREFIX=asic
-e launch_by=k8s
docker-sonic-telemetry:latest

by default it will not be used so that existing rollout mgmt test will not be break.

How to verify it

image

Which release branch to backport (provide reason below if selected)

  • 202205
  • 202211
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@FengPan-Frank FengPan-Frank changed the title Update telemetry entry sh to support k8s start and keep compatible with Update telemetry entry sh to support k8s start and keep compatible with systemd start flow Sep 20, 2025
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

#!/usr/bin/env bash

# Control with env var launch_by, only used if container is launched via k8s
if [[ "${launch_by:-}" == "k8s" ]]; then
Copy link
Copy Markdown

@make1980 make1980 Sep 20, 2025

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

Copy link
Copy Markdown
Contributor Author

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


DST="/usr/share/sonic/hwsku"
rm -rf -- "$DST"
ln -s -- "$SRC_HWSKU" "$DST"
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Sep 21, 2025

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not for k8s feature, this was used in currently telemetry.sh

docker create {{docker_image_run_opt}} \
, we only try to launch telemetry with the same parameter/mount/env but from k8s instead of systemd path.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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 rm them and create symlink.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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/

[[ -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}")" \
Copy link
Copy Markdown

@make1980 make1980 Sep 24, 2025

Choose a reason for hiding this comment

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

/usr/share/sonic/device/device/${PLATFORM}

what's this? shouldn't we remove it? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

seems indeed redundant check, removed.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to msft-202412: Azure/sonic-buildimage-msft#1700

FengPan-Frank added a commit to FengPan-Frank/sonic-buildimage that referenced this pull request Dec 4, 2025
…th systemd start flow (sonic-net#24061)

Why I did it
Update telemetry entry sh to support k8s start and keep compatible with systemd start flow

How I did it
With k8s start, it will contains below env

sudo docker run -d --rm -it --privileged
--net=host --pid=host --ipc=host
--tmpfs /usr/share/sonic:rw
-v /usr/share/sonic/device:/usr/share/sonic/device:ro
-v /etc/sonic:/etc/sonic:ro
-v /etc/localtime:/etc/localtime:ro
-v /host/reboot-cause:/host/reboot-cause
-v /var/run/redis:/var/run/redis
-v /var/run/redis-chassis:/var/run/redis-chassis:ro
-v /usr/share/sonic/templates/rsyslog-container.conf.j2:/usr/share/sonic/templates/rsyslog-container.conf.j2:ro
-e RUNTIME_OWNER=kube
-e SYSLOG_TARGET_IP=127.0.0.1
-e NAMESPACE_PREFIX=asic
-e launch_by=k8s
docker-sonic-telemetry:latest

by default it will not be used so that existing rollout mgmt test will not be break.

Signed-off-by: Feng Pan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants