Remove license tier validation

This commit is contained in:
Fedor Korotkov 2026-04-12 15:13:56 -04:00
parent 23f62cd62a
commit e5427e98b6
2 changed files with 0 additions and 57 deletions

View File

@ -44,40 +44,6 @@ func (controller *Controller) createWorker(ctx *gin.Context) responder.Responder
} }
worker.CreatedAt = currentTime worker.CreatedAt = currentTime
// License capacity check
if err := controller.storeView(func(txn storepkg.Transaction) responder.Responder {
_, err := txn.GetWorker(worker.Name)
if err != nil && !errors.Is(err, storepkg.ErrNotFound) {
controller.logger.Errorf("failed to check if the worker "+
"with name %q exists in the DB: %v", worker.Name, err)
return responder.Code(http.StatusInternalServerError)
}
if err == nil {
// We will be re-creating a worker with
// the same name, no capacity change
return nil
}
// We will be adding a new worker, check if the license capacity allows that
workers, err := txn.ListWorkers()
if err != nil {
controller.logger.Errorf("failed to count the number of workers in the DB: %v", err)
return responder.Code(http.StatusInternalServerError)
}
if !controller.synthetic && uint(len(workers)+1) > controller.maxWorkersPerLicense {
return responder.JSON(http.StatusConflict, NewErrorResponse("cannot register a new worker "+
"because the license capacity of %d workers has been reached, "+
"consider upgrading at https://tart.run/licensing/", controller.maxWorkersPerLicense))
}
return nil
}); err != nil {
return err
}
return controller.storeUpdate(func(txn storepkg.Transaction) responder.Responder { return controller.storeUpdate(func(txn storepkg.Transaction) responder.Responder {
// In case there already exist a worker with the same name, // In case there already exist a worker with the same name,
// update it (to avoid overwriting things like SchedulingPaused) // update it (to avoid overwriting things like SchedulingPaused)

View File

@ -8,7 +8,6 @@ import (
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
"os"
"strings" "strings"
"time" "time"
@ -39,12 +38,6 @@ var (
ErrAdminTaskFailed = errors.New("controller administrative task failed") ErrAdminTaskFailed = errors.New("controller administrative task failed")
) )
const (
maxWorkersPerDefaultLicense = 4
maxWorkersPerGoldLicense = 20
maxWorkersPerPlatinumLicense = 200
)
type Controller struct { type Controller struct {
dataDir *DataDir dataDir *DataDir
listenAddr string listenAddr string
@ -62,7 +55,6 @@ type Controller struct {
ipRendezvous *rendezvous.Rendezvous[rendezvous.ResultWithErrorMessage[string]] ipRendezvous *rendezvous.Rendezvous[rendezvous.ResultWithErrorMessage[string]]
enableSwaggerDocs bool enableSwaggerDocs bool
workerOfflineTimeout time.Duration workerOfflineTimeout time.Duration
maxWorkersPerLicense uint
experimentalRPCV2 bool experimentalRPCV2 bool
disableDBCompression bool disableDBCompression bool
pingInterval time.Duration pingInterval time.Duration
@ -83,7 +75,6 @@ func New(opts ...Option) (*Controller, error) {
connRendezvous: rendezvous.New[rendezvous.ResultWithErrorMessage[net.Conn]](), connRendezvous: rendezvous.New[rendezvous.ResultWithErrorMessage[net.Conn]](),
ipRendezvous: rendezvous.New[rendezvous.ResultWithErrorMessage[string]](), ipRendezvous: rendezvous.New[rendezvous.ResultWithErrorMessage[string]](),
workerOfflineTimeout: 3 * time.Minute, workerOfflineTimeout: 3 * time.Minute,
maxWorkersPerLicense: maxWorkersPerDefaultLicense,
pingInterval: 30 * time.Second, pingInterval: 30 * time.Second,
single: singleflight.Group{}, single: singleflight.Group{},
} }
@ -93,20 +84,6 @@ func New(opts ...Option) (*Controller, error) {
opt(controller) opt(controller)
} }
// Apply environment variables
orchardLicenseTier, ok := os.LookupEnv("ORCHARD_LICENSE_TIER")
if ok {
switch orchardLicenseTier {
case "gold":
controller.maxWorkersPerLicense = maxWorkersPerGoldLicense
case "platinum":
controller.maxWorkersPerLicense = maxWorkersPerPlatinumLicense
default:
return nil, fmt.Errorf("%w: invalid ORCHARD_LICENSE_TIER value: %q",
ErrInitFailed, orchardLicenseTier)
}
}
// Apply defaults // Apply defaults
if controller.dataDir == nil { if controller.dataDir == nil {
return nil, fmt.Errorf("%w: please specify the data directory path with WithDataDir()", return nil, fmt.Errorf("%w: please specify the data directory path with WithDataDir()",