Compare commits

...

3 Commits

Author SHA1 Message Date
df40b779af Bump version to 0.9.92 2024-01-29 09:39:10 -05:00
db4f0881a2 Improve error handling and retries
1. Use the actual response code from the server on error, or 504 on
timeouts instead of 500.
2. Retry GET requests 3 times and only error if the last fails
2024-01-29 09:35:14 -05:00
9b51fe9f10 Use get() for newer keys in client 2024-01-29 09:21:02 -05:00
11 changed files with 52 additions and 17 deletions

View File

@ -1 +1 @@
0.9.91 0.9.92

View File

@ -1,5 +1,13 @@
## PVC Changelog ## PVC Changelog
###### [v0.9.92](https://github.com/parallelvirtualcluster/pvc/releases/tag/v0.9.92)
* [CLI Client] Adds the new restore state to the colours list for VM status
* [API Daemon] Fixes an incorrect variable assignment
* [Provisioner] Improves the error handling of various steps in the debootstrap and rinse example scripts
* [CLI Client] Fixes two bugs around missing keys that were added recently (uses get() instead direct dictionary refs)
* [CLI Client] Improves API error handling via GET retries (x3) and better server status code handling
###### [v0.9.91](https://github.com/parallelvirtualcluster/pvc/releases/tag/v0.9.91) ###### [v0.9.91](https://github.com/parallelvirtualcluster/pvc/releases/tag/v0.9.91)
* [Client CLI] Fixes a bug and improves output during cluster task events. * [Client CLI] Fixes a bug and improves output during cluster task events.

View File

@ -27,7 +27,7 @@ from distutils.util import strtobool as dustrtobool
import daemon_lib.config as cfg import daemon_lib.config as cfg
# Daemon version # Daemon version
version = "0.9.91" version = "0.9.92"
# API version # API version
API_VERSION = 1.0 API_VERSION = 1.0

View File

@ -140,7 +140,12 @@ def call_api(
# Determine the request type and hit the API # Determine the request type and hit the API
disable_warnings() disable_warnings()
try: try:
response = None
if operation == "get": if operation == "get":
retry_on_code = [429, 500, 502, 503, 504]
for i in range(3):
failed = False
try:
response = requests.get( response = requests.get(
uri, uri,
timeout=timeout, timeout=timeout,
@ -149,6 +154,17 @@ def call_api(
data=data, data=data,
verify=config["verify_ssl"], verify=config["verify_ssl"],
) )
if response.status_code in retry_on_code:
failed = True
continue
except requests.exceptions.ConnectionError:
failed = True
pass
if failed:
error = f"Code {response.status_code}" if response else "Timeout"
raise requests.exceptions.ConnectionError(
f"Failed to connect after 3 tries ({error})"
)
if operation == "post": if operation == "post":
response = requests.post( response = requests.post(
uri, uri,
@ -189,7 +205,8 @@ def call_api(
) )
except Exception as e: except Exception as e:
message = "Failed to connect to the API: {}".format(e) message = "Failed to connect to the API: {}".format(e)
response = ErrorResponse({"message": message}, 500) code = response.status_code if response else 504
response = ErrorResponse({"message": message}, code)
# Display debug output # Display debug output
if config["debug"]: if config["debug"]:

View File

@ -430,7 +430,7 @@ def format_list_osd(config, osd_list):
) )
continue continue
if osd_information["is_split"]: if osd_information.get("is_split") is not None:
osd_information["device"] = f"{osd_information['device']} [s]" osd_information["device"] = f"{osd_information['device']} [s]"
# Deal with the size to human readable # Deal with the size to human readable

View File

@ -1717,7 +1717,7 @@ def format_info(config, domain_information, long_output):
"{}Max live downtime:{} {}".format( "{}Max live downtime:{} {}".format(
ansiprint.purple(), ansiprint.purple(),
ansiprint.end(), ansiprint.end(),
f"{domain_information['migration_max_downtime']} ms", f"{domain_information.get('migration_max_downtime')} ms",
) )
) )

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup( setup(
name="pvc", name="pvc",
version="0.9.91", version="0.9.92",
packages=["pvc.cli", "pvc.lib"], packages=["pvc.cli", "pvc.lib"],
install_requires=[ install_requires=[
"Click", "Click",

10
debian/changelog vendored
View File

@ -1,3 +1,13 @@
pvc (0.9.92-0) unstable; urgency=high
* [CLI Client] Adds the new restore state to the colours list for VM status
* [API Daemon] Fixes an incorrect variable assignment
* [Provisioner] Improves the error handling of various steps in the debootstrap and rinse example scripts
* [CLI Client] Fixes two bugs around missing keys that were added recently (uses get() instead direct dictionary refs)
* [CLI Client] Improves API error handling via GET retries (x3) and better server status code handling
-- Joshua M. Boniface <joshua@boniface.me> Mon, 29 Jan 2024 09:39:10 -0500
pvc (0.9.91-0) unstable; urgency=high pvc (0.9.91-0) unstable; urgency=high
* [Client CLI] Fixes a bug and improves output during cluster task events. * [Client CLI] Fixes a bug and improves output during cluster task events.

View File

@ -33,7 +33,7 @@ import os
import signal import signal
# Daemon version # Daemon version
version = "0.9.91" version = "0.9.92"
########################################################## ##########################################################

View File

@ -49,7 +49,7 @@ import re
import json import json
# Daemon version # Daemon version
version = "0.9.91" version = "0.9.92"
########################################################## ##########################################################

View File

@ -44,7 +44,7 @@ from daemon_lib.vmbuilder import (
) )
# Daemon version # Daemon version
version = "0.9.91" version = "0.9.92"
config = cfg.get_configuration() config = cfg.get_configuration()