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

Listing backups fails on some installations against Azure #595

Closed
2 tasks
adejanovski opened this issue Jul 5, 2023 · 0 comments · Fixed by #597
Closed
2 tasks

Listing backups fails on some installations against Azure #595

adejanovski opened this issue Jul 5, 2023 · 0 comments · Fixed by #597
Assignees
Labels
done Issues in the state 'done'

Comments

@adejanovski
Copy link
Contributor

adejanovski commented Jul 5, 2023

Project board link

While we couldn't reproduce the issue, we're seeing installations where backups are taken correctly but listing them fails with the following error:

Traceback (most recent call last):
 File "/usr/local/bin/medusa", line 8, in <module>
  sys.exit(cli())
 File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1128, in __call__
  return self.main(*args, **kwargs)
 File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1053, in main
  rv = self.invoke(ctx)
 File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1659, in invoke
  return _process_result(sub_ctx.command.invoke(sub_ctx))
 File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1395, in invoke
  return ctx.invoke(self.callback, **ctx.params)
 File "/usr/local/lib/python3.6/site-packages/click/core.py", line 754, in invoke
  return __callback(*args, **kwargs)
 File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 84, in new_func
  return ctx.invoke(f, obj, *args, **kwargs)
 File "/usr/local/lib/python3.6/site-packages/click/core.py", line 754, in invoke
  return __callback(*args, **kwargs)
 File "/usr/local/lib/python3.6/site-packages/medusa/medusacli.py", line 185, in list_backups
  medusa.listing.list_backups(medusaconfig, show_all)
 File "/usr/local/lib/python3.6/site-packages/medusa/listing.py", line 41, in list_backups
  cluster_backups = get_backups(config, show_all)
 File "/usr/local/lib/python3.6/site-packages/medusa/listing.py", line 29, in get_backups
  key=lambda b: b.started
 File "/usr/local/lib/python3.6/site-packages/medusa/storage/__init__.py", line 355, in list_cluster_backups
  key=lambda b: (b.name, b.started)
 File "/usr/local/lib/python3.6/site-packages/medusa/storage/__init__.py", line 190, in list_node_backups
  blobs_by_backup = self.group_backup_index_by_backup_and_node(backup_index_blobs)
 File "/usr/local/lib/python3.6/site-packages/medusa/storage/__init__.py", line 299, in group_backup_index_by_backup_and_node
  key=name_and_fqdn
 File "/usr/local/lib/python3.6/site-packages/medusa/storage/__init__.py", line 288, in name_and_fqdn
  return get_backup_name(blob), Storage.get_fqdn_from_any_index_blob(blob)
 File "/usr/local/lib/python3.6/site-packages/medusa/storage/__init__.py", line 285, in get_backup_name
  return blob.name.split('/')[2] if len(str(self.prefix_path)) <= 1 else blob.name.split('/')[3]
IndexError: list index out of range

After adding some debugging outputs, we see that the folders are returned when listing backups, giving a hierarchical view of the blobs instead of a flat one:

[2023-06-29 20:29:25,480] DEBUG: Loading storage_provider: azure_blobs
[2023-06-29 20:29:26,966] DEBUG: [Storage] Listing objects in index/backup_index
[2023-06-29 20:29:26,991] DEBUG: Found backup index blob: index/backup_index
[2023-06-29 20:29:26,991] DEBUG: Found backup index blob: index/backup_index/cassandra_backup_20230628
[2023-06-29 20:29:26,991] DEBUG: Found backup index blob: index/backup_index/cassandra_backup_20230628/differential....
...

This is unexpected and not dealt with correctly in the code.
We either need to filter out the folders when listing blobs, which should be made possible thanks to their 0 size.
We could also make the get_backup_name() method more resilient to such issues and do a precheck before trying to access the split array indices. If we don't have the index we're looking for, we can issue a warning and skip the file without erroring.

Definition of Done

  • when listing blobs in the list-backups command, empty files are filtered out
  • get_backup_name() will detect blob that aren't named as expected and ignore them
@adejanovski adejanovski added new Issues requiring triage ready Issues in the state 'ready' labels Jul 5, 2023
@adejanovski adejanovski removed the new Issues requiring triage label Jul 5, 2023
@adejanovski adejanovski added ready-for-review Issues in the state 'ready-for-review' review Issues in the state 'review' and removed ready Issues in the state 'ready' ready-for-review Issues in the state 'ready-for-review' labels Jul 17, 2023
@adejanovski adejanovski added in-progress Issues in the state 'in-progress' and removed review Issues in the state 'review' labels Jul 17, 2023
@adejanovski adejanovski added ready-for-review Issues in the state 'ready-for-review' review Issues in the state 'review' and removed in-progress Issues in the state 'in-progress' ready-for-review Issues in the state 'ready-for-review' labels Jul 18, 2023
rzvoncek added a commit that referenced this issue Jul 20, 2023
* Skip 0-sized blobs when listing storage. Fixes #595.

* Reading index blobs ignores wrongly pathed ones. Fixes #595.

* Remove unused argument about allowing listing empty files
@adejanovski adejanovski removed the review Issues in the state 'review' label Jul 20, 2023
@adejanovski adejanovski added the done Issues in the state 'done' label Jul 20, 2023
adejanovski pushed a commit that referenced this issue Sep 4, 2023
* Skip 0-sized blobs when listing storage. Fixes #595.

* Reading index blobs ignores wrongly pathed ones. Fixes #595.

* Remove unused argument about allowing listing empty files
adejanovski pushed a commit that referenced this issue Sep 4, 2023
* Skip 0-sized blobs when listing storage. Fixes #595.

* Reading index blobs ignores wrongly pathed ones. Fixes #595.

* Remove unused argument about allowing listing empty files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Issues in the state 'done'
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants