fedora-iot / greenboot

Generic Health Checking Framework for systemd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing 01_update_platforms_check.sh on Fedora IoT

alcir opened this issue · comments

commented

I don't know if it is a duplicate of #90 and #71, so excuse me in advance:

On a fresh Fedora IoT 37 I always get

There are problems connecting with the following URLs:
https://ostree.fedoraproject.org/iot
https://ostree.fedoraproject.org/iot/mirrorlist

Also running /usr/lib/greenboot/check/wanted.d/01_update_platforms_check.sh by hand after the boot, it returns the same result.

I'm not a great bash expert, but I suspect that the double quotes around the ${UPDATE_PLATFORM_URLS[@]} will result in a single line containing all the UPDATE_PLATFORM_URLS making ineffective the for loop

for UPDATE_PLATFORM_URL in "${UPDATE_PLATFORM_URLS[@]}"; do

At the end of the day, the curl command is
curl -o /dev/null -Isw '%{http_code}\n' "https://ostree.fedoraproject.org/iot https://ostree.fedoraproject.org/iot/mirrorlist"
leading to a 000 HTTP_STATUS variable (that is curl: (3) URL using bad/illegal format or missing URL)

In short: if in such line I remove the double quotes
for UPDATE_PLATFORM_URL in ${UPDATE_PLATFORM_URLS[@]}; do
the script works as expected.

This regression happened recently with 84bbd67

@alcir did you want to open a RHBZ for this issue so we can track it for F38? (if not I can)

Thanks for finding it!

commented

@alcir did you want to open a RHBZ for this issue so we can track it for F38? (if not I can)

I will

commented

Again, I'm not a bash expert, but instead of disable shellcheck, here

UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

we could actually populate the UPDATE_PLATFORM_URLS array simply in this way
UPDATE_PLATFORM_URLS=($(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*))
or
readarray -t UPDATE_PLATFORM_URLS < <(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

Again, I'm not a bash expert, but instead of disable shellcheck, here

UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

we could actually populate the UPDATE_PLATFORM_URLS array simply in this way
UPDATE_PLATFORM_URLS=($(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*))
or
readarray -t UPDATE_PLATFORM_URLS < <(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

Could you make this same suggestion on the PR itself (#94)? Maintaining the context of the suggestion would make it easier to discuss.

Yes that works for me, I also I made this that works as well using the tr command.

UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.' $REPOS_DIRECTORY/ | tr '\n' ' ')