Add back ability to disable backup of snapshot to secondary#3122
Conversation
| if (backupedSnapshot != null) { | ||
| snapshotStrategy.postSnapshotCreation(snapshotOnPrimary); | ||
| if(s_logger.isDebugEnabled()) { | ||
| s_logger.debug("skipping backup of snapshot to secondary due to configuration"); |
There was a problem hiding this comment.
Is it clear from this log message which snapshot we are talking about?
| s_logger.debug("skipping backup of snapshot to secondary due to configuration"); | ||
| } | ||
| if (!snapshotOnPrimary.markBackedUp()) { | ||
| throw new CloudRuntimeException("Can't mark snapshot as backed up!"); |
There was a problem hiding this comment.
Same applies here. Maybe add the snapshot name, volume ID, etc?
| } | ||
|
|
||
| @Override | ||
| public boolean markBackedUp() { |
There was a problem hiding this comment.
Why returning a boolean here?
I mean, you capture a checked exception here, and then you return false. Then, in the method where you use this markBackedUp, you will check if the return is false, and then you throw a runtime exception. Why not capture the checked exception and throw the runtime here?
Also, what about unit test cases?
There was a problem hiding this comment.
Mainly I just couldn't throw a NoTransitionException because it would create a circular dependency. CloudRuntimeException would work though, since as you say that's ultimately what ends up happening in the one place this gets called (for now). I have no problem making this change.
There was a problem hiding this comment.
I am +1 on the @rafaelweingartner idea. Throwing a CloudRuntimeException would be better than the boolean approach.
| SnapshotInfo snapshotOnPrimary = snapshotStrategy.takeSnapshot(snapshot); | ||
| if (payload.getAsyncBackup()) { | ||
| backupSnapshotExecutor.schedule(new BackupSnapshotTask(snapshotOnPrimary, snapshotBackupRetries - 1, snapshotStrategy), 0, TimeUnit.SECONDS); | ||
| boolean backupFlag = BackupSnapshotAfterTakingSnapshot.value() == null || |
There was a problem hiding this comment.
Could you rename this variable to something more descriptive?
| BackupSnapshotAfterTakingSnapshot.value(); | ||
|
|
||
| if (backupFlag) { | ||
| if (payload.getAsyncBackup()) { |
There was a problem hiding this comment.
can you extract lines 1130-1136 to a method? This will also allow you to document it, and then to unit test it.
There was a problem hiding this comment.
This isn't my code, but I'm not entirely sure how to even test things in backupSnapshotExecutor. That is inited by the config() method, and that's not called from the existing unit tests. Any thoughts?
816a356 to
ca27bbc
Compare
|
@wido I hope I've addressed your concerns. @rafaelweingartner see above regarding the unit test suggestion |
SHA: 6bb0ca2 This adds it back, though named snapshot.backup.to.secondary now instead. This global parameter, once set, will allow you to prevent automatic backups of snapshots to secondary storage, unless they're actually needed. Fixes apache#3096
ca27bbc to
4372205
Compare
| processEvent(Event.OperationNotPerformed); | ||
| } catch (NoTransitionException ex) { | ||
| s_logger.error("no transition error: ", ex); | ||
| throw new CloudRuntimeException("Error marking snapshot backed up: " + |
There was a problem hiding this comment.
Can you maintain the history of the stack of the exception that is re-thrown here?
I mean, it is a matter of using throw new CloudRuntimeException(<message>, <exception>)
There was a problem hiding this comment.
@nathanejohnson I see this point as critical. Doing as @rafaelweingartner proposed would allow having the full stack on the log, which helps on debugging.
Could you please address this point? Thanks! Overall LGTM.
| SnapshotInfo snapshotOnPrimary = snapshotStrategy.takeSnapshot(snapshot); | ||
| if (payload.getAsyncBackup()) { | ||
| backupSnapshotExecutor.schedule(new BackupSnapshotTask(snapshotOnPrimary, snapshotBackupRetries - 1, snapshotStrategy), 0, TimeUnit.SECONDS); | ||
| boolean backupSnapToSecondary = BackupSnapshotAfterTakingSnapshot.value() == null || |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| return snapshot; | ||
| } | ||
|
|
||
| protected void backupSnapshotToSecondary(boolean asyncBackup, SnapshotStrategy snapshotStrategy, SnapshotInfo snapshotOnPrimary) { |
There was a problem hiding this comment.
Would you mind documenting this method, and then creating unit test cases for it?
|
@blueorangutan package |
|
@GabrielBrascher a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2554 |
|
@blueorangutan test |
|
@GabrielBrascher a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
This PR is almost good to go, thanks @nathanejohnson! |
|
Trillian test result (tid-3337)
|
Correção no estado da VM ao criar um _backup_ com o host `Down` ou `Disconnected` Closes #3122 See merge request scclouds/scclouds!1314
Description
The snapshot.backup.rightafter configuration variable was removed by:
SHA: 6bb0ca2
This adds it back, though named snapshot.backup.to.secondary now instead.
This global parameter, once set, will allow you to prevent automatic backups of
snapshots to secondary storage, unless they're actually needed.
Fixes #3096
Types of changes
How Has This Been Tested?
tested this in our 4.11 lab environment