Skip to content

fix(linstor): Database Backup when Linstor Controller is not the Pool Master. - #142

Open
Ythogtha wants to merge 10 commits into
3.2.12-8.3-develfrom
agf-linstor_backupdb_base
Open

fix(linstor): Database Backup when Linstor Controller is not the Pool Master.#142
Ythogtha wants to merge 10 commits into
3.2.12-8.3-develfrom
agf-linstor_backupdb_base

Conversation

@Ythogtha

@Ythogtha Ythogtha commented Jun 10, 2026

Copy link
Copy Markdown
  • Added secondary backup location outside of Linstor's DRBD mounts.
  • Throttling is restricted to backup on the Linstor Controller (needs access to files).
  • check_sr operates a regular backup only if it runs on the Linstor Controller, to allow throttling.
  • Retention is enforced by check_sr on Controller, with access to actual files.
  • Retention checks all backup.zip files for consistency :
    Valid zip with a non-empty linstordb.mv.db file inside,
    Reporting errors, and keeping only valid files.

@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch from 0e5dcb8 to f5e5bfc Compare June 10, 2026 09:59
@Ythogtha
Ythogtha changed the base branch from 3.2.12-8.3 to 3.2.12-8.3-cowutil-qcow2 June 10, 2026 10:04
@Wescoeur
Wescoeur changed the base branch from 3.2.12-8.3-cowutil-qcow2 to 3.2.12-8.3-devel June 10, 2026 12:58
@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch from b18a3f2 to 46bc6e3 Compare June 16, 2026 10:05
@Ythogtha Ythogtha changed the title Linstor: (fix) Remove all operations on backup files… fix(linstor): Database Backup when Linstor Controller is not the Pool Master. Jun 16, 2026
@Wescoeur
Wescoeur requested a review from a team June 16, 2026 15:15

@Millefeuille42 Millefeuille42 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Only small changes / clarification. Not all comments are actually blocking though.

Comment thread drivers/LinstorSR.py Outdated
Comment thread drivers/LinstorSR.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
@Millefeuille42
Millefeuille42 requested a review from a team June 17, 2026 08:54
Comment thread drivers/LinstorSR.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/LinstorSR.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment on lines +1773 to +1777
def is_controller(self):
"""Checks if the current host is the Linstor Controller.
This is done by checking that the Linstor database path is a mountpoint.
Which should only be the case on the Linstor Controller."""
return os.path.ismount(DATABASE_PATH)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be merged with existing code like cls._is_mounted(DATABASE_PATH).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So can you replace existing cls._is_mounted(DATABASE_PATH) calls with is_controller() ? Thx. :)

Comment thread drivers/linstorvolumemanager.py Outdated
@Wescoeur

Copy link
Copy Markdown
Member

I don't understand the choice of using a log file rather than directly listing the logs, either by using:

  • The file dates (not the most robust method if they are modified).
  • Or by using a clear and robust naming convention, in which case there are no problems.

@Ythogtha

Copy link
Copy Markdown
Author

I don't understand the choice of using a log file rather than directly listing the logs, either by using:

* The file dates (not the most robust method if they are modified).

* Or by using a clear and robust naming convention, in which case there are no problems.

Because we can't use throttling with filenames on SR operations (not check_sr), because we don't know if we have access to the files.
So in order to have a usable delay parameter, another solutions needs to be found.
I used a logfile.
But that's a bad one, and instead I removed the delay parameter, since only check_sr needs it, and it can be run on the Controller, therefore have access to the files, and use them as reference.

@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch 2 times, most recently from 9126138 to 6e1ab3d Compare June 18, 2026 17:43
@Ythogtha

Copy link
Copy Markdown
Author

Also, I converted some method into @classmethod since only the actual backup requires a linstor connection, and an instance of LinstorVolumeManager.

