statusutil

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SubnetStatusUpdateTotal counts Subnet status updates
	SubnetStatusUpdateTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "aquanaut_ipam_subnet_status_update_total",
			Help: "Total number of Subnet status update attempts",
		},
		[]string{"result"},
	)

	// SubnetStatusUpdateLatency measures Subnet status update latency
	SubnetStatusUpdateLatency = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "aquanaut_ipam_subnet_status_update_latency_seconds",
			Help:    "Latency of Subnet status update operations",
			Buckets: []float64{0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0},
		},
		[]string{"result"},
	)

	// SubnetStatusRetryTotal counts Subnet status update retries due to conflicts
	SubnetStatusRetryTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "aquanaut_ipam_subnet_status_retry_total",
			Help: "Total number of Subnet status update retries due to conflicts",
		},
		[]string{"retries"},
	)
)

Functions

func PatchSubnetStatus

func PatchSubnetStatus(
	ctx context.Context,
	c client.Client,
	sub *ipamv1.Subnet,
	mutate func(*ipamv1.SubnetStatus),
) error

PatchSubnetStatus is a generic helper function to update the Status field of a Subnet using Patch Arbitrary Status updates are possible with a custom mutate function Enhance conflict resistance using client.Status().Patch and retry.OnError

Arguments:

  • ctx: Context (supports timeout/cancellation)
  • c: Client interface
  • sub: Subnet to be updated
  • mutate: Callback function for Status update

Example:

err := statusutil.PatchSubnetStatus(ctx, r.Client, subnet, func(status *ipamv1.SubnetStatus) {
    status.Phase = ipamv1.SubnetPhaseAllocated
    // Update other status fields
})

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL