@@ -489,6 +489,10 @@ func (u *BatchUpdater) backgroundUpdater() {
489
489
for {
490
490
select {
491
491
case <- u .triggerUpdate :
492
+ // If we are using AWS Marketplace, we should only report the usage at the end of the sync
493
+ if u .awsMarketplaceClient != nil {
494
+ continue
495
+ }
492
496
if time .Since (u .lastUpdateTime ) < u .minTimeBetweenFlushes {
493
497
// Not enough time since last update
494
498
continue
@@ -500,12 +504,6 @@ func (u *BatchUpdater) backgroundUpdater() {
500
504
// Not enough rows to update
501
505
continue
502
506
}
503
- // If we are using AWS Marketplace, we need to round down to the nearest 1000
504
- // Only on the last update, will we round up to the nearest 1000
505
- // This will allow us to not overcharge the customer by rounding on each batch
506
- if u .awsMarketplaceClient != nil {
507
- totals = roundDown (totals , 1000 )
508
- }
509
507
510
508
if err := u .updateUsageWithRetryAndBackoff (ctx , totals , tables ); err != nil {
511
509
u .logger .Warn ().Err (err ).Msg ("failed to update usage" )
@@ -514,6 +512,10 @@ func (u *BatchUpdater) backgroundUpdater() {
514
512
u .subtractTableUsage (tables , totals )
515
513
516
514
case <- u .flushDuration .C :
515
+ // If we are using AWS Marketplace, we should only report the usage at the end of the sync
516
+ if u .awsMarketplaceClient != nil {
517
+ continue
518
+ }
517
519
if time .Since (u .lastUpdateTime ) < u .minTimeBetweenFlushes {
518
520
// Not enough time since last update
519
521
continue
@@ -524,12 +526,7 @@ func (u *BatchUpdater) backgroundUpdater() {
524
526
if totals == 0 {
525
527
continue
526
528
}
527
- // If we are using AWS Marketplace, we need to round down to the nearest 1000
528
- // Only on the last update, will we round up to the nearest 1000
529
- // This will allow us to not overcharge the customer by rounding on each batch
530
- if u .awsMarketplaceClient != nil {
531
- totals = roundDown (totals , 1000 )
532
- }
529
+
533
530
if err := u .updateUsageWithRetryAndBackoff (ctx , totals , tables ); err != nil {
534
531
u .logger .Warn ().Err (err ).Msg ("failed to update usage" )
535
532
continue
0 commit comments