Skip to content

grpc: fix missing some early events#2333

Merged
BareosBot merged 18 commits intobareos:masterfrom
sebsura:dev/master/ssura/fix-grpc-early-events
Sep 16, 2025
Merged

grpc: fix missing some early events#2333
BareosBot merged 18 commits intobareos:masterfrom
sebsura:dev/master/ssura/fix-grpc-early-events

Conversation

@sebsura
Copy link
Contributor

@sebsura sebsura commented Jul 25, 2025

Thank you for contributing to the Bareos Project!

The way that the grpc plugin (and the bareos bridge module) works, is that they only know their "child", once a certain step in the backup/restore process was reached.

This means they had no way to send events that were created before that point to the child, as it does not exist at that point.

This lead to the behaviour, where plugins run under grpc never knew that they were supposed to do an incremental backup.

This pr fixes this by caching "early" events, if the child does not exist yet, and then dispatching them at the first possible moment.

This pr also fixes the following:

TODO:

  • fix the other bug mentioned in fix Plugin Names without double quotes #2299, i.e. the actual crash
  • dont register the grpc plugin for every event, only the "early" ones should be enough
  • only send requested events to the plugin (optional, as sending more events should not mess up anything)

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
Tests
  • Decision taken that a test is required (if not, then remove this paragraph)
  • The choice of the type of test (unit test or systemtest) is reasonable
  • Testname matches exactly what is being tested
  • On a fail, output of the test leads quickly to the origin of the fault

@sebsura sebsura force-pushed the dev/master/ssura/fix-grpc-early-events branch 3 times, most recently from 3131a3f to 2e8135b Compare August 21, 2025 06:30
@sebsura sebsura requested a review from pstorz August 21, 2025 06:30
@sebsura sebsura added the bug This addresses a bug label Aug 21, 2025
@sebsura sebsura added this to the 25.0.0 milestone Aug 21, 2025
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

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

See comments.

@sebsura sebsura mentioned this pull request Sep 16, 2025
3 tasks
sebsura and others added 17 commits September 16, 2025 15:35
If you did not quote your plugin names, they were getting parsed as
identifiers, which the function did not accept.  As such we just force
strings during the parsing, which should fix this issue.
nullptr RestoreObjects are sent to every plugin, which will grpc to
try to pass them to its child, even if it does not exist.

Now these events are simply cached, so that the child can take care of
them when it gets initialized.

We should probably just drop these, as they dont really matter and
might just confuse the plugin...
Plugins should only receive events that they registered for.  So we
need to make sure we respect that even for early events.
Make sure to reuse/free the object/name memory.

Also enhance the restoreobject test.  If the restoreobject was messed
up, then python may throw an exception when we try to print
it (i.e. when the object has internal zero bytes)!

This is fixed by just printing everything in hex instead.
Also remove some defaults from the switches and handle sentinel values
separately.  This way its much easier to add new enum options.
Some early events actually have data, so we need to cache those as
well.  This also fixes an issue where we did not report the correct
event size in some cases.

The python code was also fixed: some types were set to the wrong
python type, leading to repeated error messages about truncations.
@sebsura sebsura force-pushed the dev/master/ssura/fix-grpc-early-events branch from d2af535 to 120d227 Compare September 16, 2025 13:36
@BareosBot BareosBot merged commit 593bde8 into bareos:master Sep 16, 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 requires backport to 24

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix Plugin Names without double quotes fix usage of brc_skip in our plugins

3 participants