Skip to content

Commit

Permalink
Merge pull request #1992 from slntopp/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
coddmeistr authored Feb 5, 2025
2 parents 5c813bf + 50fa256 commit dce270a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/billing/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ func (s *BillingServiceServer) dailyCronJobAction(ctx context.Context, log *zap.
}
}()
// Jobs
s.DeleteOrphanVPNInstances(ctx, log)
s.InvoiceExpiringInstancesCronJob(ctx, log)
s.NotifyToUpdateOvhPricesCronJob(ctx, log)
s.DeleteExpiredBalanceInvoicesCronJob(ctx, log)
s.WhmcsInvoicesSyncerCronJob(ctx, log)
s.CollectSystemReport(ctx, log)
s.DeleteOrphanVPNInstances(ctx, log)
}

func (s *BillingServiceServer) cronPreflightChecks(ctx context.Context, log *zap.Logger) error {
Expand Down
8 changes: 7 additions & 1 deletion pkg/billing/cron_delete_orphan_vpn_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ func (s *BillingServiceServer) DeleteOrphanVPNInstances(ctx context.Context, log
return
}
for _, p := range _plans {
if p == nil {
continue
}
plans[p.Key] = p
}

for _, obj := range resp.Msg.Pool {
if obj == nil || obj.Instance == nil {
continue
}
inst := obj.Instance
log := log.With(zap.String("instance", inst.GetUuid()))
if inst.BillingPlan == nil || inst.Config == nil {
Expand All @@ -52,7 +58,7 @@ func (s *BillingServiceServer) DeleteOrphanVPNInstances(ctx context.Context, log
continue
}
linkedInstance, err := s.instances.Get(ctx, linked)
if err != nil {
if err != nil || linkedInstance == nil {
log.Error("Failed to get linked vpn instance", zap.Error(err))
continue
}
Expand Down

0 comments on commit dce270a

Please sign in to comment.