diff --git a/cinder/backup/drivers/gcs.py b/cinder/backup/drivers/gcs.py index 65aff80bb93..28746d6ac07 100644 --- a/cinder/backup/drivers/gcs.py +++ b/cinder/backup/drivers/gcs.py @@ -166,7 +166,8 @@ class GoogleBackupDriver(chunkeddriver.ChunkedBackupDriver): creds = service_account.Credentials.from_service_account_file( backup_credential) OAUTH_EXCEPTIONS = (gexceptions.RefreshError, - gexceptions.DefaultCredentialsError) + gexceptions.DefaultCredentialsError, + client.Error) # Can't use google-auth, use deprecated oauth2client else: diff --git a/cinder/tests/unit/backup/drivers/test_backup_google.py b/cinder/tests/unit/backup/drivers/test_backup_google.py index a6beab6f00a..e39369d6719 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_google.py +++ b/cinder/tests/unit/backup/drivers/test_backup_google.py @@ -76,6 +76,11 @@ def gcs_client(func): fake_google_client.FakeGoogleMediaIoBaseDownload) @mock.patch.object(hashlib, 'md5', FakeMD5) def func_wrapper(self, *args, **kwargs): + if google_dr.service_account: + with mock.patch.object(google_dr.service_account.Credentials, + 'from_service_account_file', + fake_google_client.FakeGoogleCredentials): + return func(self, *args, **kwargs) return func(self, *args, **kwargs) return func_wrapper @@ -93,6 +98,11 @@ def gcs_client2(func): FakeObjectName._fake_generate_object_name_prefix) @mock.patch.object(hashlib, 'md5', FakeMD5) def func_wrapper(self, *args, **kwargs): + if google_dr.service_account: + with mock.patch.object(google_dr.service_account.Credentials, + 'from_service_account_file', + fake_google_client.FakeGoogleCredentials): + return func(self, *args, **kwargs) return func(self, *args, **kwargs) return func_wrapper