Documentation
¶
Index ¶
- func BuildAPIRateInfo(rateName limesrates.RateName, rateInfo liquid.RateInfo) limesrates.RateInfo
- func BuildServiceCapacityRequest(backchannel CapacityScrapeBackchannel, allAZs []limes.AvailabilityZone, ...) (liquid.ServiceCapacityRequest, error)
- func BuildServiceUsageRequest(project KeystoneProject, allAZs []limes.AvailabilityZone, ...) (liquid.ServiceUsageRequest, error)
- func ConvertUnitFor(serviceInfo liquid.ServiceInfo, resourceName liquid.ResourceName, ...) (uint64, error)
- func HasResource(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType, ...) bool
- func HasService(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType) bool
- func HasUsageForRate(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType, ...) bool
- func InfoForRate(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType, ...) liquid.RateInfo
- func InfoForResource(serviceInfo liquid.ServiceInfo, resourceName liquid.ResourceName) liquid.ResourceInfo
- func InfoForService(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType) liquid.ServiceInfo
- func LiquidClientFactory(provider *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) func(db.ServiceType) (LiquidClient, error)
- func RatesForService(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType) map[liquid.RateName]liquid.RateInfo
- func SaveServiceInfoToDB(serviceType db.ServiceType, serviceInfo liquid.ServiceInfo, ...) (srv db.Service, err error)
- type AZResourceLocation
- type AutogrowQuotaDistributionConfiguration
- type CapacityScrapeBackchannel
- type Cluster
- func (c *Cluster) AllServiceInfos() (map[db.ServiceType]liquid.ServiceInfo, error)
- 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) BehaviorForResourceLocation(loc AZResourceLocation) ResourceBehavior
- func (c *Cluster) CommitmentBehaviorForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) CommitmentBehavior
- func (c *Cluster) Connect(ctx context.Context, provider *gophercloud.ProviderClient, ...) (errs errext.ErrorSet)
- func (c *Cluster) InfoForService(serviceType db.ServiceType) (Option[liquid.ServiceInfo], error)
- func (c *Cluster) QuotaDistributionConfigForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) QuotaDistributionConfiguration
- type ClusterConfiguration
- type CommitmentBehavior
- type CommitmentConversionRate
- type CommitmentConversionRule
- type CommitmentGroupNotification
- type CommitmentNotification
- type DiscoveryConfiguration
- type DiscoveryPlugin
- type KeystoneDomain
- type KeystoneProject
- type LiquidClient
- type LiquidConfiguration
- type LiquidConnection
- func (l *LiquidConnection) Init(ctx context.Context, client LiquidClient) (err error)
- func (l *LiquidConnection) Scrape(ctx context.Context, project KeystoneProject, allAZs []limes.AvailabilityZone) (result liquid.ServiceUsageReport, err error)
- func (l *LiquidConnection) ScrapeCapacity(ctx context.Context, backchannel CapacityScrapeBackchannel, ...) (result liquid.ServiceCapacityReport, srv db.Service, err error)
- func (l *LiquidConnection) ScrapeRates(ctx context.Context, project KeystoneProject, allAZs []limes.AvailabilityZone, ...) (result map[liquid.RateName]*big.Int, serializedState string, err error)
- func (l *LiquidConnection) ServiceInfo() liquid.ServiceInfo
- func (l *LiquidConnection) SetQuota(ctx context.Context, project KeystoneProject, ...) error
- type MailConfiguration
- type MailTemplate
- type MailTemplateConfiguration
- type PrometheusCapacityConfiguration
- type QuotaDistributionConfiguration
- type RateBehavior
- type RateLimitConfiguration
- type RateNameMapping
- type RateRef
- type RefInService
- type ResourceBehavior
- 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 ScopedCommitmentBehavior
- func (b ScopedCommitmentBehavior) CanConfirmCommitmentsAt(t time.Time) (errorMsg string)
- func (b ScopedCommitmentBehavior) ForAPI(now time.Time) Option[limesresources.CommitmentConfiguration]
- func (b ScopedCommitmentBehavior) GetConversionRateTo(other ScopedCommitmentBehavior) Option[CommitmentConversionRate]
- type ServiceRateLimitConfiguration
- type StaticDiscoveryConfiguration
- type StaticDiscoveryPlugin
- func (p *StaticDiscoveryPlugin) Init(ctx context.Context, client *gophercloud.ProviderClient, ...) error
- func (p *StaticDiscoveryPlugin) ListDomains(ctx context.Context) ([]KeystoneDomain, error)
- func (p *StaticDiscoveryPlugin) ListProjects(ctx context.Context, queryDomain KeystoneDomain) ([]KeystoneProject, error)
- type TranslationRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAPIRateInfo ¶
func BuildAPIRateInfo(rateName limesrates.RateName, rateInfo liquid.RateInfo) limesrates.RateInfo
BuildAPIRateInfo converts a RateInfo from LIQUID into the API format.
func BuildServiceCapacityRequest ¶
func BuildServiceCapacityRequest(backchannel CapacityScrapeBackchannel, allAZs []limes.AvailabilityZone, serviceType db.ServiceType, resources map[liquid.ResourceName]liquid.ResourceInfo) (liquid.ServiceCapacityRequest, error)
BuildServiceCapacityRequest generates the request body payload for querying the LIQUID API endpoint /v1/report-capacity. In order to be reusable for exposing an API which prints the request for admin purposes, it does not use the LiquidConnection as receiver type.
func BuildServiceUsageRequest ¶
func BuildServiceUsageRequest(project KeystoneProject, allAZs []limes.AvailabilityZone, usageReportNeedsProjectMetadata bool) (liquid.ServiceUsageRequest, error)
BuildServiceUsageRequest generates the request body payload for querying the LIQUID API endpoint /v1/projects/:uuid/report-usage. In order to be reusable for exposing an API which prints the request for admin purposes, it does not use the LiquidConnection as receiver type.
func ConvertUnitFor ¶
func ConvertUnitFor(serviceInfo liquid.ServiceInfo, 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.
func HasResource ¶
func HasResource(serviceInfos map[db.ServiceType]liquid.ServiceInfo, 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 HasService ¶
func HasService(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType) bool
HasService checks whether the given service is enabled in this cluster.
func HasUsageForRate ¶
func HasUsageForRate(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType, rateName liquid.RateName) bool
HasUsageForRate checks whether the given service is enabled in this cluster and whether it scrapes usage for the given rate.
func InfoForRate ¶
func InfoForRate(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType, rateName liquid.RateName) liquid.RateInfo
InfoForRate finds the connection for the given serviceType and finds within that connection 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 InfoForResource ¶
func InfoForResource(serviceInfo liquid.ServiceInfo, resourceName liquid.ResourceName) liquid.ResourceInfo
InfoForResource returns the ResourceInfo for a given service and resource. If the service does not exist, an empty ResourceInfo (with .Unit == UnitNone and .Category == "") is returned.
func InfoForService ¶
func InfoForService(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType) liquid.ServiceInfo
InfoForService returns the ServiceInfo for the given service type. If the service does not exist, an empty ServiceInfo is returned.
func LiquidClientFactory ¶
func LiquidClientFactory(provider *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) func(db.ServiceType) (LiquidClient, error)
LiquidClientFactory constructs LIQUID clients using liquidapi.NewClient(). Code holding a *Cluster object should use Cluster.LiquidClientFactory instead. In tests, a factory for mock clients is inserted at that dependency injection slot.
func RatesForService ¶
func RatesForService(serviceInfos map[db.ServiceType]liquid.ServiceInfo, serviceType db.ServiceType) map[liquid.RateName]liquid.RateInfo
RatesForService returns a list of all rates for the given service type. If the service does not exist, an empty list is returned. If an error occurs during db lookup, the error is returned.
func SaveServiceInfoToDB ¶
func SaveServiceInfoToDB(serviceType db.ServiceType, serviceInfo liquid.ServiceInfo, availabilityZones []limes.AvailabilityZone, rateLimits ServiceRateLimitConfiguration, timeNow time.Time, dbm *gorp.DbMap) (srv db.Service, err error)
SaveServiceInfoToDB ensures consistency of tables services, resources, az_resources and rates with the given serviceInfo. It is called whenever the LiquidVersion changes during Scrape or ScrapeCapacity or on Init from the collect-task. It does not have the LiquidConnection as receiverType, so that it can be reused from the testSetup to create DB entries.
Types ¶
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.
func (AZResourceLocation) ScopeString ¶
func (a AZResourceLocation) ScopeString() string
ScopeString returns a human-readable string representation of this AZ resource location. Format: "<service_type>/<resource_name> in <availability_zone>"
func (AZResourceLocation) ShortScopeString ¶
func (a AZResourceLocation) ShortScopeString() string
ShortScopeString returns a compact string representation of this AZ resource location. Format: "<service_type>/<resource_name>/<availability_zone>"
type AutogrowQuotaDistributionConfiguration ¶
type AutogrowQuotaDistributionConfiguration struct {
AllowQuotaOvercommitUntilAllocatedPercent float64 `json:"allow_quota_overcommit_until_allocated_percent"`
ProjectBaseQuota uint64 `json:"project_base_quota"`
GrowthMultiplier float64 `json:"growth_multiplier"`
GrowthMinimum uint64 `json:"growth_minimum"`
UsageDataRetentionPeriod util.MarshalableTimeDuration `json:"usage_data_retention_period"`
}
AutogrowQuotaDistributionConfiguration appears in type QuotaDistributionConfiguration.
type CapacityScrapeBackchannel ¶
type CapacityScrapeBackchannel interface {
GetResourceDemand(serviceType db.ServiceType, resourceName liquid.ResourceName) (liquid.ResourceDemand, error)
}
CapacityScrapeBackchannel is a callback interface that is provided to LiquidConnection.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 collect from a liquid or another source by the OvercommitFactor.
type Cluster ¶
type Cluster struct {
Config ClusterConfiguration
DiscoveryPlugin DiscoveryPlugin
LiquidConnections map[db.ServiceType]*LiquidConnection
// reference of the DB is necessary to delete leftover LiquidConnections
DB *gorp.DbMap
// used to generate LiquidClients without LiquidConnections
LiquidClientFactory func(db.ServiceType) (LiquidClient, error)
}
Cluster contains all configuration and runtime information for the target cluster. It will behave differently with regards to the LiquidConnections depending on the configuration of the fillLiquidConnections parameter on NewCluster. When LiquidConnections are not filled, the cluster is in read-only mode, which will cause all operations involving LiquidConnections to fallback to database operations.
func NewCluster ¶
func NewCluster(config ClusterConfiguration, timeNow func() time.Time, dbm *gorp.DbMap, fillLiquidConnections bool) (c *Cluster, errs errext.ErrorSet)
NewCluster creates a new Cluster instance also initializes the LiquidConnections - if configured. Errors will be logged when the requested DiscoveryPlugin cannot be found.
func NewClusterFromJSON ¶
func NewClusterFromJSON(configBytes []byte, timeNow func() time.Time, dbm *gorp.DbMap, fillLiquidConnections bool) (cluster *Cluster, errs errext.ErrorSet)
NewClusterFromJSON reads and validates the configuration in the given JSON document. Errors are logged and will result in program termination, causing the function to not return.
func (*Cluster) AllServiceInfos ¶
func (c *Cluster) AllServiceInfos() (map[db.ServiceType]liquid.ServiceInfo, error)
AllServiceInfos returns a map of all ServiceInfos for all services in this cluster. Its output is the basis to use the convenience methods below to get certain properties of the services configuration. In order to be usable efficiently, it is recommended to call this method only once per API, so that the database fallback is only done once.
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 service.
func (*Cluster) BehaviorForResourceLocation ¶
func (c *Cluster) BehaviorForResourceLocation(loc AZResourceLocation) ResourceBehavior
BehaviorForResourceLocation is a shorthand for BehaviorForResource using an AZResourceLocation.
func (*Cluster) CommitmentBehaviorForResource ¶
func (c *Cluster) CommitmentBehaviorForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) CommitmentBehavior
CommitmentBehaviorForResource returns the CommitmentBehavior for the given resource in the given service.
func (*Cluster) Connect ¶
func (c *Cluster) Connect(ctx context.Context, provider *gophercloud.ProviderClient, eo gophercloud.EndpointOpts, liquidClientFactory func(db.ServiceType) (LiquidClient, error)) (errs errext.ErrorSet)
Connect calls Init() on the DiscoveryPlugin and LiquidConnections.
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 LiquidConnections.
func (*Cluster) InfoForService ¶
func (c *Cluster) InfoForService(serviceType db.ServiceType) (Option[liquid.ServiceInfo], error)
InfoForService returns the ServiceInfo for a given service. If the service does not exist, None[liquid.ServiceInfo] is returned. It should be used instead of Cluster.AllServiceInfos when only one service is needed, to avoid the overhead of loading all services.
func (*Cluster) QuotaDistributionConfigForResource ¶
func (c *Cluster) QuotaDistributionConfigForResource(serviceType db.ServiceType, resourceName liquid.ResourceName) QuotaDistributionConfiguration
QuotaDistributionConfigForResource returns the QuotaDistributionConfiguration for the given resource.
type ClusterConfiguration ¶
type ClusterConfiguration struct {
AvailabilityZones []limes.AvailabilityZone `json:"availability_zones"`
CatalogURL string `json:"catalog_url"`
Discovery DiscoveryConfiguration `json:"discovery"`
Liquids map[db.ServiceType]LiquidConfiguration `json:"liquids"`
ResourceBehaviors []ResourceBehavior `json:"resource_behavior"`
RateBehaviors []RateBehavior `json:"rate_behavior"`
QuotaDistributionConfigs []QuotaDistributionConfiguration `json:"quota_distribution_configs"`
MailNotifications Option[*MailConfiguration] `json:"mail_notifications"`
}
ClusterConfiguration contains all the configuration data for a single cluster. It is instantiated from JSON and then transformed into type Cluster during the startup phase.
func (*ClusterConfiguration) GetLiquidConfigurationForType ¶
func (cluster *ClusterConfiguration) GetLiquidConfigurationForType(serviceType db.ServiceType) (LiquidConfiguration, bool)
GetLiquidConfigurationForType returns the LiquidConfiguration or false.
type CommitmentBehavior ¶
type CommitmentBehavior struct {
// This ConfigSet is keyed on domain name, because commitment durations
// (and thus committability) are allowed to differ per domain.
//
// If DurationsPerDomain.Pick() returns an empty slice, then commitments are entirely forbidden for that resource in the given domain.
DurationsPerDomain regexpext.ConfigSet[string, []limesresources.CommitmentDuration] `json:"durations_per_domain"`
MinConfirmDate Option[time.Time] `json:"min_confirm_date"`
UntilPercent Option[float64] `json:"until_percent"`
ConversionRule Option[CommitmentConversionRule] `json:"conversion_rule"`
}
CommitmentBehavior describes how commitments work for a single resource.
It appears in type ServiceConfiguration.
func (CommitmentBehavior) ForCluster ¶
func (b CommitmentBehavior) ForCluster() ScopedCommitmentBehavior
ForCluster merges the commitment behaviors for all domains together, thus reporting all durations that are allowed on at least one domain in no guaranteed order.
func (CommitmentBehavior) ForDomain ¶
func (b CommitmentBehavior) ForDomain(domainName string) ScopedCommitmentBehavior
ForDomain resolves Durations.Pick() using the provided domain name.
func (CommitmentBehavior) Validate ¶
func (b CommitmentBehavior) Validate(path string, occupiedConversionIdentifiers []string) (errs errext.ErrorSet, identifier string)
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 CommitmentConversionRate ¶
CommitmentConversionRate describes the rate for converting commitments between two compatible resources.
type CommitmentConversionRule ¶
type CommitmentConversionRule struct {
Identifier string `json:"identifier"`
Weight uint64 `json:"weight"`
}
CommitmentConversionRule describes how commitments for a resource may be converted into commitments for other resources with the same rule identifier.
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
LeftoverAmount uint64
}
CommitmentNotification appears in type CommitmentGroupNotification.
type DiscoveryConfiguration ¶
type DiscoveryConfiguration struct {
Method string `json:"method"`
ExcludeDomainRx regexpext.PlainRegexp `json:"except_domains"`
IncludeDomainRx regexpext.PlainRegexp `json:"only_domains"`
StaticDiscoveryConfiguration StaticDiscoveryConfiguration `json:"static_config"`
}
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 {
// 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.
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.
func NewDiscoveryPlugin ¶
func NewDiscoveryPlugin(cfg DiscoveryConfiguration) (DiscoveryPlugin, error)
NewDiscoveryPlugin instantiates a DiscoveryPlugin implementation based on the provided method and parameters.
type KeystoneDomain ¶
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 liquid.ProjectUUID `json:"id"`
Name string `json:"name"`
ParentUUID string `json:"parent_id,omitempty"`
Domain KeystoneDomain `json:"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 LiquidClient ¶
type LiquidClient interface {
GetInfo(ctx context.Context) (result liquid.ServiceInfo, err error)
GetCapacityReport(ctx context.Context, req liquid.ServiceCapacityRequest) (result liquid.ServiceCapacityReport, err error)
GetUsageReport(ctx context.Context, projectUUID string, req liquid.ServiceUsageRequest) (result liquid.ServiceUsageReport, err error)
PutQuota(ctx context.Context, projectUUID string, req liquid.ServiceQuotaRequest) (err error)
ChangeCommitments(ctx context.Context, req liquid.CommitmentChangeRequest) (result liquid.CommitmentChangeResponse, err error)
}
LiquidClient is a wrapper for type liquidapi.Client. Allows for the implementation of a mock client that is used in unit tests
type LiquidConfiguration ¶
type LiquidConfiguration struct {
Area string `json:"area"`
// FixedCapacityConfiguration and PrometheusCapacityConfiguration are additional means of providing capacity for this
// service_type besides the liquid.ServiceCapacityReport. All means are not exclusive and can be combined, as long as
// they don't write capacity to the same liquid.ResourceName.
FixedCapacityConfiguration Option[map[liquid.ResourceName]uint64] `json:"fixed_capacity_values"`
PrometheusCapacityConfiguration Option[PrometheusCapacityConfiguration] `json:"capacity_values_from_prometheus"`
// RateLimits describes the global rate limits (all requests for to a backend) and default project level rate limits.
RateLimits ServiceRateLimitConfiguration `json:"rate_limits"`
// Use Cluster.CommitmentBehaviorForResource() to access this.
CommitmentBehaviorPerResource regexpext.ConfigSet[liquid.ResourceName, CommitmentBehavior] `json:"commitment_behavior_per_resource"`
}
LiquidConfiguration describes a service that is enabled for a certain cluster by means of a corresponding running liquid. It holds configurations for how to deal with the service on project level (quota, usage, commitment) as well as cluster level (capacity).
type LiquidConnection ¶
type LiquidConnection struct {
// configuration
ServiceType db.ServiceType
FixedCapacityConfiguration Option[map[liquid.ResourceName]uint64]
PrometheusCapacityConfiguration Option[PrometheusCapacityConfiguration]
AvailabilityZones []limes.AvailabilityZone
RateLimits ServiceRateLimitConfiguration
LiquidClient LiquidClient
DB *gorp.DbMap
// contains filtered or unexported fields
}
LiquidConnection holds all the information which is necessary to interact with the LiquidClient. The state information of the LiquidConnection is persisted in the database to avoid reloading in case of configuration changes.
func MakeLiquidConnection ¶
func MakeLiquidConnection(lc LiquidConfiguration, serviceType db.ServiceType, availabilityZones []limes.AvailabilityZone, rateLimits ServiceRateLimitConfiguration, timeNow func() time.Time, dbm *gorp.DbMap) LiquidConnection
MakeLiquidConnection is a factory to fill all necessary configuration fields
func (*LiquidConnection) Init ¶
func (l *LiquidConnection) Init(ctx context.Context, client LiquidClient) (err error)
Init is called before any other interface methods, and allows the LiquidConnection to perform first-time initialization.
func (*LiquidConnection) Scrape ¶
func (l *LiquidConnection) Scrape(ctx context.Context, project KeystoneProject, allAZs []limes.AvailabilityZone) (result liquid.ServiceUsageReport, err error)
Scrape queries the backend service for the quota and usage data of all the resources for the given project in the given domain.
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.
func (*LiquidConnection) ScrapeCapacity ¶
func (l *LiquidConnection) ScrapeCapacity(ctx context.Context, backchannel CapacityScrapeBackchannel, allAZs []limes.AvailabilityZone) (result liquid.ServiceCapacityReport, srv db.Service, err error)
ScrapeCapacity queries the backend service(s) for the capacities of the resources that this LiquidConnection 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.
func (*LiquidConnection) ScrapeRates ¶
func (l *LiquidConnection) ScrapeRates(ctx context.Context, project KeystoneProject, allAZs []limes.AvailabilityZone, prevSerializedState string) (result map[liquid.RateName]*big.Int, serializedState string, err error)
ScrapeRates queries the backend service for the usage data of all 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 LiquidConnection can use this field to carry state between ScrapeRates() calls, esp. to detect and handle counter resets in the backend.
func (*LiquidConnection) ServiceInfo ¶
func (l *LiquidConnection) ServiceInfo() liquid.ServiceInfo
ServiceInfo returns metadata for this liquid. This includes metadata for all the resources and rates that this liquid scrapes.
func (*LiquidConnection) SetQuota ¶
func (l *LiquidConnection) SetQuota(ctx context.Context, project KeystoneProject, quotaReq map[liquid.ResourceName]liquid.ResourceQuotaRequest) error
SetQuota updates the backend service's quotas for the given project in the given domain to the values specified here.
type MailConfiguration ¶
type MailConfiguration struct {
Endpoint string `json:"endpoint"`
Templates MailTemplateConfiguration `json:"templates"`
}
MailConfiguration appears in type Configuration.
type MailTemplate ¶
type MailTemplate struct {
Subject string `json:"subject"`
Body string `json:"body"`
Compiled *template.Template `json:"-"` // 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 `json:"confirmed_commitments"`
ExpiringCommitments MailTemplate `json:"expiring_commitments"`
TransferredCommitments MailTemplate `json:"transferred_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 PrometheusCapacityConfiguration ¶
type PrometheusCapacityConfiguration struct {
APIConfig promquery.Config `json:"api"`
Queries map[liquid.ResourceName]string `json:"queries"`
AllowZeroCapacity bool `json:"allow_zero_capacity"`
}
PrometheusCapacityConfiguration appears in type LiquidConfiguration.
type QuotaDistributionConfiguration ¶
type QuotaDistributionConfiguration struct {
FullResourceNameRx regexpext.BoundedRegexp `json:"resource"`
Model limesresources.QuotaDistributionModel `json:"model"`
// options for AutogrowQuotaDistribution
Autogrow Option[AutogrowQuotaDistributionConfiguration] `json:"autogrow"`
}
QuotaDistributionConfiguration contains configuration options for specifying the QuotaDistributionModel of specific resources.
type RateBehavior ¶
type RateBehavior struct {
FullRateNameRx regexpext.BoundedRegexp `json:"rate"`
IdentityInV1API RateRef `json:"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 `json:"name"`
Unit limes.Unit `json:"unit"`
Limit uint64 `json:"limit"`
Window limesrates.Window `json:"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, serviceInfos map[db.ServiceType]liquid.ServiceInfo) 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 JSON, this deserializes from a string in the "service/resource" or "service/rate" format.
func (*RefInService[S, R]) UnmarshalJSON ¶
func (r *RefInService[S, R]) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type ResourceBehavior ¶
type ResourceBehavior struct {
FullResourceNameRx regexpext.BoundedRegexp `json:"resource"`
OvercommitFactor liquid.OvercommitFactor `json:"overcommit_factor"`
IdentityInV1API ResourceRef `json:"identity_in_v1_api"`
TranslationRuleInV1API TranslationRule `json:"translation_rule_in_v1_api"`
Category string `json:"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) 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 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, serviceInfos map[db.ServiceType]liquid.ServiceInfo) 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 ScopedCommitmentBehavior ¶
type ScopedCommitmentBehavior struct {
Durations []limesresources.CommitmentDuration
MinConfirmDate Option[time.Time]
UntilPercent Option[float64]
ConversionRule Option[CommitmentConversionRule]
}
ScopedCommitmentBehavior is a CommitmentBehavior that applies only to a certain scope (usually a specific domain). It is created through the For... methods on type CommitmentBehavior.
func (ScopedCommitmentBehavior) CanConfirmCommitmentsAt ¶
func (b ScopedCommitmentBehavior) CanConfirmCommitmentsAt(t time.Time) (errorMsg string)
CanConfirmCommitmentsAt evaluates the MinConfirmDate field.
func (ScopedCommitmentBehavior) ForAPI ¶
func (b ScopedCommitmentBehavior) ForAPI(now time.Time) Option[limesresources.CommitmentConfiguration]
ForAPI converts this behavior into its API representation.
func (ScopedCommitmentBehavior) GetConversionRateTo ¶
func (b ScopedCommitmentBehavior) GetConversionRateTo(other ScopedCommitmentBehavior) Option[CommitmentConversionRate]
GetConversionRateTo checks whether this resource can be converted into the given resource. If so, the conversion rate is returned.
type ServiceRateLimitConfiguration ¶
type ServiceRateLimitConfiguration struct {
Global []RateLimitConfiguration `json:"global"`
ProjectDefault []RateLimitConfiguration `json:"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 StaticDiscoveryConfiguration ¶
type StaticDiscoveryConfiguration struct {
Domains []KeystoneDomain `json:"domains"`
Projects map[string][]KeystoneProject `json:"projects"`
}
StaticDiscoveryConfiguration appears in type DiscoveryConfiguration. It contains configuration for the discovery method "static".
type StaticDiscoveryPlugin ¶
type StaticDiscoveryPlugin struct {
Config StaticDiscoveryConfiguration
}
StaticDiscoveryPlugin is an implementation of DiscoveryPlugin.
This type should not be instantiated directly. It is only exported because tests need to be able to cast into it.
func (*StaticDiscoveryPlugin) Init ¶
func (p *StaticDiscoveryPlugin) Init(ctx context.Context, client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) error
Init implements the DiscoveryPlugin interface.
func (*StaticDiscoveryPlugin) ListDomains ¶
func (p *StaticDiscoveryPlugin) ListDomains(ctx context.Context) ([]KeystoneDomain, error)
ListDomains implements the DiscoveryPlugin interface.
func (*StaticDiscoveryPlugin) ListProjects ¶
func (p *StaticDiscoveryPlugin) ListProjects(ctx context.Context, queryDomain KeystoneDomain) ([]KeystoneProject, error)
ListProjects implements the DiscoveryPlugin interface.
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) `json:"-"`
// If not nil, reports need to pass all `subresources` strings through this handler.
TranslateSubresources func(string, limes.AvailabilityZone, liquid.ResourceName, liquid.ResourceInfo) (string, error) `json:"-"`
}
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 old plugins for quota or capacity.
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) UnmarshalJSON ¶
func (r *TranslationRule) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.