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

use dictionary instead of list for Controller.state['backups'] #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kathia-barahona
Copy link
Contributor

@kathia-barahona kathia-barahona commented Sep 28, 2023

About this change: What it does, why it matters

Changed the way we store backups in the controller's state, main reason is because there a lot of scenarios where we need to fetch a backup based on its stream id. Also added more typing when backups are refreshed.

Not super urgent, but will be nice to have.

@@ -75,6 +75,26 @@ class BaseBackupFailureReason(str, enum.Enum):
xtrabackup_error = "xtrabackup_error"


class BaseBackup(TypedDict, total=False):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moved this from myhoard.Controller and added rest of expected fields. The total=False is mainly in case a basebackup.json file is not containing all keys (ideally shouldn't happen but just in case)

backups = []
for site_name, site_config in backup_sites.items():
file_storage = site_transfers.get(site_name)
def get_backups(self) -> Dict[str, Backup]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed previous arguments... 🤷‍♀️ we were just passing class properties that can be accessed here and it was quite odd.

@@ -75,7 +75,7 @@ async def backup_list(self, _request):
}
with self.controller.lock:
if self.controller.state["backups_fetched_at"]:
response["backups"] = self.controller.state["backups"]
response["backups"] = list(self.controller.state["backups"].values())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment left as a list here, I don't see a reason for changing the response type

@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2023

Codecov Report

Merging #175 (818862e) into master (9654217) will increase coverage by 0.64%.
The diff coverage is 85.24%.

@@            Coverage Diff             @@
##           master     #175      +/-   ##
==========================================
+ Coverage   78.93%   79.57%   +0.64%     
==========================================
  Files          17       17              
  Lines        4400     4396       -4     
  Branches      995      983      -12     
==========================================
+ Hits         3473     3498      +25     
+ Misses        693      667      -26     
+ Partials      234      231       -3     
Files Coverage Δ
myhoard/backup_stream.py 79.91% <100.00%> (+0.49%) ⬆️
myhoard/web_server.py 77.01% <100.00%> (ø)
myhoard/controller.py 81.73% <77.50%> (-0.19%) ⬇️

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

myhoard/controller.py Outdated Show resolved Hide resolved
@rikonen
Copy link
Contributor

rikonen commented Sep 29, 2023

I don't know if we have any policy related to backward compatibility and probably earlier changes have been incompatible too (perhaps to lesser extent) but if anyone is doing in-place upgrades for MyHoard then it will break when upgrading from a version prior to this one.

@kathia-barahona
Copy link
Contributor Author

I don't know if we have any policy related to backward compatibility and probably earlier changes have been incompatible too (perhaps to lesser extent) but if anyone is doing in-place upgrades for MyHoard then it will break when upgrading from a version prior to this one.

Oh yes, this will definitely break for in-place upgrades 😬 tho not sure if working on backward compatibility is worth it, old state file should be just removed

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