Documentation
¶
Index ¶
- Variables
- func BuildAPIRateInfo(rateName limesrates.RateName, rateInfo liquid.RateInfo) limesrates.RateInfo
- func ConvertUnitFor(cluster *Cluster, serviceType db.ServiceType, resourceName liquid.ResourceName, ...) (uint64, error)
- type AZAwareData
- type AZResourceLocation
- type AutogrowQuotaDistributionConfiguration
- type CapacitorConfiguration
- type CapacityData
- type CapacityPlugin
- type CapacityPluginBackchannel
- type Cluster
- func (c *Cluster) BehaviorForRate(serviceType db.ServiceType, rateName liquid.RateName) RateBehavior
- func (c *Cluster) BehaviorForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) ResourceBehavior
- func (c *Cluster) Connect(ctx context.Context, provider *gophercloud.ProviderClient, ...) (errs errext.ErrorSet)
- func (c *Cluster) HasResource(serviceType db.ServiceType, resourceName liquid.ResourceName) bool
- func (c *Cluster) HasService(serviceType db.ServiceType) bool
- func (c *Cluster) HasUsageForRate(serviceType db.ServiceType, rateName liquid.RateName) bool
- func (c *Cluster) InfoForRate(serviceType db.ServiceType, rateName liquid.RateName) liquid.RateInfo
- func (c *Cluster) InfoForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) liquid.ResourceInfo
- func (c *Cluster) InfoForService(serviceType db.ServiceType) ServiceInfo
- func (c *Cluster) QuotaDistributionConfigForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) QuotaDistributionConfiguration
- func (c *Cluster) ServiceTypesInAlphabeticalOrder() []db.ServiceType
- type ClusterConfiguration
- type CommitmentConversion
- type CommitmentGroupNotification
- type CommitmentNotification
- type DiscoveryConfiguration
- type DiscoveryPlugin
- type KeystoneDomain
- type KeystoneProject
- type MailConfiguration
- type MailTemplate
- type MailTemplateConfiguration
- type PerAZ
- type QuotaDistributionConfiguration
- type QuotaPlugin
- type RateBehavior
- type RateLimitConfiguration
- type RateNameMapping
- type RateRef
- type RefInService
- type ResourceBehavior
- func (b ResourceBehavior) BuildAPIResourceInfo(resName limesresources.ResourceName, resInfo liquid.ResourceInfo) limesresources.ResourceInfo
- func (b *ResourceBehavior) Merge(other ResourceBehavior, fullResourceName string)
- func (b ResourceBehavior) ToCommitmentConfig(now time.Time) *limesresources.CommitmentConfiguration
- func (b *ResourceBehavior) Validate(path string) (errs errext.ErrorSet)
- type ResourceData
- type ResourceNameMapping
- func (nm ResourceNameMapping) MapFromV1API(serviceType limes.ServiceType, resourceName limesresources.ResourceName) (db.ServiceType, liquid.ResourceName, bool)
- func (nm ResourceNameMapping) MapToV1API(serviceType db.ServiceType, resourceName liquid.ResourceName) (limes.ServiceType, limesresources.ResourceName, bool)
- type ResourceRef
- type ServiceConfiguration
- type ServiceInfo
- type ServiceRateLimitConfiguration
- type TranslationRule
- type UsageData
Constants ¶
This section is empty.
Variables ¶
var ( // DiscoveryPluginRegistry is a pluggable.Registry for DiscoveryPlugin implementations. DiscoveryPluginRegistry pluggable.Registry[DiscoveryPlugin] // QuotaPluginRegistry is a pluggable.Registry for QuotaPlugin implementations. QuotaPluginRegistry pluggable.Registry[QuotaPlugin] // CapacityPluginRegistry is a pluggable.Registry for CapacityPlugin implementations. CapacityPluginRegistry pluggable.Registry[CapacityPlugin] )
var ErrNotALiquid = errors.New("this plugin is not a liquid")
ErrNotALiquid is a custom eror that is thrown by plugins that do not support the LIQUID API
Functions ¶
func BuildAPIRateInfo ¶
func BuildAPIRateInfo(rateName limesrates.RateName, rateInfo liquid.RateInfo) limesrates.RateInfo
BuildAPIRateInfo converts a RateInfo from LIQUID into the API format.
func ConvertUnitFor ¶
func ConvertUnitFor(cluster *Cluster, serviceType db.ServiceType, resourceName liquid.ResourceName, v limes.ValueWithUnit) (uint64, error)
ConvertUnitFor works like ConvertTo, but instead of taking a unit as an argument, it uses the native unit of the specified resource. In contrast to ConvertTo(), this also handles UnitUnspecified. Values with unspecified unit will be interpreted as being in the native unit, and will not be converted.
Types ¶
type AZAwareData ¶
type AZAwareData[Self any] interface { // List of permitted types. This is required for type inference, as explained here: // <https://stackoverflow.com/a/73851453> UsageData | CapacityData // contains filtered or unexported methods }
AZAwareData is an interface for types that can be put into the PerAZ container.
type AZResourceLocation ¶
type AZResourceLocation struct { ServiceType db.ServiceType ResourceName liquid.ResourceName AvailabilityZone limes.AvailabilityZone }
AZResourceLocation is a tuple identifying an AZ resource within a project.
type AutogrowQuotaDistributionConfiguration ¶
type AutogrowQuotaDistributionConfiguration struct { AllowQuotaOvercommitUntilAllocatedPercent float64 `yaml:"allow_quota_overcommit_until_allocated_percent"` ProjectBaseQuota uint64 `yaml:"project_base_quota"` GrowthMultiplier float64 `yaml:"growth_multiplier"` GrowthMinimum uint64 `yaml:"growth_minimum"` UsageDataRetentionPeriod util.MarshalableTimeDuration `yaml:"usage_data_retention_period"` }
AutogrowQuotaDistributionConfiguration appears in type QuotaDistributionConfiguration.
type CapacitorConfiguration ¶
type CapacitorConfiguration struct { ID string `yaml:"id"` PluginType string `yaml:"type"` Parameters util.YamlRawMessage `yaml:"params"` }
CapacitorConfiguration describes a capacity plugin that is enabled for a certain cluster.
type CapacityData ¶
type CapacityData struct { //NOTE: The json tags are only relevant for the output of `limes test-scan-capacity`. Capacity uint64 `json:"capacity"` Usage *uint64 `json:"usage,omitempty"` //NOTE: currently only relevant on AZ level, regional level uses the aggregation of project usages Subcapacities []any `json:"subcapacities,omitempty"` // only if supported by plugin and enabled in config }
CapacityData contains capacity data for a single project resource.
type CapacityPlugin ¶
type CapacityPlugin interface { pluggable.Plugin // Init is called before any other interface methods, and allows the plugin to // perform first-time initialization. If the plugin needs to access OpenStack // APIs, it needs to spawn the respective ServiceClients in this method and // retain them. // // Before Init is called, the `capacitors[].params` provided in the config // file will be yaml.Unmarshal()ed into the plugin object itself. Init(ctx context.Context, client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) error // Scrape queries the backend service(s) for the capacities of the resources // that this plugin is concerned with. The result is a two-dimensional map, // with the first key being the service type, and the second key being the // resource name. The capacity collector will ignore service types for which // there is no QuotaPlugin, and resources which are not advertised by that // QuotaPlugin. // // The serializedMetrics return value is persisted in the Limes DB and // supplied to all subsequent RenderMetrics calls. Scrape(ctx context.Context, backchannel CapacityPluginBackchannel, allAZs []limes.AvailabilityZone) (result map[db.ServiceType]map[liquid.ResourceName]PerAZ[CapacityData], serializedMetrics []byte, err error) // BuildServiceCapacityRequest generates the request body payload for querying // the LIQUID API endpoint /v1/report-capacity BuildServiceCapacityRequest(backchannel CapacityPluginBackchannel, allAZs []limes.AvailabilityZone) (liquid.ServiceCapacityRequest, error) // DescribeMetrics is called when Prometheus is scraping metrics from // limes-collect, to provide an opportunity to the plugin to emit its own // metrics. // // Together with CollectMetrics, this interface is roughly analogous to the // prometheus.Collector interface; cf. documentation over there. DescribeMetrics(ch chan<- *prometheus.Desc) // CollectMetrics is called when Prometheus is scraping metrics from // limes-collect, to provide an opportunity to the plugin to emit its own // metrics. The serializedMetrics argument contains the respective value // returned from the last Scrape call on the same project. // // Some plugins also emit metrics directly within Scrape. This newer interface // should be preferred since metrics emitted here won't be lost between // restarts of limes-collect. CollectMetrics(ch chan<- prometheus.Metric, serializedMetrics []byte, capacitorID string) error }
CapacityPlugin is the interface that all capacity collector plugins must implement.
While there can only be one QuotaPlugin for each backend service, there may be different CapacityPlugin instances for each backend service, and a single CapacityPlugin can even report capacities for multiple service types. The reason is that quotas are handled in the concrete backend service, thus their handling is independent from the underlying infrastructure. Capacity calculations, however, may be highly dependent on the infrastructure. For example, for the Compute service, there could be different capacity plugins for each type of hypervisor (KVM, VMware, etc.) which use the concrete APIs of these hypervisors instead of the OpenStack Compute API.
type CapacityPluginBackchannel ¶
type CapacityPluginBackchannel interface {
GetResourceDemand(serviceType db.ServiceType, resourceName liquid.ResourceName) (liquid.ResourceDemand, error)
}
CapacityPluginBackchannel is a callback interface that is provided to CapacityPlugin.Scrape(). Most capacity scrape implementations will not need this, but some esoteric usecases use this information to distribute available capacity among resources in accordance with customer demand.
Note that ResourceDemand is measured against effective capacity, which differs from the raw capacity seen by the CapacityPlugin by this OvercommitFactor.
type Cluster ¶
type Cluster struct { Config ClusterConfiguration DiscoveryPlugin DiscoveryPlugin QuotaPlugins map[db.ServiceType]QuotaPlugin CapacityPlugins map[string]CapacityPlugin }
Cluster contains all configuration and runtime information for the target cluster.
func NewCluster ¶
func NewCluster(config ClusterConfiguration) (c *Cluster, errs errext.ErrorSet)
NewCluster creates a new Cluster instance with the given ID and configuration, and also initializes all quota and capacity plugins. Errors will be logged when some of the requested plugins cannot be found.
func NewClusterFromYAML ¶
NewClusterFromYAML reads and validates the configuration in the given YAML document. Errors are logged and will result in program termination, causing the function to not return.
func (*Cluster) BehaviorForRate ¶
func (c *Cluster) BehaviorForRate(serviceType db.ServiceType, rateName liquid.RateName) RateBehavior
BehaviorForRate returns the RateBehavior for the given rate in the given scope.
func (*Cluster) BehaviorForResource ¶
func (c *Cluster) BehaviorForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) ResourceBehavior
BehaviorForResource returns the ResourceBehavior for the given resource in the given scope.
func (*Cluster) Connect ¶
func (c *Cluster) Connect(ctx context.Context, provider *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (errs errext.ErrorSet)
Connect calls Init() on all plugins.
It also loads the QuotaOverrides for this cluster, if configured. We also validate if Config.ResourceBehavior[].ScalesWith refers to existing resources.
We cannot do any of this earlier because we only know all resources after calling Init() on all quota plugins.
func (*Cluster) HasResource ¶
func (c *Cluster) HasResource(serviceType db.ServiceType, resourceName liquid.ResourceName) bool
HasResource checks whether the given service is enabled in this cluster and whether it advertises the given resource.
func (*Cluster) HasService ¶
func (c *Cluster) HasService(serviceType db.ServiceType) bool
HasService checks whether the given service is enabled in this cluster.
func (*Cluster) HasUsageForRate ¶
HasUsageForRate checks whether the given service is enabled in this cluster and whether it scrapes usage for the given rate.
func (*Cluster) InfoForRate ¶
InfoForRate finds the plugin for the given serviceType and finds within that plugin the RateInfo for the given rateName. If the service or rate does not exist, an empty RateInfo (with .Unit == UnitNone) is returned. Note that this only returns non-empty RateInfos for rates where a usage is reported. There may be rates that only have a limit, as defined in the ClusterConfiguration.
func (*Cluster) InfoForResource ¶
func (c *Cluster) InfoForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) liquid.ResourceInfo
InfoForResource finds the plugin for the given serviceType and finds within that plugin the ResourceInfo for the given resourceName. If the service or resource does not exist, an empty ResourceInfo (with .Unit == UnitNone and .Category == "") is returned.
func (*Cluster) InfoForService ¶
func (c *Cluster) InfoForService(serviceType db.ServiceType) ServiceInfo
InfoForService finds the plugin for the given serviceType and returns its ServiceInfo(), or an empty ServiceInfo (with .Area == "") when no such service exists in this cluster.
func (*Cluster) QuotaDistributionConfigForResource ¶
func (c *Cluster) QuotaDistributionConfigForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) QuotaDistributionConfiguration
QuotaDistributionConfigForResource returns the QuotaDistributionConfiguration for the given resource.
func (*Cluster) ServiceTypesInAlphabeticalOrder ¶
func (c *Cluster) ServiceTypesInAlphabeticalOrder() []db.ServiceType
ServiceTypesInAlphabeticalOrder can be used when service types need to be iterated over in a stable order (mostly to ensure deterministic behavior in unit tests).
type ClusterConfiguration ¶
type ClusterConfiguration struct { AvailabilityZones []limes.AvailabilityZone `yaml:"availability_zones"` CatalogURL string `yaml:"catalog_url"` Discovery DiscoveryConfiguration `yaml:"discovery"` Services []ServiceConfiguration `yaml:"services"` Capacitors []CapacitorConfiguration `yaml:"capacitors"` // ^ Sorry for the stupid pun. Not. ResourceBehaviors []ResourceBehavior `yaml:"resource_behavior"` RateBehaviors []RateBehavior `yaml:"rate_behavior"` QuotaDistributionConfigs []*QuotaDistributionConfiguration `yaml:"quota_distribution_configs"` MailNotifications Option[*MailConfiguration] `yaml:"mail_notifications"` }
ClusterConfiguration contains all the configuration data for a single cluster. It is instantiated from YAML and then transformed into type Cluster during the startup phase.
func (*ClusterConfiguration) GetServiceConfigurationForType ¶
func (cluster *ClusterConfiguration) GetServiceConfigurationForType(serviceType db.ServiceType) (ServiceConfiguration, bool)
GetServiceConfigurationForType returns the ServiceConfiguration or false.
type CommitmentConversion ¶
type CommitmentGroupNotification ¶
type CommitmentGroupNotification struct { DomainName string ProjectName string Commitments []CommitmentNotification }
CommitmentGroupNotification contains data for rendering mails notifying about commitment workflows (confirmation or expiration).
type CommitmentNotification ¶
type CommitmentNotification struct { Commitment db.ProjectCommitment DateString string Resource AZResourceLocation }
CommitmentNotification appears in type CommitmentGroupNotification.
type DiscoveryConfiguration ¶
type DiscoveryConfiguration struct { Method string `yaml:"method"` ExcludeDomainRx regexpext.PlainRegexp `yaml:"except_domains"` IncludeDomainRx regexpext.PlainRegexp `yaml:"only_domains"` Parameters util.YamlRawMessage `yaml:"params"` }
DiscoveryConfiguration describes the method of discovering Keystone domains and projects.
func (DiscoveryConfiguration) FilterDomains ¶
func (c DiscoveryConfiguration) FilterDomains(domains []KeystoneDomain) []KeystoneDomain
FilterDomains applies the configured ExcludeDomainRx and IncludeDomainRx to the given list of domains.
type DiscoveryPlugin ¶
type DiscoveryPlugin interface { pluggable.Plugin // Init is called before any other interface methods, and allows the plugin to // perform first-time initialization. If the plugin needs to access OpenStack // APIs, it needs to spawn the respective ServiceClients in this method and // retain them. // // Before Init is called, the `discovery.params` provided in the configuration // file will be yaml.Unmarshal()ed into the plugin object itself. Init(ctx context.Context, client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) error // ListDomains returns all Keystone domains in the cluster. ListDomains(ctx context.Context) ([]KeystoneDomain, error) // ListProjects returns all Keystone projects in the given domain. ListProjects(ctx context.Context, domain KeystoneDomain) ([]KeystoneProject, error) }
DiscoveryPlugin is the interface that the collector uses to discover Keystone projects and domains in a cluster.
type KeystoneDomain ¶
type KeystoneDomain struct { UUID string `json:"id" yaml:"id"` Name string `json:"name" yaml:"name"` }
KeystoneDomain describes the basic attributes of a Keystone domain.
func KeystoneDomainFromDB ¶
func KeystoneDomainFromDB(dbDomain db.Domain) KeystoneDomain
KeystoneDomainFromDB converts a db.Domain into a KeystoneDomain.
type KeystoneProject ¶
type KeystoneProject struct { UUID string `json:"id" yaml:"id"` Name string `json:"name" yaml:"name"` ParentUUID string `json:"parent_id,omitempty" yaml:"parent_id,omitempty"` Domain KeystoneDomain `json:"domain" yaml:"domain"` }
KeystoneProject describes the basic attributes of a Keystone project.
func KeystoneProjectFromDB ¶
func KeystoneProjectFromDB(dbProject db.Project, domain KeystoneDomain) KeystoneProject
KeystoneProjectFromDB converts a db.Project into a KeystoneProject.
func (KeystoneProject) ForLiquid ¶
func (p KeystoneProject) ForLiquid() *liquid.ProjectMetadata
ForLiquid casts this KeystoneProject into the format used in LIQUID requests.
type MailConfiguration ¶
type MailConfiguration struct { Endpoint string `yaml:"endpoint"` Templates MailTemplateConfiguration `yaml:"templates"` }
MailConfiguration appears in type Configuration.
type MailTemplate ¶
type MailTemplate struct { Subject string `yaml:"subject"` Body string `yaml:"body"` Compiled *template.Template `yaml:"-"` // filled during Config.Validate() }
MailTemplate is a template for notification mails generated by Limes. It appears in type MailTemplateConfiguration.
func (*MailTemplate) Compile ¶
func (t *MailTemplate) Compile() (err error)
Compile compiles the provided mail body template. This needs to be run once before any call to Render().
func (MailTemplate) Render ¶
func (t MailTemplate) Render(m CommitmentGroupNotification, projectID db.ProjectID, now time.Time) (db.MailNotification, error)
Render generates a mail notification for a completed commitment workflow.
type MailTemplateConfiguration ¶
type MailTemplateConfiguration struct { ConfirmedCommitments MailTemplate `yaml:"confirmed_commitments"` ExpiringCommitments MailTemplate `yaml:"expiring_commitments"` }
MailTemplateConfiguration appears in type Configuration. It contains the mail template for each notification case. The templates will be filled with the details collected from the limes collect job.
type PerAZ ¶
type PerAZ[D AZAwareData[D]] map[limes.AvailabilityZone]*D
PerAZ is a container for data that can be reported for each AZ.
func InAnyAZ ¶
func InAnyAZ[D AZAwareData[D]](data D) PerAZ[D]
InAnyAZ is a convenience constructor for PerAZ that puts all data in the "any" AZ. Use this for data relating to resources that are not AZ-aware.
func InUnknownAZUnlessEmpty ¶
func InUnknownAZUnlessEmpty[D AZAwareData[D]](data D) PerAZ[D]
InUnknownAZUnlessEmpty is a convenience constructor for PerAZ that puts all data in the "unknown" AZ. Use this for data relating to AZ-aware resources where the AZ association is unknown.
If the provided data is empty, an empty map is returned instead. (We usually only report "unknown" if there is actually something to report.)
func (PerAZ[D]) AndZeroInTheseAZs ¶
func (p PerAZ[D]) AndZeroInTheseAZs(availabilityZones []limes.AvailabilityZone) PerAZ[D]
AndZeroInTheseAZs adds zero-valued entries for each of the given AZs, then returns the same map.
This is used for AZ-aware usage reporting when the main API is not AZ-aware. The initial UsageData is constructed as `InUnknownAZ(totalUsage).AndZeroInTheseAZs(knownAZs)`. Then as we iterate through AZ-localized objects, their respective usage is moved from AZ `any` to their specific AZ using AddLocalizedUsage().
func (PerAZ[D]) Keys ¶
func (p PerAZ[D]) Keys() []limes.AvailabilityZone
Keys returns all availability zones that have entries in this map.
type QuotaDistributionConfiguration ¶
type QuotaDistributionConfiguration struct { FullResourceNameRx regexpext.BoundedRegexp `yaml:"resource"` Model limesresources.QuotaDistributionModel `yaml:"model"` // options for AutogrowQuotaDistribution Autogrow *AutogrowQuotaDistributionConfiguration `yaml:"autogrow"` }
QuotaDistributionConfiguration contains configuration options for specifying the QuotaDistributionModel of specific resources.
type QuotaPlugin ¶
type QuotaPlugin interface { pluggable.Plugin // Init is called before any other interface methods, and allows the plugin to // perform first-time initialization. If the plugin needs to access OpenStack // APIs, it needs to spawn the respective ServiceClients in this method and // retain them. // // Implementations can use it f.i. to discover the available Resources(). For // plugins that support subresource scraping, the final argument indicates // which resources to scrape (the keys are resource names). // // Before Init is called, the `services[].params` provided in the config // file will be yaml.Unmarshal()ed into the plugin object itself. Init(ctx context.Context, client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts, serviceType db.ServiceType) error // ServiceInfo returns metadata for this service. ServiceInfo() ServiceInfo // Resources returns metadata for all the resources that this plugin scrapes // from the backend service. Resources() map[liquid.ResourceName]liquid.ResourceInfo // Scrape queries the backend service for the quota and usage data of all // known resources for the given project in the given domain. The string keys // in the result map must be identical to the resource names // from Resources(). // // The `allAZs` list comes from the Limes config and should be used when // building AZ-aware usage data, to ensure that each AZ-aware resource reports // usage in all available AZs, even when the project in question does not have // usage in every AZ. // // The `serializedMetrics` return value is persisted in the Limes DB and // supplied to all subsequent RenderMetrics calls. Scrape(ctx context.Context, project KeystoneProject, allAZs []limes.AvailabilityZone) (result map[liquid.ResourceName]ResourceData, serializedMetrics []byte, err error) // BuildServiceUsageRequest generates the request body payload for querying // the LIQUID API endpoint /v1/projects/:uuid/report-usage BuildServiceUsageRequest(project KeystoneProject, allAZs []limes.AvailabilityZone) (liquid.ServiceUsageRequest, error) // SetQuota updates the backend service's quotas for the given project in the // given domain to the values specified here. The map is guaranteed to contain // values for all resources defined by Resources(). SetQuota(ctx context.Context, project KeystoneProject, quotaReq map[liquid.ResourceName]liquid.ResourceQuotaRequest) error // Rates returns metadata for all the rates that this plugin scrapes // from the backend service. Rates() map[liquid.RateName]liquid.RateInfo // ScrapeRates queries the backend service for the usage data of all the rates // enumerated by Rates() for the given project in the given domain. The string // keys in the result map must be identical to the rate names from Rates(). // // The `allAZs` list comes from the Limes config and should be used when // building AZ-aware usage data, to ensure that each AZ-aware resource reports // usage in all available AZs, even when the project in question does not have // usage in every AZ. // // The serializedState return value is persisted in the Limes DB and returned // back to the next ScrapeRates() call for the same project in the // prevSerializedState argument. Besides that, this field is not interpreted // by the core application in any way. The plugin implementation can use this // field to carry state between ScrapeRates() calls, esp. to detect and handle // counter resets in the backend. ScrapeRates(ctx context.Context, project KeystoneProject, allAZs []limes.AvailabilityZone, prevSerializedState string) (result map[liquid.RateName]*big.Int, serializedState string, err error) // DescribeMetrics is called when Prometheus is scraping metrics from // limes-collect, to provide an opportunity to the plugin to emit its own // metrics. // // Together with CollectMetrics, this interface is roughly analogous to the // prometheus.Collector interface; cf. documentation over there. DescribeMetrics(ch chan<- *prometheus.Desc) // CollectMetrics is called when Prometheus is scraping metrics from // limes-collect, to provide an opportunity to the plugin to emit its own // metrics. The serializedMetrics argument contains the respective value // returned from the last Scrape call on the same project. // // Some plugins also emit metrics directly within Scrape. This newer interface // should be preferred since metrics emitted here won't be lost between // restarts of limes-collect. CollectMetrics(ch chan<- prometheus.Metric, project KeystoneProject, serializedMetrics []byte) error }
QuotaPlugin is the interface that the quota/usage collector plugins for all backend services must implement. There can only be one QuotaPlugin for each backend service.
type RateBehavior ¶
type RateBehavior struct { FullRateNameRx regexpext.BoundedRegexp `yaml:"rate"` IdentityInV1API RateRef `yaml:"identity_in_v1_api"` }
RateBehavior contains the configuration options for specialized behavior of a single rate (or a set thereof).
func (*RateBehavior) Merge ¶
func (b *RateBehavior) Merge(other RateBehavior, fullRateName string)
Merge computes the union of both given resource behaviors.
func (*RateBehavior) Validate ¶
func (b *RateBehavior) Validate(path string) (errs errext.ErrorSet)
Validate returns a list of all errors in this behavior configuration.
The `path` argument denotes the location of this behavior in the configuration file, and will be used when generating error messages.
type RateLimitConfiguration ¶
type RateLimitConfiguration struct { Name liquid.RateName `yaml:"name"` Unit limes.Unit `yaml:"unit"` Limit uint64 `yaml:"limit"` Window limesrates.Window `yaml:"window"` }
RateLimitConfiguration describes a rate limit configuration.
type RateNameMapping ¶
type RateNameMapping struct {
// contains filtered or unexported fields
}
RateNameMapping is like ResourceNameMapping, but for rates instead.
func BuildRateNameMapping ¶
func BuildRateNameMapping(cluster *Cluster) RateNameMapping
BuildRateNameMapping constructs a new RateNameMapping instance.
func (RateNameMapping) MapFromV1API ¶
func (nm RateNameMapping) MapFromV1API(serviceType limes.ServiceType, rateName limesrates.RateName) (db.ServiceType, liquid.RateName, bool)
MapFromV1API maps API-level identifiers for a rate into DB-level identifiers.
func (RateNameMapping) MapToV1API ¶
func (nm RateNameMapping) MapToV1API(serviceType db.ServiceType, rateName liquid.RateName) (limes.ServiceType, limesrates.RateName, bool)
MapToV1API maps API-level identifiers for a rate into DB-level identifiers.
type RateRef ¶
type RateRef = RefInService[limes.ServiceType, limesrates.RateName]
RateRef is an instance of RefInService. It appears in type RateBehavior.
type RefInService ¶
type RefInService[S, R ~string] struct { ServiceType S Name R }
RefInService contains a pair of service type and resource or rate name. When read from the configuration YAML, this deserializes from a string in the "service/resource" or "service/rate" format.
func (*RefInService[S, R]) UnmarshalYAML ¶
func (r *RefInService[S, R]) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface.
type ResourceBehavior ¶
type ResourceBehavior struct { FullResourceNameRx regexpext.BoundedRegexp `yaml:"resource"` OvercommitFactor liquid.OvercommitFactor `yaml:"overcommit_factor"` CommitmentDurations []limesresources.CommitmentDuration `yaml:"commitment_durations"` CommitmentMinConfirmDate *time.Time `yaml:"commitment_min_confirm_date"` CommitmentUntilPercent *float64 `yaml:"commitment_until_percent"` CommitmentConversion CommitmentConversion `yaml:"commitment_conversion"` IdentityInV1API ResourceRef `yaml:"identity_in_v1_api"` TranslationRuleInV1API TranslationRule `yaml:"translation_rule_in_v1_api"` Category string `yaml:"category"` }
ResourceBehavior contains the configuration options for specialized behaviors of a single resource (or a set thereof).
func (ResourceBehavior) BuildAPIResourceInfo ¶
func (b ResourceBehavior) BuildAPIResourceInfo(resName limesresources.ResourceName, resInfo liquid.ResourceInfo) limesresources.ResourceInfo
BuildAPIResourceInfo converts a ResourceInfo from LIQUID into the API format, using the category mapping in this behavior object.
func (*ResourceBehavior) Merge ¶
func (b *ResourceBehavior) Merge(other ResourceBehavior, fullResourceName string)
Merge computes the union of both given resource behaviors.
func (ResourceBehavior) ToCommitmentConfig ¶
func (b ResourceBehavior) ToCommitmentConfig(now time.Time) *limesresources.CommitmentConfiguration
ToCommitmentConfig returns the CommitmentConfiguration for this resource, or nil if commitments are not allowed on this resource.
func (*ResourceBehavior) Validate ¶
func (b *ResourceBehavior) Validate(path string) (errs errext.ErrorSet)
Validate returns a list of all errors in this behavior configuration.
The `path` argument denotes the location of this behavior in the configuration file, and will be used when generating error messages.
type ResourceData ¶
type ResourceData struct { Quota int64 // negative values indicate infinite quota MinQuota *uint64 // if set, indicates that SetQuota will reject values below this level MaxQuota *uint64 // if set, indicates that SetQuota will reject values above this level UsageData PerAZ[UsageData] }
ResourceData contains quota and usage data for a single project resource.
func (ResourceData) AddLocalizedUsage ¶
func (r ResourceData) AddLocalizedUsage(az limes.AvailabilityZone, usage uint64)
AddLocalizedUsage subtracts the given `usage from the `unknown` AZ (if any) and adds it to the given AZ instead.
This is used when breaking down a usage total reported by a non-AZ-aware API by iterating over AZ-localized objects. If the sum of usage of the AZ-localized objects matches the reported usage total, the entry for the "unknown" AZ will be removed entirely once it reaches zero usage.
func (ResourceData) UsageInAZ ¶
func (r ResourceData) UsageInAZ(az limes.AvailabilityZone) *UsageData
UsageInAZ is like `r.UsageData[az]`, but inserts a new zero-valued UsageData on first access. This is useful when calculating AZ-aware usage by iterating through a list of AZ-localized objects.
type ResourceNameMapping ¶
type ResourceNameMapping struct {
// contains filtered or unexported fields
}
ResourceNameMapping contains an efficient pre-computed mapping between API-level and DB-level service and resource identifiers.
func BuildResourceNameMapping ¶
func BuildResourceNameMapping(cluster *Cluster) ResourceNameMapping
BuildResourceNameMapping constructs a new ResourceNameMapping instance.
func (ResourceNameMapping) MapFromV1API ¶
func (nm ResourceNameMapping) MapFromV1API(serviceType limes.ServiceType, resourceName limesresources.ResourceName) (db.ServiceType, liquid.ResourceName, bool)
MapFromV1API maps API-level identifiers for a resource into DB-level identifiers. False is returned if the given resource does not exist.
func (ResourceNameMapping) MapToV1API ¶
func (nm ResourceNameMapping) MapToV1API(serviceType db.ServiceType, resourceName liquid.ResourceName) (limes.ServiceType, limesresources.ResourceName, bool)
MapToV1API maps DB-level identifiers for a resource into API-level identifiers. False is returned if the given resource does not exist.
type ResourceRef ¶
type ResourceRef = RefInService[limes.ServiceType, limesresources.ResourceName]
ResourceRef is an instance of RefInService. It appears in type ResourceBehavior.
type ServiceConfiguration ¶
type ServiceConfiguration struct { ServiceType db.ServiceType `yaml:"service_type"` PluginType string `yaml:"type"` // RateLimits describes the global rate limits (all requests for to a backend) and default project level rate limits. RateLimits ServiceRateLimitConfiguration `yaml:"rate_limits"` Parameters util.YamlRawMessage `yaml:"params"` }
ServiceConfiguration describes a service that is enabled for a certain cluster.
type ServiceInfo ¶
ServiceInfo is a reduced version of type limes.ServiceInfo, suitable for being returned from func QuotaPlugin.ServiceInfo().
func (ServiceInfo) ForAPI ¶
func (s ServiceInfo) ForAPI(serviceType limes.ServiceType) limes.ServiceInfo
ForAPI inflates the given core.ServiceInfo into a limes.ServiceInfo. The given ServiceType should be the one that we want to appear in the API.
type ServiceRateLimitConfiguration ¶
type ServiceRateLimitConfiguration struct { Global []RateLimitConfiguration `yaml:"global"` ProjectDefault []RateLimitConfiguration `yaml:"project_default"` }
ServiceRateLimitConfiguration describes the global and project-level default rate limit configurations for a service.
func (*ServiceRateLimitConfiguration) GetProjectDefaultRateLimit ¶
func (svcRlConfig *ServiceRateLimitConfiguration) GetProjectDefaultRateLimit(name liquid.RateName) (RateLimitConfiguration, bool)
GetProjectDefaultRateLimit returns the default project-level rate limit for a given target type URI and action or an error if not found.
type TranslationRule ¶
type TranslationRule struct { // If not nil, reports need to pass all `subcapacities` strings through this handler. TranslateSubcapacities func(string, limes.AvailabilityZone, liquid.ResourceName, liquid.ResourceInfo) (string, error) // If not nil, reports need to pass all `subresources` strings through this handler. TranslateSubresources func(string, limes.AvailabilityZone, liquid.ResourceName, liquid.ResourceInfo) (string, error) }
TranslationRule appears in type ResourceBehavior.
It provides a backwards compatibility mechanism to format subcapacities or subresources provided by a LIQUID implementation back into the old format that was generated by the respective CapacityPlugin or QuotaPlugin.
func NewTranslationRule ¶
func NewTranslationRule(id string) (TranslationRule, error)
NewTranslationRule returns the TranslationRule for the given ID, or an error if the ID is unknown.
func (TranslationRule) IsEmpty ¶
func (r TranslationRule) IsEmpty() bool
IsEmpty returns whether this translation rule contains only nil members.
func (*TranslationRule) UnmarshalYAML ¶
func (r *TranslationRule) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface.