Skip to content

Commit 977a375

Browse files
authored
feat dumpinventory deals with quota eceeded (#151)
1 parent d578e0f commit 977a375

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

services/dumpinventory/core.go

+16
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ import (
3535
"github.com/google/uuid"
3636
)
3737

38+
// Quota ExportAssets Requests per minute
39+
const waitSecOnQuotaExceeded = 70
40+
3841
// Global structure for global variables to optimize the cloud function performances
3942
type Global struct {
4043
assetClient *asset.Client
@@ -213,6 +216,19 @@ func EntryPoint(ctxEvent context.Context, PubSubMessage gps.PubSubMessage, globa
213216

214217
operation, err := global.assetClient.ExportAssets(global.ctx, global.request)
215218
if err != nil {
219+
if strings.Contains(strings.ToLower(err.Error()), "quota") {
220+
log.Println(glo.Entry{
221+
MicroserviceName: global.microserviceName,
222+
InstanceName: global.instanceName,
223+
Environment: global.environment,
224+
Severity: "WARNING",
225+
Message: fmt.Sprintf("waiting_on_quota_exceeded"),
226+
Description: fmt.Sprintf("ExportAssets quota is gone, wait for %d seconds then retry", waitSecOnQuotaExceeded),
227+
TriggeringPubsubID: global.PubSubID,
228+
})
229+
time.Sleep(waitSecOnQuotaExceeded * time.Second)
230+
return err
231+
}
216232
log.Println(glo.Entry{
217233
MicroserviceName: global.microserviceName,
218234
InstanceName: global.instanceName,

0 commit comments

Comments
 (0)