Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

installer: exit if FTL update check fails#6316

Merged
dschaper merged 1 commit intopi-hole:developmentfrom
MichaIng:fix-/ftl-check-return-handling
Jul 10, 2025
Merged

installer: exit if FTL update check fails#6316
dschaper merged 1 commit intopi-hole:developmentfrom
MichaIng:fix-/ftl-check-return-handling

Conversation

@MichaIng
Copy link
Contributor

@MichaIng MichaIng commented Jun 25, 2025

Thank you for your contribution to the Pi-hole Community!

Please read the comments below to help us consider your Pull Request.

We are all volunteers and completing the process outlined will help us review your commits quicker.

Please make sure you

  1. Base your code and PRs against the repositories developmental branch.
  2. Sign Off all commits as we enforce the DCO for all contributions
  3. Sign all your commits as they must have verified signatures
  4. File a pull request for any change that requires changes to our documentation at our documentation repo

What does this PR aim to accomplish?:

The return code of FTLdetect() is used in the installer to know whether FTL has been installed or not.

The function however returns an error only, if the download of FTL fails, not if checking for a latest version/update of FTL fails. This way, installs and rapairs can continue without or with ourdated FTL until pihole-FTL migrate v6, which hangs endlessly, if it is a v5 FTL.

How does this PR accomplish the above?:

This commit handles the return code in FTLdetect(), and lets it return true only if FTL download succeeded, or if the update check succeeded and FTL is up-to-date. Else, it could neither be repaired, nor installed, and the error message should give a hint what went wrong, hence exit.

FTLdetect() is not called by any other script, hence this change has no surprising effect elsewhere.

Link documentation PRs if any are needed to support this PR:


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code and I have tested my changes.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)
  6. I have checked that another pull request for this purpose does not exist.
  7. I have considered, and confirmed that this submission will be valuable to others.
  8. I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  9. I give this submission freely, and claim no ownership to its content.

  • I have read the above and my PR is ready for review. Check this box to confirm

@MichaIng MichaIng requested a review from a team as a code owner June 25, 2025 22:43
@MichaIng MichaIng force-pushed the fix-/ftl-check-return-handling branch 2 times, most recently from 18b6f9e to c010ce6 Compare June 25, 2025 22:52
The return code of `FTLdetect()` is used in the installer to know whether FTL has been installed or not.

The function however returns an error only, if the download of FTL fails, not if checking for a latest version/update of FTL fails. This way, installs and rapairs can continue without or with ourdated FTL until `pihole-FTL migrate v6`, which hangs endlessly, if it is a v5 FTL.

This commit handles the return code in `FTLdetect()`, and lets it return true only if FTL download succeeded, or if the update check succeeded and FTL is up-to-date. Else, it could neither be repaired, nor installed, and the error message should give a hint what went wrong, hence exit.

`FTLdetect()` is not called by any other script, hence this change has no surprising effect elsewhere.

Additionally, a syntax error in the `FTLcheckUpdate()` function itself is fixed, which masks the `check_download_exists()` return code, hence always leads to error code 4, if the FTL branch is not `master`.

Signed-off-by: MichaIng <[email protected]>
@MichaIng MichaIng force-pushed the fix-/ftl-check-return-handling branch from c010ce6 to 3a35e58 Compare June 25, 2025 22:53
@MichaIng
Copy link
Contributor Author

MichaIng commented Jun 25, 2025

Now I recognized the main problem which causes the forum issue which triggered this PR: https://discourse.pi-hole.net/t/80614

local var has an own return code, since local is a command, hence below code in FTLcheckUpdate()

        if ! check_download_exists "$path"; then
            local status
            status=$?

masks the return code of check_download_exists, and status is always 0, which leads to return 4 below, and hence the FTL download did not happen, and this did not exit the installer.

@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/after-pihole-update-to-v6-web-version-n-a-migration-to-pihole-toml-failed-file-missing/80614/12

@MichaIng
Copy link
Contributor Author

Btw, the update script handles the exit codes of the function, prints meaningful error messages (hiding the origin ones, but that makes sense as of update vs install/repair purpose), and exits on uncommon errors. But it continues if the FTL update check returns with 404 on non-master branch, only suggesting to switch to a valid branch: https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/update.sh#L157-L177

This can also lead to systems with v6 core/web but v5 FTL, failing at config migration. IMO it makes sense to also abort the update in that case. The updater prints the command to change it, so it is even easier to recognize that issue and fix it, if this message is the last on the console. Or is there a particular reason/need this is currently allowed to continue?

@dschaper
Copy link
Member

No, it should not be allowed to continue.

The base requirement for everything in v6 is for FTL to be v6. There should never be a situation where the core or web repos are v6 while FTL is still v5. If the core/web are v5 and there is no FTL v6 binary installed or available to be installed then there should not be a partial update by moving only core/web to v6.

@dschaper
Copy link
Member

local var has an own return code, since local is a command, hence below code in FTLcheckUpdate()

Ah so status=$? is setting status to the return valued/result of local status which will always be 0. Make sense.

@dschaper dschaper merged commit 080e1cc into pi-hole:development Jul 10, 2025
15 checks passed
@MichaIng MichaIng deleted the fix-/ftl-check-return-handling branch July 10, 2025 19:23
@MichaIng
Copy link
Contributor Author

No, it should not be allowed to continue.

The base requirement for everything in v6 is for FTL to be v6. There should never be a situation where the core or web repos are v6 while FTL is still v5. If the core/web are v5 and there is no FTL v6 binary installed or available to be installed then there should not be a partial update by moving only core/web to v6.

Agreed, I opened a PR for this: #6329

@dschaper dschaper added this to the v6.1.3 milestone Jul 12, 2025
@dschaper dschaper mentioned this pull request Jul 14, 2025
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.

3 participants