Skip to content

stored: add new volume status 'Unlabeled'#2207

Merged
BareosBot merged 10 commits intobareos:masterfrom
florian-at-bareos:dev/fburger/master/fix-media-record
Jul 30, 2025
Merged

stored: add new volume status 'Unlabeled'#2207
BareosBot merged 10 commits intobareos:masterfrom
florian-at-bareos:dev/fburger/master/fix-media-record

Conversation

@florian-at-bareos
Copy link
Contributor

@florian-at-bareos florian-at-bareos commented Mar 12, 2025

This status is the initial status when a new volume is created in the catalog and is changed if the storage daemon (successfully) wrote on the volume.

Fixes #1804

Currently:

  1. the sd asks for a new volume to append to
  2. the director creates a new record in the catalog with that new volume with "Append" status and sends the information to the sd
  3. the sd can't label the volume, errors out
    -> the volume record with "Append" status persists in the catalog even if no volume with that name was ever created by the sd

With this PR:

  1. the sd asks for a new volume to append to
  2. the director creates a new record in the catalog with that new volume with "Unlabeled" status and sends the information to the sd
  3. the sd can't label the volume, errors out
    -> the volume record with "Unlabeled" status persists in the catalog and is selected again if the sd asks for a volume to append to until labeling works

If the sd successfully wrote on the "Unlabeled" volume, its status is updated to "Append", "Full" or whatever the sd decides.

Note:
Manually updating an existing volume record in the catalog to the status "Unlabeled" is not dangerous, no backup data is ever overwritten!
When the sd wants to send volume updates to the director, and the status is "Unlabeled" but has written bytes, the status is set to "Append".

  • Update docs accordingly

Thank you for contributing to the Bareos Project!

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
    Required backport PRs have been created
  • Correct milestone is set
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR

@florian-at-bareos florian-at-bareos added the bug This addresses a bug label Mar 12, 2025
@florian-at-bareos florian-at-bareos added this to the 25.0.0 milestone Mar 12, 2025
@florian-at-bareos florian-at-bareos self-assigned this Mar 12, 2025
@florian-at-bareos florian-at-bareos force-pushed the dev/fburger/master/fix-media-record branch from 2d99d80 to 2ff782f Compare March 12, 2025 14:26
@florian-at-bareos florian-at-bareos force-pushed the dev/fburger/master/fix-media-record branch from 2ff782f to 67f2ded Compare March 14, 2025 14:02
@arogge arogge self-requested a review March 17, 2025 10:26
@florian-at-bareos
Copy link
Contributor Author

Currently, when manually labeling a volume its status is set to unlabeled

@florian-at-bareos florian-at-bareos marked this pull request as ready for review March 24, 2025 08:16
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

  • You'll need to upgrade the database correctly. This means we need to introduce a new database version and create a migration script for that.
  • As far as I can tell an unlabeled volume was definitely never written to (as the label would have been written first), so neither the purge nor the prune operation makes sense on such a volume.
  • When selecting a volume, I think we should prefer appendable volumes over unlabeled ones

@florian-at-bareos
Copy link
Contributor Author

  • I don't know how to write such a migration script and how much effort it is
  • You're right, that is a little awkward but it was necessary to integrate with the existing behaviour because otherwise "purge" and "prune" commands would just fail for a newly created volume which it doesn't currently. I'll think about how one can make this more intuitive.
  • that's the behaviour of the current changes

maybe we can discuss sometime how to pursue with this.

@arogge
Copy link
Member

arogge commented Apr 9, 2025

I don't know how to write such a migration script and how much effort it is

