Remove license tier validation (#428)
This commit is contained in:
parent
23f62cd62a
commit
88506b1adb
|
|
@ -44,40 +44,6 @@ func (controller *Controller) createWorker(ctx *gin.Context) responder.Responder
|
|||
}
|
||||
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 {
|
||||
// In case there already exist a worker with the same name,
|
||||
// update it (to avoid overwriting things like SchedulingPaused)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -39,12 +38,6 @@ var (
|
|||
ErrAdminTaskFailed = errors.New("controller administrative task failed")
|
||||
)
|
||||
|
||||
const (
|
||||
maxWorkersPerDefaultLicense = 4
|
||||
maxWorkersPerGoldLicense = 20
|
||||
maxWorkersPerPlatinumLicense = 200
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
dataDir *DataDir
|
||||
listenAddr string
|
||||
|
|
@ -62,7 +55,6 @@ type Controller struct {
|
|||
ipRendezvous *rendezvous.Rendezvous[rendezvous.ResultWithErrorMessage[string]]
|
||||
enableSwaggerDocs bool
|
||||
workerOfflineTimeout time.Duration
|
||||
maxWorkersPerLicense uint
|
||||
experimentalRPCV2 bool
|
||||
disableDBCompression bool
|
||||
pingInterval time.Duration
|
||||
|
|
@ -83,7 +75,6 @@ func New(opts ...Option) (*Controller, error) {
|
|||
connRendezvous: rendezvous.New[rendezvous.ResultWithErrorMessage[net.Conn]](),
|
||||
ipRendezvous: rendezvous.New[rendezvous.ResultWithErrorMessage[string]](),
|
||||
workerOfflineTimeout: 3 * time.Minute,
|
||||
maxWorkersPerLicense: maxWorkersPerDefaultLicense,
|
||||
pingInterval: 30 * time.Second,
|
||||
single: singleflight.Group{},
|
||||
}
|
||||
|
|
@ -93,20 +84,6 @@ func New(opts ...Option) (*Controller, error) {
|
|||
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
|
||||
if controller.dataDir == nil {
|
||||
return nil, fmt.Errorf("%w: please specify the data directory path with WithDataDir()",
|
||||
|
|
|
|||
Loading…
Reference in New Issue