Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sapcc/go-api-declarations
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.14.0
Choose a base ref
...
head repository: sapcc/go-api-declarations
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.14.1
Choose a head ref
  • 10 commits
  • 8 files changed
  • 4 contributors

Commits on Mar 3, 2025

  1. Add mail option to planned commitments

    VoigtS committed Mar 3, 2025
    Copy the full SHA
    17d5561 View commit details
  2. fix linter

    VoigtS committed Mar 3, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b5f71ea View commit details
  3. Run go-makefile-maker

    sapcc-bot committed Mar 3, 2025
    Copy the full SHA
    a5d531e View commit details
  4. Run go-makefile-maker

    sapcc-bot committed Mar 3, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    24683db View commit details
  5. Run go-makefile-maker

    sapcc-bot committed Mar 3, 2025
    Copy the full SHA
    e063ab2 View commit details
  6. Fix lints

    SuperSandro2000 committed Mar 3, 2025
    Copy the full SHA
    6d35325 View commit details

Commits on Mar 17, 2025

  1. Run go-makefile-maker

    sapcc-bot committed Mar 17, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    32ec785 View commit details

Commits on Mar 20, 2025

  1. Merge pull request #42 from sapcc/notify_on_confirm

    Add mail option to planned commitments
    majewsky authored Mar 20, 2025
    Copy the full SHA
    4e8794d View commit details
  2. liquid: rename ResourceTopology to Topology, add Topology field to Ra…

    …teInfo
    
    This is an oversight on my part. RateUsageReport.PerAZ is already
    documented as being AZ-aware in the same way as
    ResourceUsageReport.PerAZ, so we need a topology declaration.
    
    The name change from ResourceTopology to Topology is necessitated by
    Topology being relevant for rates, too, not just resources.
    majewsky committed Mar 20, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e972622 View commit details
  3. Merge pull request #44 from sapcc/rateinfo-add-topology

    liquid: rename ResourceTopology to Topology, add Topology field to RateInfo
    majewsky authored Mar 20, 2025
    Copy the full SHA
    fef5bdd View commit details
Showing with 49 additions and 36 deletions.
  1. +1 −6 .golangci.yaml
  2. +1 −0 .license-scan-rules.json
  3. +4 −0 limes/resources/commitment.go
  4. +30 −17 liquid/info.go
  5. +1 −1 liquid/overcommit_factor_test.go
  6. +3 −3 liquid/quota.go
  7. +3 −3 liquid/report_capacity.go
  8. +6 −6 liquid/report_usage.go
7 changes: 1 addition & 6 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
# SPDX-License-Identifier: Apache-2.0

run:
timeout: 3m # 1m by default
timeout: 3m0s # 1m by default
modules-download-mode: readonly

output:
@@ -23,15 +23,11 @@ issues:
- path: _test\.go
linters:
- bodyclose
- dupl
# '0' disables the following options.
max-issues-per-linter: 0
max-same-issues: 0

linters-settings:
dupl:
# Tokens count to trigger issue, 150 by default.
threshold: 100
errcheck:
# Report about assignment of errors to blank identifier.
check-blank: true
@@ -135,7 +131,6 @@ linters:
- bodyclose
- containedctx
- copyloopvar
- dupl
- dupword
- durationcheck
- errcheck
1 change: 1 addition & 0 deletions .license-scan-rules.json
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
"BSD-2-Clause",
"BSD-2-Clause-FreeBSD",
"BSD-3-Clause",
"EPL-2.0",
"ISC",
"MIT",
"MPL-2.0",
4 changes: 4 additions & 0 deletions limes/resources/commitment.go
Original file line number Diff line number Diff line change
@@ -56,6 +56,9 @@ type Commitment struct {
// TransferStatus and TransferToken are only filled while the commitment is marked for transfer.
TransferStatus CommitmentTransferStatus `json:"transfer_status,omitempty"`
TransferToken *string `json:"transfer_token,omitempty"`
// NotifyOnConfirm can only be set if ConfirmBy is filled.
// Used to send a mail notification at commitment confirmation.
NotifyOnConfirm bool `json:"notify_on_confirm,omitempty"`
}

// CommitmentRequest is the API representation of a *new* commitment as requested by a user.
@@ -66,6 +69,7 @@ type CommitmentRequest struct {
Amount uint64 `json:"amount"`
Duration CommitmentDuration `json:"duration"`
ConfirmBy *limes.UnixEncodedTime `json:"confirm_by,omitempty"`
NotifyOnConfirm bool `json:"notify_on_confirm,omitempty"`
}

