Skip to content

RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing#511

Open
vrenu2018 wants to merge 5 commits intodevelopfrom
RDKEMW-10725
Open

RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing#511
vrenu2018 wants to merge 5 commits intodevelopfrom
RDKEMW-10725

Conversation

@vrenu2018
Copy link
Copy Markdown
Contributor

@vrenu2018 vrenu2018 commented Apr 13, 2026

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

…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>
@vrenu2018 vrenu2018 requested a review from a team as a code owner April 13, 2026 15:53
Copilot AI review requested due to automatic review settings April 13, 2026 15:53
@vrenu2018 vrenu2018 changed the title RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name … RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing Apr 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.service to call a standalone /lib/rdk/gstreamer-cleanup.sh script instead of embedding complex shell logic in the unit.
  • Adds lib/rdk/gstreamer-cleanup.sh to 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.

Comment thread systemd_units/gstreamer-cleanup.service
Comment on lines +21 to +24
# 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}]"
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
# 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

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/gstreamer-cleanup.sh Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 13, 2026 17:27
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

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

Suggested change
( ! -f /opt/cdl_flashed_file_name && "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* ) || \
( ! -f /opt/cdl_flashed_file_name && ( -z "${CUR_IMAGE}" || "${PREV_CDLFILE}" != *"${CUR_IMAGE}"* ) ) || \

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +31
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;'
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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;'

Copilot uses AI. Check for mistakes.
Renuka Varry and others added 3 commits April 13, 2026 17:46
…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>
Copilot AI review requested due to automatic review settings April 14, 2026 14:07
@rdkcentral rdkcentral deleted a comment from Copilot AI Apr 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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;'
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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

Suggested change
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;'

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +42
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
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
@vrenu2018
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@nhanasi
Copy link
Copy Markdown
Contributor

nhanasi commented Apr 14, 2026

@vrenu2018 - plesae move the script/service to meta layer or Gstreamer module as these are not maintained by platform team
cc: @shibu-kv @vinupalackal @tdeva14

Copy link
Copy Markdown
Contributor

@shibu-kv shibu-kv left a comment

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants