Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sqlite3 remote_resource_uuid update #249

Merged
merged 4 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.. Created by changelog.py at 2022-05-11, command
.. Created by changelog.py at 2022-05-25, command
'/Users/giffler/.cache/pre-commit/repor6pnmwlm/py_env-default/bin/changelog docs/source/changes compile --output=docs/source/changelog.rst'
based on the format of 'https://keepachangelog.com/'

#########
CHANGELOG
#########

[Unreleased] - 2022-05-11
[Unreleased] - 2022-05-25
=========================

Added
Expand All @@ -25,6 +25,7 @@ Fixed
-----

* Unique constraints in database schema have been fixed to allow same machine_type and remote_resource_uuid on multiple sites
* Update the remote_resource_uuid in sqlite registry on a each update

[0.6.0] - 2021-08-09
====================
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
category: fixed
summary: "Update the remote_resource_uuid in sqlite registry on a each update"
description: |
The change drone state initialisation update revealed a bug in TARDIS. The ``remote_resource_uuid`` in the
``SqliteRegistry`` plugin in not updated at all. As a result, TARDIS keeps crashing on restarts due to the missing
giffels marked this conversation as resolved.
Show resolved Hide resolved
``remote_resource_uuid`` until the DB has been removed.
pull_requests:
- 249
issues:
- 248
1 change: 1 addition & 0 deletions tardis/plugins/sqliteregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ async def notify(self, state: State, resource_attributes: AttributeDict) -> None

async def update_resource(self, bind_parameters: Dict) -> None:
sql_query = """UPDATE Resources SET updated = :updated,
remote_resource_uuid = :remote_resource_uuid,
state_id = (SELECT state_id FROM ResourceStates WHERE state = :state)
WHERE drone_uuid = :drone_uuid
AND site_id = (SELECT site_id FROM Sites WHERE site_name = :site_name)"""
Expand Down
7 changes: 3 additions & 4 deletions tests/plugins_t/test_sqliteregistry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging

from tardis.resources.dronestates import BootingState
from tardis.resources.dronestates import IntegrateState
from tardis.resources.dronestates import RequestState, DownState
from tardis.interfaces.state import State
from tardis.plugins.sqliteregistry import SqliteRegistry
Expand All @@ -27,7 +26,7 @@ def setUpClass(cls):
cls.test_machine_type = "MyGreatTestMachineType"
cls.tables_in_db = {"MachineTypes", "Resources", "ResourceStates", "Sites"}
cls.test_resource_attributes = {
"remote_resource_uuid": "bf85022b-fdd6-42b1-932d-086c288d4755",
"remote_resource_uuid": None,
"drone_uuid": f"{cls.test_site_name}-07af52405e",
"site_name": cls.test_site_name,
"machine_type": cls.test_machine_type,
Expand Down Expand Up @@ -66,7 +65,7 @@ def setUpClass(cls):
cls.test_updated_notify_result = (
cls.test_updated_resource_attributes["remote_resource_uuid"],
cls.test_updated_resource_attributes["drone_uuid"],
str(IntegrateState()),
str(BootingState()),
cls.test_updated_resource_attributes["site_name"],
cls.test_updated_resource_attributes["machine_type"],
str(cls.test_updated_resource_attributes["created"]),
Expand Down Expand Up @@ -220,7 +219,7 @@ def fetch_all():

run_async(
self.registry.notify,
IntegrateState(),
BootingState(),
self.test_updated_resource_attributes,
)

Expand Down