CheckReplicaLimit checks if the current replica count exceeds the allowed limit. Returns error if HA is not allowed and there are multiple active replicas. CheckReplicaLimit checks if the deployment exceeds the replica limit. In SaaS mode, replica limits are managed by the operator — skip this check
(ctx context.Context)
| 509 | // CheckReplicaLimit checks if the deployment exceeds the replica limit. |
| 510 | // In SaaS mode, replica limits are managed by the operator — skip this check. |
| 511 | func (s *LicenseService) CheckReplicaLimit(ctx context.Context) error { |
| 512 | if s.saas { |
| 513 | return nil |
| 514 | } |
| 515 | workspaceID, _ := s.store.GetWorkspaceID(ctx) |
| 516 | if s.LoadSubscription(ctx, workspaceID).Ha { |
| 517 | return nil // HA license, no limit |
| 518 | } |
| 519 | |
| 520 | count := s.CountActiveReplicas(ctx) |
| 521 | if count > 1 { |
| 522 | return errors.Errorf( |
| 523 | "multiple replicas detected (%d) but HA is not enabled in license", |
| 524 | count, |
| 525 | ) |
| 526 | } |
| 527 | |
| 528 | return nil |
| 529 | } |
| 530 | |
| 531 | func (s *LicenseService) parseLicense(license, workspaceID string) (*v1pb.Subscription, error) { |
| 532 | claim := &Claims{} |
no test coverage detected