Follow up on issue #7444 and make the parent checks more robust.
We can end up with an incoherent storage when, for instance, a
build has been killed.
Backport of commit a6f8586 and commit 238abf6. Squashed for easier
tracking and referencing.
Fixes: #7444
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1876576
Signed-off-by: Brent Baude <bbaude@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>