Skip to content

Commit

Permalink
agent/billing: Use autoscaling.neon.tech/billing-endpoint-id for ev…
Browse files Browse the repository at this point in the history
…ents (#579)

Sometimes we want to provide neon/endpoint-id but not have billing
events generated for it.

This PR must not be merged until the corresponding control plane changes
have been released.

Ref neondatabase/cloud#7475
  • Loading branch information
sharnoff authored Nov 15, 2023
1 parent 3a38ede commit a6b385b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
6 changes: 1 addition & 5 deletions pkg/agent/billing/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ type vmMetricsSeconds struct {
activeTime time.Duration
}

const (
EndpointLabel string = "neon/endpoint-id"
)

func RunBillingMetricsCollector(
backgroundCtx context.Context,
parentLogger *zap.Logger,
Expand Down Expand Up @@ -152,7 +148,7 @@ func (s *metricsState) collect(logger *zap.Logger, store VMStoreForNode, metrics
})
}
for _, vm := range vmsOnThisNode {
endpointID, isEndpoint := vm.Labels[EndpointLabel]
endpointID, isEndpoint := vm.Annotations[api.AnnotationBillingEndpointID]
metricsBatch.inc(isEndpointFlag(isEndpoint), autoscalingEnabledFlag(api.HasAutoscalingEnabled(vm)), vm.Status.Phase)
if !isEndpoint {
// we're only reporting metrics for VMs with endpoint IDs, and this VM doesn't have one
Expand Down
1 change: 1 addition & 0 deletions pkg/api/vminfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
LabelEnableAutoscaling = "autoscaling.neon.tech/enabled"
AnnotationAutoscalingBounds = "autoscaling.neon.tech/bounds"
AnnotationAutoscalingConfig = "autoscaling.neon.tech/config"
AnnotationBillingEndpointID = "autoscaling.neon.tech/billing-endpoint-id"
)

// HasAutoscalingEnabled returns true iff the object has the label that enables autoscaling
Expand Down

0 comments on commit a6b385b

Please sign in to comment.