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

Create VmBackup earlier in HybridBackupCommand #936

Merged
merged 1 commit into from
May 27, 2024

Conversation

dupondje
Copy link
Member

@dupondje dupondje commented Apr 19, 2024

When creation of a snapshot for the HybridBackup fails, we end up with a null pointer exception.

2024-04-17 10:29:48,296+02 ERROR [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (default task-2) [76e81a20-4d1d-441b-8e6c-90f37889cd66] EVENT_ID: USER_FAILED_CREATE_SNAPSHOT(117), Failed to create Snapshot Auto-generated for Backup VM for VM xxxxx (User: admin@internal-authz). 2024-04-17 10:29:48,298+02 INFO  [org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand] (default task-2) [76e81a20-4d1d-441b-8e6c-90f37889cd66] Change VM '73df70f5-09b0-4f1a-abd8-2d0b4cd5e8b2' backup 'null' phase from 'null' to 'FAILED' 2024-04-17 10:29:48,299+02 ERROR [org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand] (default task-2) [76e81a20-4d1d-441b-8e6c-90f37889cd66] Command 'org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand' failed: null 2024-04-17 10:29:48,299+02 ERROR [org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand] (default task-2) [76e81a20-4d1d-441b-8e6c-90f37889cd66] Exception: java.lang.NullPointerException
	at org.ovirt.engine.core.dal//org.ovirt.engine.core.dao.VmBackupDaoImpl.update(VmBackupDaoImpl.java:90)
	at org.ovirt.engine.core.dal//org.ovirt.engine.core.dao.VmBackupDaoImpl.update(VmBackupDaoImpl.java:22)
	at deployment.engine.ear.bll.jar//org.ovirt.engine.core.bll.storage.backup.StartVmBackupCommand.updateVmBackupPhase(StartVmBackupCommand.java:632)
	at deployment.engine.ear.bll.jar//org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand.executeCommand(HybridBackupCommand.java:118)
	at deployment.engine.ear.bll.jar//org.ovirt.engine.core.bll.CommandBase.executeWithoutTransaction(CommandBase.java:1174)
	at deployment.engine.ear.bll.jar//org.ovirt.engine.core.bll.CommandBase.executeActionInTransactionScope(CommandBase.java:1332)

This happens because VmBackupDaoImpl tries to save the BackupType into the database (entity.getBackupType().getName()), but that value is still null.
The BackupType is only set when calling createVmBackup.

But as we already have all the data except the snapshotId at the start of the HybridBackup, we already call createVmBackup before creating the snapshot and when the snapshot was created, we add it to the VmBackup data.

This avoids the null getBackupType()

Fixes issue # (delete if not relevant)

Changes introduced with this PR

Are you the owner of the code you are sending in, or do you have permission of the owner?

[y]

When creation of a snapshot for the HybridBackup fails, we end up with a
null pointer exception.

2024-04-17 10:29:48,296+02 ERROR [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (default task-2) [76e81a20-4d1d-441b-8e6c-90f37889cd66] EVENT_ID: USER_FAILED_CREATE_SNAPSHOT(117), Failed to create Snapshot Auto-generated for Backup VM for VM xxxxx (User: admin@internal-authz).
2024-04-17 10:29:48,298+02 INFO  [org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand] (default task-2) [76e81a20-4d1d-441b-8e6c-90f37889cd66] Change VM '73df70f5-09b0-4f1a-abd8-2d0b4cd5e8b2' backup 'null' phase from 'null' to 'FAILED'
2024-04-17 10:29:48,299+02 ERROR [org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand] (default task-2) [76e81a20-4d1d-441b-8e6c-90f37889cd66] Command 'org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand' failed: null
2024-04-17 10:29:48,299+02 ERROR [org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand] (default task-2) [76e81a20-4d1d-441b-8e6c-90f37889cd66] Exception: java.lang.NullPointerException
	at org.ovirt.engine.core.dal//org.ovirt.engine.core.dao.VmBackupDaoImpl.update(VmBackupDaoImpl.java:90)
	at org.ovirt.engine.core.dal//org.ovirt.engine.core.dao.VmBackupDaoImpl.update(VmBackupDaoImpl.java:22)
	at deployment.engine.ear.bll.jar//org.ovirt.engine.core.bll.storage.backup.StartVmBackupCommand.updateVmBackupPhase(StartVmBackupCommand.java:632)
	at deployment.engine.ear.bll.jar//org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand.executeCommand(HybridBackupCommand.java:118)
	at deployment.engine.ear.bll.jar//org.ovirt.engine.core.bll.CommandBase.executeWithoutTransaction(CommandBase.java:1174)
	at deployment.engine.ear.bll.jar//org.ovirt.engine.core.bll.CommandBase.executeActionInTransactionScope(CommandBase.java:1332)

This happens because VmBackupDaoImpl tries to save the BackupType into
the database (entity.getBackupType().getName()), but that value is still
null.
The BackupType is only set when calling createVmBackup.

But as we already have all the data except the snapshotId at the start
of the HybridBackup, we already call createVmBackup before creating the
snapshot and when the snapshot was created, we add it to the VmBackup
data.

This avoids the null getBackupType()

Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
@sandrobonazzola
Copy link
Member

@shubhaOracle , @BrooklynDewolf can you please review?

Copy link
Contributor

@BrooklynDewolf BrooklynDewolf left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@sandrobonazzola
Copy link
Member

/OST

@sandrobonazzola sandrobonazzola merged commit ed023e5 into oVirt:master May 27, 2024
3 checks passed
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.

None yet

3 participants