The migration scripts are in core/src/cats/ddl/updates.
We have a schema version (usually that's the Bareos target version prefixed by a 2 and suffixed with a 0, i.e. 2250 for Bareos 25), this must be set correctly in the create-script, too.

For the upgrade script you create a new file (probably based on an existing one) named postgresql.<old_db_version>_<new_db_version>.sql that contains the commands required to transition the old database schema into the new one. Everything should be wrapped into a transaction (i.e. begin and commit) and the version update should be the last things before the transaction commit.

When changing the database version, you also have to change the #define BDB_VERSION in core/src/cats/cats.h so Bareos knows what database version to expect.

@arogge
Copy link
Member

arogge commented Apr 9, 2025

You're right, that is a little awkward but it was necessary to integrate with the existing behaviour because otherwise "purge" and "prune" commands would just fail for a newly created volume which it doesn't currently. I'll think about how one can make this more intuitive.

That's actually a good point. I think it doesn't make much sense to support purge/prune on these volumes, but you're right that it should probably not fail either.
Maybe it makes sense to just ignore volumes (maybe with a message) that are in status Unlabeled for prune/purge operations?

@florian-at-bareos florian-at-bareos force-pushed the dev/fburger/master/fix-media-record branch from 73282af to 270eea4 Compare April 23, 2025 14:09
@florian-at-bareos florian-at-bareos force-pushed the dev/fburger/master/fix-media-record branch from 270eea4 to ced3746 Compare June 2, 2025 09:09
@florian-at-bareos florian-at-bareos requested a review from sebsura June 3, 2025 15:11
Copy link
Contributor

@sebsura sebsura left a comment

Choose a reason for hiding this comment

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

These are some great changes!

Comment on lines 408 to 411
| VolStatus | text | | Status of media: |
| | | | Full, Archive, Append, |
| | | | Unlabeled, Full, Archive, Append, |
| | | Recycle, Read-Only, Disabled, Error, |
| | | Busy |
Copy link
Contributor

Choose a reason for hiding this comment

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

This creates a line that is slightly too long.

| VolStatus        | text      | | Status of media:                      |
|                  |           | | Unlabeled, Full, Archive, Append,     |
|                  |           | | Recycle, Read-Only, Disabled, Error,  |
|                  |           |   Busy                                  |

this might fix it.

Comment on lines +662 to +664
| NewVolStatus | integer | enum: Unlabeled, Full, Archive, Append, |
| | | Recycle, Purged, Read-only, Disabled, Error, |
| | | Busy, Used, Cleaning |
Copy link
Contributor

Choose a reason for hiding this comment

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

The same applies here: i get a scroll bar for the table. You can just split it up like we did above.

@sebsura
Copy link
Contributor

sebsura commented Jun 5, 2025

You should also squash the commits a bit. There are some check sources/undo commits in there.

@florian-at-bareos florian-at-bareos force-pushed the dev/fburger/master/fix-media-record branch 2 times, most recently from efa5bae to 6e6353e Compare June 11, 2025 06:44
@arogge arogge force-pushed the dev/fburger/master/fix-media-record branch 2 times, most recently from a5ab259 to 98d4e31 Compare July 8, 2025 15:09
@arogge
Copy link
Member

arogge commented Jul 8, 2025

@sebsura I squashed some of the commits. Do you want to take another look at this?

this status is the original status when a new volume is created in the
catalog and is changed if the storage daemon (successfully) wrote on the
volume.
If you manually set the volume status of a volume to "Unlabeled", the
sd corrects this status after successfully writing to the volume.
DoLabel returns whether labelling suceeded or not and not whether the
console connection should be killed.
such that the VolStatus is not "Unlabeled" after labeling but "Append".
@arogge arogge force-pushed the dev/fburger/master/fix-media-record branch from 98d4e31 to 0bd41e2 Compare July 29, 2025 13:06
@arogge arogge requested a review from sebsura July 29, 2025 13:59
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

This is a great improvement for that nasty annoyance when your filesystem is full (or something else went wrong).
Looks great and tested OK.

@BareosBot BareosBot merged commit 521f5cc into bareos:master Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This addresses a bug enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Director should not create volume record if storage daemon fails to label the volume

4 participants