Skip to content

Commit

Permalink
Fixed bugs in the version checking
Browse files Browse the repository at this point in the history
Downgraded the minimally expected version to 15, which is the lowest
level the application is written for.
  • Loading branch information
iagaponenko committed Aug 1, 2024
1 parent 6b4578d commit 853312f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
2 changes: 2 additions & 0 deletions rootfs/ingest/python/qserv/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ def post(
"""
if payload is None:
payload = dict()
# Set version if it does not exists
payload["version"] = payload.get("version", version.REPL_SERVICE_VERSION)
if auth is True:
payload["auth_key"] = self.authKey
timeouts: Union[float, Tuple[float, float], Tuple[float, None]]
Expand Down
9 changes: 3 additions & 6 deletions rootfs/ingest/python/qserv/ingestconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,16 @@ def _check_version(self, yaml: dict) -> None:
if "version" in yaml:
fileversion = yaml["version"]

if fileversion is None or not (
_MIN_SUPPORTED_VERSION <= fileversion <= version.INGEST_CONFIG_VERSION
):
if fileversion is None or fileversion < _MIN_SUPPORTED_VERSION:
_LOG.critical(
"The ingest configuration file (ingest.yaml) version "
"is not in the range supported by qserv-ingest "
"(is %s, expected between %s and %s)",
"(is %s, expected at least %s)",
fileversion,
_MIN_SUPPORTED_VERSION,
version.REPL_SERVICE_VERSION,
)
sys.exit(1)
_LOG.info("Ingest configuration file version: %s", version.REPL_SERVICE_VERSION)
_LOG.info("Ingest configuration file version: %s", fileversion)


@dataclass
Expand Down
10 changes: 4 additions & 6 deletions rootfs/ingest/python/qserv/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,23 +330,21 @@ def json_db(self) -> Dict[str, Any]:
return self._json_db

def _check_version(self) -> None:
"""Check metadata file version
and exit if its value is not supported"""
"""Check metadata file version and exit if its value is not supported"""
fileversion = None
if "version" in self.metadata:
fileversion = self.metadata["version"]

if fileversion is None or not (_MIN_SUPPORTED_VERSION <= fileversion <= version.REPL_SERVICE_VERSION):
if fileversion is None or fileversion < _MIN_SUPPORTED_VERSION:
_LOG.critical(
"The metadata file (%s) version is not in the range supported by qserv-ingest "
"(is %s, expected between %s and %s)",
"(is %s, expected at least %s)",
self.metadata_url,
fileversion,
_MIN_SUPPORTED_VERSION,
version.REPL_SERVICE_VERSION,
)
sys.exit(1)
_LOG.info("Metadata file version: %s", version.REPL_SERVICE_VERSION)
_LOG.info("Metadata file version: %s", fileversion)

@property
def table_contribs_spec(self) -> Generator[TableContributionsSpec, None, None]:
Expand Down
17 changes: 4 additions & 13 deletions rootfs/ingest/python/qserv/replicationclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(

self.repl_url = util.trailing_slash(repl_url)
self.http = Http(timeout_read_sec, timeout_write_sec, auth_path)
self._check_version()
self._report_version()
self.index_url = urllib.parse.urljoin(self.repl_url, "replication/sql/index")

def abort_all_transactions(self, database: str) -> None:
Expand Down Expand Up @@ -102,20 +102,11 @@ def close_transaction(self, database: str, transaction_id: int, success: bool) -
for trans in responseJson["databases"][database]["transactions"]:
_LOG.debug("Close transaction (id: %s state: %s)", trans["id"], trans["state"])

def _check_version(self) -> None:
"""Check replication service version and exit if it is not
the expected one
"""
def _report_version(self) -> None:
"""Get and report replication service version"""
url = urllib.parse.urljoin(self.repl_url, "meta/version")
responseJson = self.http.get(url)
if responseJson["version"] != version.REPL_SERVICE_VERSION:
_LOG.critical(
"Invalid replication server version (is %s, expected %s)",
responseJson["version"],
version.REPL_SERVICE_VERSION,
)
sys.exit(1)
_LOG.info("Replication service version: v%s", version.REPL_SERVICE_VERSION)
_LOG.info("Replication service version: %s, this application's version: %s", responseJson["version"], version.REPL_SERVICE_VERSION)

def database_config(self, database: str, ingest_service_config: IngestServiceConfig) -> None:
"""Set replication system configuration for a given database https://co
Expand Down
3 changes: 1 addition & 2 deletions rootfs/ingest/python/qserv/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@
# ---------------------------------
_LOG = logging.getLogger(__name__)

REPL_SERVICE_VERSION = 30
INGEST_CONFIG_VERSION = 15
REPL_SERVICE_VERSION = 15

0 comments on commit 853312f

Please sign in to comment.