diff options
| author | John Estabrook <jestabro@vyos.io> | 2026-02-10 11:48:09 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-10 11:48:09 -0600 |
| commit | 4824a493701180b2d9eb37bce6420cf5ccf602c8 (patch) | |
| tree | 009c8b124bc3851917341098a67edb4ecab3c229 /src/conf_mode | |
| parent | d9aa7405a3e0259370b86caa7ea704f0022faf32 (diff) | |
| parent | 8262f78e0013291f747203e0b3768bb412bf1aed (diff) | |
| download | vyos-1x-4824a493701180b2d9eb37bce6420cf5ccf602c8.tar.gz vyos-1x-4824a493701180b2d9eb37bce6420cf5ccf602c8.zip | |
Merge pull request #4980 from alexandr-san4ez/T7945-current
update-check: T7945: Improve reliability during early boot and error handling
Diffstat (limited to 'src/conf_mode')
| -rwxr-xr-x | src/conf_mode/system_update-check.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/conf_mode/system_update-check.py b/src/conf_mode/system_update-check.py index 7ed736eac..6a07d93a6 100755 --- a/src/conf_mode/system_update-check.py +++ b/src/conf_mode/system_update-check.py @@ -15,10 +15,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import json +import requests from pathlib import Path from sys import exit +from vyos.base import Warning from vyos.config import Config from vyos.utils.process import call from vyos import ConfigError @@ -54,6 +56,21 @@ def verify(config): if 'url' not in config: raise ConfigError('URL is required!') + url = config['url'] + + # Make sure that provided URL is available and responses a valid JSON + # otherwise print warning and display type of error (connection, timeout and etc.) + try: + response = requests.get(url, timeout=10) + response.raise_for_status() + response.json() + except requests.exceptions.RequestException as e: + error_type = type(e).__name__ + Warning( + '"system update-check url" has a valid URL but ' + f'unable to retrieve data from the server: {error_type}' + ) + def generate(config): # bail out early - looks like removal from running config |
