Skip to content

Commit

Permalink
BackupAccountControl: silence exceptions during CreateAccount
Browse files Browse the repository at this point in the history
We expect that the raidfile or HTTP file doesn't exist during CreateAccount, so
the exception message is unhelpful, so suppress it.
  • Loading branch information
qris committed Jan 8, 2018
1 parent b364244 commit 4308764
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/backupstore/BackupAccountControl.cpp
Expand Up @@ -15,6 +15,7 @@

#include "autogen_BackupStoreException.h"
#include "autogen_CommonException.h"
#include "autogen_RaidFileException.h"
#include "BackupAccountControl.h"
#include "BackupStoreAccounts.h"
#include "BackupStoreCheck.h"
Expand Down Expand Up @@ -495,6 +496,18 @@ int BackupStoreAccountControl::CreateAccount(int32_t DiscNumber, int32_t SoftLim

// Create the BackupStoreInfo and BackupStoreRefCountDatabase files:
mapFileSystem.reset(new RaidBackupFileSystem(mAccountID, mRootDir, mDiscSetNum));

{
// Taking the lock will try to GetAccountIdentifier() (for the log message) which
// will throw a RaidFileException(RaidFileDoesntExist) because the BackupStoreInfo
// file does not exist yet. We expect that! So take the lock early (before calling
// BackupAccountControl::CreateAccount) and silence the exception warning while we
// do so.
HideSpecificExceptionGuard guard(RaidFileException::ExceptionType,
RaidFileException::RaidFileDoesntExist);
mapFileSystem->GetLock();
}

BackupAccountControl::CreateAccount(mAccountID, SoftLimit, HardLimit, "");

BOX_NOTICE("Account " << BOX_FORMAT_ACCOUNT(mAccountID) << " created.");
Expand Down Expand Up @@ -595,6 +608,17 @@ int S3BackupAccountControl::CreateAccount(const std::string& name, int32_t SoftL
}
}

{
// Taking the lock will try to GetAccountIdentifier() (for the log message) which
// will throw a RaidFileException(RaidFileDoesntExist) because the BackupStoreInfo
// file does not exist yet. We expect that! So take the lock early (before calling
// BackupAccountControl::CreateAccount) and silence the exception warning while we
// do so.
HideSpecificExceptionGuard guard(HTTPException::ExceptionType,
HTTPException::FileNotFound);
mapFileSystem->GetLock();
}

// Create the BackupStoreInfo and BackupStoreRefCountDatabase files:
BackupAccountControl::CreateAccount(S3_FAKE_ACCOUNT_ID, SoftLimit, HardLimit, name);

Expand Down

0 comments on commit 4308764

Please sign in to comment.