@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch 2 times, most recently from b090447 to b6b7676 Compare June 19, 2026 07:45
Comment thread drivers/LinstorSR.py
Comment thread drivers/LinstorSR.py
Comment thread drivers/linstorvolumemanager.py
Comment thread drivers/linstorvolumemanager.py
@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch 2 times, most recently from 3dba5e3 to 09c9925 Compare June 25, 2026 12:04
@Ythogtha
Ythogtha requested a review from Millefeuille42 June 26, 2026 14:45
@Nambrok
Nambrok force-pushed the 3.2.12-8.3-devel branch from e712aa5 to fce2d13 Compare June 29, 2026 07:36
@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch from 09c9925 to 6c0d0a3 Compare June 29, 2026 14:02
@Wescoeur
Wescoeur requested a review from klmp200 July 2, 2026 14:18
@Nambrok
Nambrok force-pushed the 3.2.12-8.3-devel branch from 6607beb to c4dce9e Compare July 2, 2026 14:25
@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch from 6c0d0a3 to b42bcd2 Compare July 7, 2026 08:42
Comment thread drivers/LinstorSR.py Outdated
Comment thread drivers/LinstorSR.py
Comment thread drivers/LinstorSR.py
Comment thread drivers/LinstorSR.py
Comment thread drivers/linstorvolumemanager.py
Comment thread drivers/LinstorSR.py
@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch 7 times, most recently from 3ed3cbd to b2d00c7 Compare July 20, 2026 13:03
Comment thread drivers/LinstorSR.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/LinstorSR.py Outdated
Comment thread drivers/LinstorSR.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/linstorvolumemanager.py Outdated
@Ythogtha
Ythogtha requested a review from Wescoeur July 30, 2026 15:37
Comment thread drivers/linstorvolumemanager.py Outdated
Comment thread drivers/LinstorSR.py Outdated
@Ythogtha
Ythogtha requested a review from Wescoeur July 31, 2026 15:23
@Nambrok
Nambrok force-pushed the 3.2.12-8.3-devel branch 2 times, most recently from 1825cbe to 9978d7f Compare August 13, 2026 07:45
@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch from 14961f8 to 43e4e88 Compare August 13, 2026 09:21
@Millefeuille42
Millefeuille42 self-requested a review August 19, 2026 13:39

@Wescoeur Wescoeur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok for merge after rebase. Just one comment to add regarding the new LINSTOR_AUTO_BACKUP_DELAY constant and a remaining refactoring.

Comment thread drivers/constants.py
# on the master.
NS_PREFIX_LVM: Final = "lvm-"

LINSTOR_AUTO_BACKUP_DELAY = 3600

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should add a comment here to explain usage and unit used.
For example: "Delay expressed in seconds between two LINSTOR DB backups launched by check_sr helper.

Comment thread drivers/linstorvolumemanager.py Outdated
Comment on lines +1773 to +1777
def is_controller(self):
"""Checks if the current host is the Linstor Controller.
This is done by checking that the Linstor database path is a mountpoint.
Which should only be the case on the Linstor Controller."""
return os.path.ismount(DATABASE_PATH)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So can you replace existing cls._is_mounted(DATABASE_PATH) calls with is_controller() ? Thx. :)

- Retention of 10 backups from operations, and check_sr always saves on latest.
- Provides a secondary backup location, with the same retention policy.

Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
… Master.

* Added secondary backup location outside of Linstor's DRBD mounts.
* Throttling uses a logfile for backup operations.
* sr_scan operates a regular backup only if it runs on the Linstor Controller.
* Retention is enforced by sr_scan on controller, with access to actual files.
* Exceptions are raised only on backup errors from sr_scan ;
  Other operations will only report in SMlog.
* Retention checks all backup.zip files for consistency :
  Valid zip with a non-empty linstordb.mv.db file inside,
  Reporting errors, and keeping only valid files.

Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
check_sr works only on the Controller to have access to the backup files.
It applies Validation, Retention, and Throttling for the automatic backup.
All three of which requires access to the backup files, on the Controller.

Removal of the logfile to manage throttling for normal operation.
Hence removal of the delay parameter.

Restricted caught Exceptions in backup validation to (FileNotFoundError, zipfile.BadZipFile).

Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
Don't except/raise LinstorDatabaseBackupError in _check_database_backup().
Simpler glob search for backup files, as the date is properly validated by datetime.
Fix bug in database_backup_age().

Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
database_backup_path instead of database_backup_file because it is a str|Path.
Throttling delay converted to Constant.

Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
…le None self._linstor

Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
@Ythogtha
Ythogtha force-pushed the agf-linstor_backupdb_base branch from 43e4e88 to d341622 Compare September 3, 2026 11:07
Also some explanations on new LINSTOR_AUTO_BACKUP_DELAY in constants.py

Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
@Ythogtha
Ythogtha requested a review from Wescoeur September 4, 2026 08:27
Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
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.

4 participants