MCPcopy Create free account
hub / github.com/bytebase/bytebase / CheckReplicaLimit

Method CheckReplicaLimit

backend/enterprise/license.go:511–529  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

509// CheckReplicaLimit checks if the deployment exceeds the replica limit.
510// In SaaS mode, replica limits are managed by the operator — skip this check.
511func (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
531func (s *LicenseService) parseLicense(license, workspaceID string) (*v1pb.Subscription, error) {
532 claim := &Claims{}

Callers 6

RunMethod · 0.80
RunMethod · 0.80
RunMethod · 0.80
RunMethod · 0.80

Calls 4

LoadSubscriptionMethod · 0.95
CountActiveReplicasMethod · 0.95
ErrorfMethod · 0.80
GetWorkspaceIDMethod · 0.65

Tested by

no test coverage detected