Skip to content

Commit

Permalink
monitor svc multi nodePort (#4726)
Browse files Browse the repository at this point in the history
* fix skip payment success status

* Update account_controller.go

* monitor svc multi nodePort
  • Loading branch information
bxy4543 authored May 11, 2024
1 parent f6b1e76 commit 4c3fac7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions controllers/account/controllers/account_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ func (r *AccountReconciler) DeletePayment(ctx context.Context) error {
r.Logger.Error(err, "get payment details failed")
}
if status == pay.PaymentSuccess {
if payment.Status.Status != pay.PaymentSuccess {
continue
}
r.Logger.Info("payment success, post delete payment cr", "payment", payment, "amount", amount)
}
// expire session
Expand Down
8 changes: 6 additions & 2 deletions controllers/resources/controllers/monitor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,20 @@ func (r *MonitorReconciler) monitorResourceUsage(namespace *corev1.Namespace) er
return fmt.Errorf("failed to list svc: %v", err)
}
for _, svc := range svcList.Items {
if svc.Spec.Type != corev1.ServiceTypeNodePort {
if svc.Spec.Type != corev1.ServiceTypeNodePort || len(svc.Spec.Ports) == 0 {
continue
}
port := make(map[int32]struct{})
for i := range svc.Spec.Ports {
port[svc.Spec.Ports[i].NodePort] = struct{}{}
}
svcRes := resources.NewResourceNamed(&svc)
if resUsed[svcRes.String()] == nil {
resNamed[svcRes.String()] = svcRes
resUsed[svcRes.String()] = initResources()
}
// nodeport 1:1000, the measurement is quantity 1000
resUsed[svcRes.String()][corev1.ResourceServicesNodePorts].Add(*resource.NewQuantity(1000, resource.BinarySI))
resUsed[svcRes.String()][corev1.ResourceServicesNodePorts].Add(*resource.NewQuantity(int64(1000*len(port)), resource.BinarySI))
}

var monitors []*resources.Monitor
Expand Down

0 comments on commit 4c3fac7

Please sign in to comment.