RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing#511
RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing#511
Conversation
…is missing Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent gstreamer-cleanup from running on every reboot when /opt/cdl_flashed_file_name is missing by moving the cleanup decision logic into a dedicated script and refining the conditions.
Changes:
- Refactors
gstreamer-cleanup.serviceto call a standalone/lib/rdk/gstreamer-cleanup.shscript instead of embedding complex shell logic in the unit. - Adds
lib/rdk/gstreamer-cleanup.shto compute flashed-image state and decide whether to clear/regenerate the GStreamer registry.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| systemd_units/gstreamer-cleanup.service | Replaces inline cleanup logic with a call to /lib/rdk/gstreamer-cleanup.sh and keeps milestone logging. |
| lib/rdk/gstreamer-cleanup.sh | Implements the new conditional cleanup/regeneration logic when CDL marker files are missing or changed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Print the variables for debugging - can be removed once the logic is stable | ||
| echo "DEBUG: CDLFILE=[${CDLFILE}]" | ||
| echo "DEBUG: PREV_CDLFILE=[${PREV_CDLFILE}]" | ||
| echo "DEBUG: CUR_IMAGE=[${CUR_IMAGE}]" |
There was a problem hiding this comment.
The script currently prints three DEBUG: lines on every boot. This will add noise to boot logs/metrics and may be undesirable long-term. Consider gating these behind an environment flag (e.g., GST_CLEANUP_DEBUG=1) or removing them once validation is complete.
| # Print the variables for debugging - can be removed once the logic is stable | |
| echo "DEBUG: CDLFILE=[${CDLFILE}]" | |
| echo "DEBUG: PREV_CDLFILE=[${PREV_CDLFILE}]" | |
| echo "DEBUG: CUR_IMAGE=[${CUR_IMAGE}]" | |
| # Print the variables for debugging only when explicitly enabled | |
| if [[ "${GST_CLEANUP_DEBUG}" == "1" ]]; then | |
| echo "DEBUG: CDLFILE=[${CDLFILE}]" | |
| echo "DEBUG: PREV_CDLFILE=[${PREV_CDLFILE}]" | |
| echo "DEBUG: CUR_IMAGE=[${CUR_IMAGE}]" | |
| fi |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Check all cleanup conditions in a single if statement using bash syntax | ||
| if [[ ! -f /opt/previous_flashed_file_name || \ | ||
| ( ! -f /opt/cdl_flashed_file_name && "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* ) || \ |
There was a problem hiding this comment.
Cleanup condition depends on CUR_IMAGE, but if /version.txt exists yet the grep doesn't match (or returns an empty value), the pattern "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* will never be true (empty pattern matches everything). That can incorrectly skip registry cleanup when /opt/cdl_flashed_file_name is missing. Consider treating an empty CUR_IMAGE as "unknown" and forcing cleanup (or explicitly require CUR_IMAGE to be non-empty before using it in the match).
| ( ! -f /opt/cdl_flashed_file_name && "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* ) || \ | |
| ( ! -f /opt/cdl_flashed_file_name && ( -z "${CUR_IMAGE}" || "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* ) ) || \ |
| ExecStartPre=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;' | ||
| ExecStart=-/lib/rdk/gstreamer-cleanup.sh | ||
| ExecStartPost=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;' |
There was a problem hiding this comment.
ExecStartPre/ExecStartPost were switched to /bin/bash -c, but the commands used are POSIX shell-compatible and the rest of the unit files in this repo consistently use /bin/sh for these hooks (e.g., systemd_units/dropbear.service:28, systemd_units/restart-parodus.service:25). Consider reverting these to /bin/sh -c for consistency and to avoid an unnecessary bash dependency at boot.
| ExecStartPre=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;' | |
| ExecStart=-/lib/rdk/gstreamer-cleanup.sh | |
| ExecStartPost=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;' | |
| ExecStartPre=/bin/sh -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;' | |
| ExecStart=-/lib/rdk/gstreamer-cleanup.sh | |
| ExecStartPost=/bin/sh -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;' |
…is missing Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com>
Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ExecStartPre=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;' | ||
| ExecStart=-/lib/rdk/gstreamer-cleanup.sh | ||
| ExecStartPost=/bin/bash -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;' | ||
| ExecStop=/bin/sh -c 'FW_UPDATE_STATE=$(cat /opt/fwdnldstatus.txt | grep FwUpdateState | cut -d "|" -f2); echo "FW_UPDATE_STATE: $FW_UPDATE_STATE"; if [ "$FW_UPDATE_STATE" == "Preparing to reboot" ]; then echo "Removing gstreamer registry after firmware update"; rm -rf /opt/.gstreamer; fi;' |
There was a problem hiding this comment.
ExecStop runs under /bin/sh but uses == in the [ ... ] test, which is not POSIX and can fail on systems where /bin/sh is not bash. Use = for the string comparison (or switch the command to /bin/bash -c for consistency with the rest of the unit).
| ExecStop=/bin/sh -c 'FW_UPDATE_STATE=$(cat /opt/fwdnldstatus.txt | grep FwUpdateState | cut -d "|" -f2); echo "FW_UPDATE_STATE: $FW_UPDATE_STATE"; if [ "$FW_UPDATE_STATE" == "Preparing to reboot" ]; then echo "Removing gstreamer registry after firmware update"; rm -rf /opt/.gstreamer; fi;' | |
| ExecStop=/bin/sh -c 'FW_UPDATE_STATE=$(cat /opt/fwdnldstatus.txt | grep FwUpdateState | cut -d "|" -f2); echo "FW_UPDATE_STATE: $FW_UPDATE_STATE"; if [ "$FW_UPDATE_STATE" = "Preparing to reboot" ]; then echo "Removing gstreamer registry after firmware update"; rm -rf /opt/.gstreamer; fi;' |
| if [[ -f /version.txt ]]; then | ||
| CUR_IMAGE=$(grep "^imagename:" /version.txt | cut -d":" -f2) | ||
| fi | ||
|
|
||
| # Print the variables for debugging - can be removed once the logic is stable | ||
| echo "DEBUG: CDLFILE=[${CDLFILE}]" | ||
| echo "DEBUG: PREV_CDLFILE=[${PREV_CDLFILE}]" | ||
| echo "DEBUG: CUR_IMAGE=[${CUR_IMAGE}]" | ||
|
|
||
| # Check all cleanup conditions in a single if statement using bash syntax | ||
| if [[ ! -f /opt/previous_flashed_file_name || \ | ||
| ( ! -f /opt/cdl_flashed_file_name && "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* ) || \ | ||
| ( -f /opt/cdl_flashed_file_name && "${CDLFILE}" != *"${PREV_CDLFILE}"* ) ]]; then |
There was a problem hiding this comment.
CUR_IMAGE is parsed via grep "^imagename:" ... | cut -d":" -f2 without trimming, so it can contain leading whitespace/newlines; that will break the later substring match against PREV_CDLFILE. Also, if /version.txt is missing or imagename isn’t found, CUR_IMAGE stays empty and the condition "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* becomes always false, meaning the cleanup will be skipped even though /opt/cdl_flashed_file_name is missing. Please trim CUR_IMAGE and add an explicit fallback for an empty CUR_IMAGE (e.g., treat it as a cleanup-required case or derive the current image name from another source).
|
I have read the CLA Document and I hereby sign the CLA |
|
@vrenu2018 - plesae move the script/service to meta layer or Gstreamer module as these are not maintained by platform team |
shibu-kv
left a comment
There was a problem hiding this comment.
Historically there was a tendency to add all scripts into sysint (System Integration) repository. With RDK-E model we have already switched to controlled component ownership model. In my opinion, we should move the gstreamer service and its supporting utilities to repos or meta layers maintained by gstreamer component owners.
Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing
Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log
Risks: low