[NET-494 / ACC-322] New free tier limits (#2495)

* Rename var

* Rename consts and use iota

* Use switch instead of repeated else if

* Rename limits related vars

* Introduce new free tier limits

* Measure new limits and report on license validation

* Separate usage and limits, have new ones

* Don't check for hosts and clients limits, but for machines instead

* Error on egress creation @ free tier w/ internet gateways

* Remove clients and hosts limit from code

* Rename var

* Rename consts and use iota

* Use switch instead of repeated else if

* Rename limits related vars

* Introduce new free tier limits

* Measure new limits and report on license validation

* Separate usage and limits, have new ones

* Don't check for hosts and clients limits, but for machines instead

* Error on egress creation @ free tier w/ internet gateways

* Remove clients and hosts limit from code
This commit is contained in:
Gabriel de Souza Seibel
2023-08-08 14:47:49 -03:00
committed by GitHub
parent 449f3f947b
commit 8ce7da2ce9
14 changed files with 185 additions and 104 deletions

View File

@@ -753,26 +753,28 @@ func GetNetworkLimit() int {
return networkslimit
}
// GetClientLimit - fetches free tier limits on ext. clients
func GetClientLimit() int {
var clientsLimit int
if os.Getenv("CLIENTS_LIMIT") != "" {
clientsLimit, _ = strconv.Atoi(os.Getenv("CLIENTS_LIMIT"))
} else {
clientsLimit = config.Config.Server.ClientsLimit
// GetMachinesLimit - fetches free tier limits on machines (clients + hosts)
func GetMachinesLimit() int {
if l, err := strconv.Atoi(os.Getenv("MACHINES_LIMIT")); err == nil {
return l
}
return clientsLimit
return config.Config.Server.MachinesLimit
}
// GetHostLimit - fetches free tier limits on hosts
func GetHostLimit() int {
var hostsLimit int
if os.Getenv("HOSTS_LIMIT") != "" {
hostsLimit, _ = strconv.Atoi(os.Getenv("HOSTS_LIMIT"))
} else {
hostsLimit = config.Config.Server.HostsLimit
// GetIngressLimit - fetches free tier limits on ingresses
func GetIngressLimit() int {
if l, err := strconv.Atoi(os.Getenv("INGRESSES_LIMIT")); err == nil {
return l
}
return hostsLimit
return config.Config.Server.IngressesLimit
}
// GetEgressLimit - fetches free tier limits on egresses
func GetEgressLimit() int {
if l, err := strconv.Atoi(os.Getenv("EGRESSES_LIMIT")); err == nil {
return l
}
return config.Config.Server.EgressesLimit
}
// DeployedByOperator - returns true if the instance is deployed by netmaker operator