// CommitmentConversionRule is the API representation of how commitments can be converted into a different resource.
47 changes: 30 additions & 17 deletions liquid/info.go
Original file line number Diff line number Diff line change
@@ -63,12 +63,8 @@ type ResourceInfo struct {
// For example, the compute resource "cores" is countable, but the compute resource "ram" is measured, usually in MiB.
Unit Unit `json:"unit,omitempty"`

// How the resource reports usage (and capacity, if any).
//
// For backwards compatibility, it is currently acceptable to not provide this field.
// In this case, the fallback behavior is for Limes to decide between FlatResourceTopology and AZAwareResourceTopology based on actual reports.
// In the future, Limes will eventually reject ResourceInfo that do not specify a known ResourceTopology.
Topology ResourceTopology `json:"topology"`
// How the resource reports usage (and capacity, if any). This field is required, and must contain one of the valid enum variants defined in this package.
Topology Topology `json:"topology"`

// Whether the liquid reports capacity for this resource on the cluster level.
HasCapacity bool `json:"hasCapacity"`
@@ -89,40 +85,54 @@ type ResourceInfo struct {
Attributes json.RawMessage `json:"attributes,omitempty"`
}

// ResourceTopology describes how capacity and usage reported by a certain resource is structured.
// Topology describes how capacity and usage reported by a certain resource is structured.
// Type type appears in type ResourceInfo.
type ResourceTopology string
type Topology string

const (
// FlatResourceTopology is a topology for resources that are not AZ-aware at all.
// FlatTopology is a topology for resources that are not AZ-aware at all.
// In reports for this resource, PerAZ must contain exactly one key: AvailabilityZoneAny.
// Any other entry, as well as the absence of AvailabilityZoneAny, will be considered an error by Limes.
//
// If the resource sets HasQuota = true, only a flat number will be given, and PerAZ will be null.
FlatResourceTopology ResourceTopology = "flat"
FlatTopology Topology = "flat"

// AZAwareResourceTopology is a topology for resources that can measure capacity and usage by AZ.
// AZAwareTopology is a topology for resources that can measure capacity and usage by AZ.
// In reports for this resource, PerAZ shall contain an entry for each AZ mentioned in the AllAZs key of the request.
// PerAZ may also include an entry for AvailabilityZoneUnknown as needed.
// Any other entry (including AvailabilityZoneAny) will be considered an error by Limes.
//
// If the resource sets "HasQuota = true", only a flat number will be given, and PerAZ will be null.
// This behavior matches the AZ-unawareness of quota in most OpenStack services.
AZAwareResourceTopology ResourceTopology = "az-aware"
AZAwareTopology Topology = "az-aware"

// AZSeparatedResourceTopology is like AZAwareResourceTopology, but quota is also AZ-aware.
// For resources with HasQuota = false, this behaves the same as AZAwareResourceTopology.
// AZSeparatedTopology is like AZAwareTopology, but quota is also AZ-aware.
// For resources with HasQuota = false, this behaves the same as AZAwareTopology.
//
// If the resource sets "HasQuota = true", quota requests will include the PerAZ breakdown.
// PerAZ will only contain quotas for actual AZs, not for AvailabilityZoneAny or AvailabilityZoneUnknown.
AZSeparatedResourceTopology ResourceTopology = "az-separated"
AZSeparatedTopology Topology = "az-separated"
)

// ResourceTopology is a synonym for Topology.
//
// Deprecated: Use Topology instead.
type ResourceTopology = Topology

const (
// Deprecated: Use FlatTopology instead.
FlatResourceTopology ResourceTopology = FlatTopology
// Deprecated: Use AZAwareTopology instead.
AZAwareResourceTopology ResourceTopology = AZAwareTopology
// Deprecated: Use AZSeparatedTopology instead.
AZSeparatedResourceTopology ResourceTopology = AZSeparatedTopology
)

// IsValid returns whether the given value is a part of the enum.
// This can be used to check unmarshalled values.
func (t ResourceTopology) IsValid() bool {
func (t Topology) IsValid() bool {
switch t {
case FlatResourceTopology, AZAwareResourceTopology, AZSeparatedResourceTopology:
case FlatTopology, AZAwareTopology, AZSeparatedTopology:
return true
default:
return false
@@ -137,6 +147,9 @@ type RateInfo struct {
// For example, the storage rate "volume_creations" is countable, but the network rate "outbound_transfer" is measured, e.g. in bytes.
Unit Unit `json:"unit,omitempty"`

// How the rate reports usage. This field is required, and must contain one of the valid enum variants defined in this package.
Topology Topology `json:"topology"`

// Whether the liquid reports usage for this rate on the project level.
// This must currently be true because there is no other reason for a rate to exist.
// This requirement may be relaxed in the future, if LIQUID starts modelling rate limits and there are rates that have limits, but no usage tracking.
2 changes: 1 addition & 1 deletion liquid/overcommit_factor_test.go
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ func TestOvercommitFactor(t *testing.T) {

// ApplyTo is pretty straightforward, but I'd like some more test coverage for ApplyInReverseTo
for _, factor := range []OvercommitFactor{0, 1, 1.1, 1.2, 1.5, 2, 2.5, 3, 4} {
for raw := uint64(0); raw <= 100; raw++ {
for raw := range uint64(100) {
check(factor, raw, factor.ApplyTo(raw))
}
}
6 changes: 3 additions & 3 deletions liquid/quota.go
Original file line number Diff line number Diff line change
@@ -31,11 +31,11 @@ type ServiceQuotaRequest struct {
// ResourceQuotaRequest contains new quotas for a single resource.
// It appears in type ServiceQuotaRequest.
type ResourceQuotaRequest struct {
// For FlatResourceTopology and AZAwareResourceTopology, this is the only field that is filled, and PerAZ will be nil.
// For AZSeparatedResourceTopology, this contains the sum of the quotas across all AZs (for compatibility purposes).
// For FlatTopology and AZAwareTopology, this is the only field that is filled, and PerAZ will be nil.
// For AZSeparatedTopology, this contains the sum of the quotas across all AZs (for compatibility purposes).
Quota uint64 `json:"quota"`

// PerAZ will only be filled for AZSeparatedResourceTopology.
// PerAZ will only be filled for AZSeparatedTopology.
PerAZ map[AvailabilityZone]AZResourceQuotaRequest `json:"perAZ,omitempty"`
}

6 changes: 3 additions & 3 deletions liquid/report_capacity.go
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ type ResourceDemand struct {
OvercommitFactor OvercommitFactor `json:"overcommitFactor,omitempty"`

// The actual demand values are AZ-aware.
// The keys that can be expected in this map depend on the chosen ResourceTopology.
// The keys that can be expected in this map depend on the chosen Topology.
PerAZ map[AvailabilityZone]ResourceDemandInAZ `json:"perAZ"`
}

@@ -77,8 +77,8 @@ type ServiceCapacityReport struct {
// ResourceCapacityReport contains capacity data for a resource.
// It appears in type ServiceCapacityReport.
type ResourceCapacityReport struct {
// The keys that are allowed in this map depend on the chosen ResourceTopology.
// See documentation on ResourceTopology enum variants for details.
// The keys that are allowed in this map depend on the chosen Topology.
// See documentation on Topology enum variants for details.
PerAZ map[AvailabilityZone]*AZResourceCapacityReport `json:"perAZ"`
}

12 changes: 6 additions & 6 deletions liquid/report_usage.go
Original file line number Diff line number Diff line change
@@ -77,12 +77,12 @@ type ResourceUsageReport struct {
// - If the project has no usage in this resource, Limes will hide this resource from project reports.
Forbidden bool `json:"forbidden"`

// This shall be null if and only if the resource is declared with "HasQuota = false" or with AZSeparatedResourceTopology.
// This shall be null if and only if the resource is declared with "HasQuota = false" or with AZSeparatedTopology.
// A negative value, usually -1, indicates "infinite quota" (i.e., the absence of a quota).
Quota *int64 `json:"quota,omitempty"`

// The keys that are allowed in this map depend on the chosen ResourceTopology.
// See documentation on ResourceTopology enum variants for details.
// The keys that are allowed in this map depend on the chosen Topology.
// See documentation on Topology enum variants for details.
//
// Tip: When filling this by starting from a non-AZ-aware usage number that is later broken down with AZ-aware data, use func PrepareForBreakdownInto.
PerAZ map[AvailabilityZone]*AZResourceUsageReport `json:"perAZ"`
@@ -102,7 +102,7 @@ type AZResourceUsageReport struct {
// It is not allowed to report 5 GiB as Usage in this situation, since the 50 GiB value is used when judging whether the Quota fits.
PhysicalUsage *uint64 `json:"physicalUsage,omitempty"`

// This shall be non-null if and only if the resource is declared with AZSeparatedResourceTopology.
// This shall be non-null if and only if the resource is declared with AZSeparatedTopology.
// A negative value, usually -1, indicates "infinite quota" (i.e., the absence of a quota).
Quota *int64 `json:"quota,omitempty"`

@@ -150,8 +150,8 @@ func (r *ResourceUsageReport) AddLocalizedUsage(az AvailabilityZone, usage uint6
// RateUsageReport contains usage data for a rate in a single project.
// It appears in type ServiceUsageReport.
type RateUsageReport struct {
// The keys that are allowed in this map depend on the chosen ResourceTopology.
// See documentation on ResourceTopology enum variants for details.
// The keys that are allowed in this map depend on the chosen Topology.
// See documentation on Topology enum variants for details.
PerAZ map[AvailabilityZone]*AZRateUsageReport `json:"perAZ"`
}