diff --git a/go.mod b/go.mod index 56fce1fcd..181e11b74 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/prometheus/client_golang v1.23.0 github.com/prometheus/client_model v0.6.2 github.com/prometheus/common v0.65.0 + github.com/prometheus/prometheus v0.305.0 github.com/stretchr/testify v1.10.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 @@ -43,14 +44,15 @@ require ( github.com/antlr4-go/antlr/v4 v4.13.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect - github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/cenkalti/backoff/v5 v5.0.2 // indirect github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/dennwc/varint v1.0.0 // indirect github.com/emicklei/go-restful/v3 v3.12.0 // indirect github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect github.com/evanphx/json-patch/v5 v5.9.11 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect @@ -64,9 +66,10 @@ require ( github.com/google/btree v1.1.3 // indirect github.com/google/cel-go v0.23.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect - github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect + github.com/google/pprof v0.0.0-20250607225305-033d6d78b36a // indirect github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect + github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect github.com/huandu/xstrings v1.3.3 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -90,30 +93,31 @@ require ( github.com/stoewer/go-strcase v1.3.0 // indirect github.com/x448/float16 v0.8.4 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect go.opentelemetry.io/otel v1.36.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.36.0 // indirect go.opentelemetry.io/otel/metric v1.36.0 // indirect go.opentelemetry.io/otel/sdk v1.36.0 // indirect go.opentelemetry.io/otel/trace v1.36.0 // indirect - go.opentelemetry.io/proto/otlp v1.4.0 // indirect + go.opentelemetry.io/proto/otlp v1.6.0 // indirect + go.uber.org/atomic v1.11.0 // indirect go.uber.org/automaxprocs v1.6.0 // indirect go.yaml.in/yaml/v2 v2.4.2 // indirect golang.org/x/crypto v0.40.0 // indirect - golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect + golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect golang.org/x/mod v0.26.0 // indirect golang.org/x/net v0.42.0 // indirect golang.org/x/oauth2 v0.30.0 // indirect golang.org/x/sys v0.34.0 // indirect golang.org/x/term v0.33.0 // indirect golang.org/x/text v0.27.0 // indirect - golang.org/x/time v0.9.0 // indirect + golang.org/x/time v0.12.0 // indirect golang.org/x/tools v0.35.0 // indirect golang.org/x/tools/go/expect v0.1.1-deprecated // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 9a0d8a4bb..0a323e09b 100644 --- a/go.sum +++ b/go.sum @@ -1,21 +1,65 @@ cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY= cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= +cloud.google.com/go/auth v0.16.2 h1:QvBAGFPLrDeoiNjyfVunhQ10HKNYuOwZ5noee0M5df4= +cloud.google.com/go/auth v0.16.2/go.mod h1:sRBas2Y1fB1vZTdurouM0AzuYQBMZinrUYL8EufhtEA= +cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc= +cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c= +cloud.google.com/go/compute/metadata v0.7.0 h1:PBWF+iiAerVNe8UCHxdOt6eHLVc3ydFeOCw78U8ytSU= +cloud.google.com/go/compute/metadata v0.7.0/go.mod h1:j5MvL9PprKL39t166CoB1uVHfQMs4tFQZZcKwksXUjo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 h1:Gt0j3wceWMwPmiazCa8MzMA0MfhmPIz0Qp0FJ6qcM0U= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1/go.mod h1:JdM5psgjfBf5fo2uWOZhflPWyDBZ/O/CNAH9CtsuZE4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 h1:FPKJS1T+clwv+OLGt13a8UjqeRuh0O4SJ3lUriThc+4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1/go.mod h1:j2chePtV91HrC22tGoRX3sGY42uF13WzmmV80/OdVAA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= +github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vSQ6PWWSL9lK8qwHozUj03+zLoEB8O0= +github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs= github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38yqWM= +github.com/aws/aws-sdk-go-v2 v1.36.3/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg= +github.com/aws/aws-sdk-go-v2/config v1.29.14 h1:f+eEi/2cKCg9pqKBoAIwRGzVb70MRKqWX4dg1BDcSJM= +github.com/aws/aws-sdk-go-v2/config v1.29.14/go.mod h1:wVPHWcIFv3WO89w0rE10gzf17ZYy+UVS1Geq8Iei34g= +github.com/aws/aws-sdk-go-v2/credentials v1.17.67 h1:9KxtdcIA/5xPNQyZRgUSpYOE6j9Bc4+D7nZua0KGYOM= +github.com/aws/aws-sdk-go-v2/credentials v1.17.67/go.mod h1:p3C44m+cfnbv763s52gCqrjaqyPikj9Sg47kUVaNZQQ= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 h1:x793wxmUWVDhshP8WW2mlnXuFrO4cOd3HLBroh1paFw= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30/go.mod h1:Jpne2tDnYiFascUEs2AWHJL9Yp7A5ZVy3TNyxaAjD6M= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 h1:ZK5jHhnrioRkUNOc+hOgQKlUL5JeC3S6JgLxtQ+Rm0Q= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34/go.mod h1:p4VfIceZokChbA9FzMbRGz5OV+lekcVtHlPKEO0gSZY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 h1:SZwFm17ZUNNg5Np0ioo/gq8Mn6u9w19Mri8DnJ15Jf0= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34/go.mod h1:dFZsC0BLo346mvKQLWmoJxT+Sjp+qcVR1tRVHQGOH9Q= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d2KyU5X/BZxjOkRo= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b5IzM/lum78bZ590jy36+d/aFLgKF/4Vd1xPE= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2F1JbDaGooxTq18wmmFzbJRfXfVfy96/1CXM= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY= +github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 h1:1Gw+9ajCV1jogloEv1RRnvfRFia2cL6c9cuKV2Ps+G8= +github.com/aws/aws-sdk-go-v2/service/sso v1.25.3/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 h1:hXmVKytPfTy5axZ+fYbR5d0cFmC3JvwLm5kM83luako= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 h1:1XuUZ8mYJw9B6lzAkXhqHlJd/XvaX32evhproijJEZY= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.19/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4= +github.com/aws/smithy-go v1.22.2 h1:6D9hW43xKFrRx/tXXfAlIZc4JI+yQe6snnWcQyxSyLQ= +github.com/aws/smithy-go v1.22.2/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 h1:6df1vn4bBlDDo4tARvBm7l6KA9iVMnE3NWizDeWSrps= +github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3/go.mod h1:CIWtjkly68+yqLPbvwwR/fjNJA/idrtULjZWh2v1ys0= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= -github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= -github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cenkalti/backoff/v5 v5.0.2 h1:rIfFVxEf1QsI7E1ZHfp/B4DF/6QBAUhmgkxc0H7Zss8= +github.com/cenkalti/backoff/v5 v5.0.2/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 h1:aQ3y1lwWyqYPiWZThqv1aFbZMiM9vblcSArJRf2Irls= @@ -25,6 +69,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dennwc/varint v1.0.0 h1:kGNFFSSw8ToIy3obO/kKr8U9GZYUAxQEVuix4zfDWzE= +github.com/dennwc/varint v1.0.0/go.mod h1:hnItb35rvZvJrbTALZtY/iQfDs48JKRG1RPpgziApxA= github.com/elastic/crd-ref-docs v0.2.0 h1:U17MyGX71j4qfKTvYxbR4qZGoA1hc2thy7kseGYmP+o= github.com/elastic/crd-ref-docs v0.2.0/go.mod h1:0bklkJhTG7nC6AVsdDi0wt5bGoqvzdZSzMMQkilZ6XM= github.com/emicklei/go-restful/v3 v3.12.0 h1:y2DdzBAURM29NFF94q6RaY4vjIH1rtwDapwQtU84iWk= @@ -39,8 +85,8 @@ github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjT github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= +github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -64,8 +110,12 @@ github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= +github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= +github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/cel-go v0.23.2 h1:UdEe3CvQh3Nv+E/j9r1Y//WO0K0cSyD7/y0bzyLIMI4= @@ -78,14 +128,22 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8= -github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= +github.com/google/pprof v0.0.0-20250607225305-033d6d78b36a h1://KbezygeMJZCSHH+HgUZiTeSoiuFspbMg1ge+eFj18= +github.com/google/pprof v0.0.0-20250607225305-033d6d78b36a/go.mod h1:5hDyRhoBCxViHszMt12TnOpEI4VVi+U8Gm9iphldiMA= +github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0= +github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.3.6 h1:GW/XbdyBFQ8Qe+YAmFU9uHLo7OnF5tL52HFAgMmyrf4= +github.com/googleapis/enterprise-certificate-proxy v0.3.6/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA= +github.com/googleapis/gax-go/v2 v2.14.2 h1:eBLnkZ9635krYIPD+ag1USrOAI0Nr0QYF3+/3GqO0k0= +github.com/googleapis/gax-go/v2 v2.14.2/go.mod h1:ON64QhlJkhVtSqp4v1uaK92VyZ2gmvDQsweuyLV+8+w= github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 h1:JeSE6pjso5THxAzdVpqr6/geYxZytqFMBCOtn/ujyeo= github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674/go.mod h1:r4w70xmWCQKmi1ONH4KIaBptdivuRPyosB9RmPlGEwA= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 h1:TmHmbvxPmaegwhDubVz0lICL0J5Ka2vwTzhoePEXsGE= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0/go.mod h1:qztMSjm835F2bXf+5HKAPIS5qsmQDqZna/PgVt4rWtI= +github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc h1:GN2Lv3MGO7AS6PrRoT6yV5+wkrOpcszoIsO4+4ds248= +github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc/go.mod h1:+JKpmjMGhpgPL+rXZ5nsZieVzvarn86asRlBg4uNGnk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= @@ -96,6 +154,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -123,16 +183,23 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= +github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s= +github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus= github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8= github.com/onsi/gomega v1.38.0 h1:c/WX+w8SLAinvuKKQFh77WEucCnPk4j2OTUr7lt7BeY= github.com/onsi/gomega v1.38.0/go.mod h1:OcXcwId0b9QsE7Y49u+BTrL4IdKOBOKnD6VQNTJEB6o= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= @@ -150,6 +217,10 @@ github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2 github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8= github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg= github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is= +github.com/prometheus/prometheus v0.305.0 h1:UO/LsM32/E9yBDtvQj8tN+WwhbyWKR10lO35vmFLx0U= +github.com/prometheus/prometheus v0.305.0/go.mod h1:JG+jKIDUJ9Bn97anZiCjwCxRyAx+lpcEQ0QnZlUlbwY= +github.com/prometheus/sigv4 v0.2.0 h1:qDFKnHYFswJxdzGeRP63c4HlH3Vbn1Yf/Ao2zabtVXk= +github.com/prometheus/sigv4 v0.2.0/go.mod h1:D04rqmAaPPEUkjRQxGqjoxdyJuyCh6E0M18fZr0zBiE= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -176,14 +247,14 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 h1:yd02MEjBdJkG3uabWP9apV+OuWRIXGDuJEUJbOHmCFU= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0/go.mod h1:umTcuxiv1n/s/S6/c2AT/g2CQ7u5C59sHDNmfSwgz7Q= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 h1:F7Jx+6hwnZ41NSFTO5q4LYDtJRXBf2PD0rNBkeB/lus= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q= go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg= go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 h1:Vh5HayB/0HHfOQA7Ctx69E/Y/DcQSMPpKANYVMQ7fBA= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0/go.mod h1:cpgtDBaqD/6ok/UG0jT15/uKjAY8mRA53diogHBg3UI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 h1:5pojmb1U1AogINhN3SurB+zm/nIcusopeBNp42f45QM= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0/go.mod h1:57gTHJSE5S1tqg+EKsLPlTWhpHMsWlVmer+LA926XiA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 h1:dNzwXjZKpMpE2JhmO+9HsPl42NIXFIFSUSSs0fiqra0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0/go.mod h1:90PoxvaEB5n6AOdZvi+yWJQoE95U8Dhhw2bSyRqnTD0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.36.0 h1:JgtbA0xkWHnTmYk7YusopJFX6uleBmAuZ8n05NEh8nQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.36.0/go.mod h1:179AK5aar5R3eS9FucPy6rggvU0g52cvKId8pv4+v0c= go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE= go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs= go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs= @@ -192,8 +263,10 @@ go.opentelemetry.io/otel/sdk/metric v1.36.0 h1:r0ntwwGosWGaa0CrSt8cuNuTcccMXERFw go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4= go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w= go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA= -go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg= -go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY= +go.opentelemetry.io/proto/otlp v1.6.0 h1:jQjP+AQyTf+Fe7OKj/MfkDrmK4MNVtw2NpXsf9fefDI= +go.opentelemetry.io/proto/otlp v1.6.0/go.mod h1:cicgGehlFuNdgZkcALOCh3VE6K/u2tAjzlRhDwmVpZc= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= @@ -211,8 +284,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= +golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA= +golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg= @@ -241,8 +314,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= -golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= +golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -259,10 +332,12 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= -google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a h1:SGktgSolFCo75dnHJF2yMvnns6jCmHFJ0vE4Vn2JKvQ= -google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a/go.mod h1:a77HrdMjoeKbnd2jmgcWdaS++ZLZAEq3orIOAEIKiVw= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a h1:v2PbRU4K3llS09c7zodFpNePeamkAwG3mPrAery9VeE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/api v0.238.0 h1:+EldkglWIg/pWjkq97sd+XxH7PxakNYoe/rkSTbnvOs= +google.golang.org/api v0.238.0/go.mod h1:cOVEm2TpdAGHL2z+UwyS+kmlGr3bVWQQ6sYEqkKje50= +google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 h1:oWVWY3NzT7KJppx2UKhKmzPq4SRe0LdCijVRwvGeikY= +google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822/go.mod h1:h3c4v36UTKzUiuaOKQ6gr3S+0hovBtUrXzTG/i3+XEc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 h1:fc6jSaCT0vBduLYZHYrBBNY4dsWuvgyff9noRNDdBeE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4= google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= diff --git a/pkg/epp/datalayer/attributemap.go b/pkg/epp/datalayer/attributemap.go index 45b39a574..614bf57bb 100644 --- a/pkg/epp/datalayer/attributemap.go +++ b/pkg/epp/datalayer/attributemap.go @@ -32,12 +32,11 @@ type AttributeMap interface { Put(string, Cloneable) Get(string) (Cloneable, bool) Keys() []string - Clone() *Attributes } // Attributes provides a goroutine-safe implementation of AttributeMap. type Attributes struct { - data sync.Map + data sync.Map // key: attribute name (string), value: attribute value (opaque, Cloneable) } // NewAttributes returns a new instance of Attributes. @@ -76,7 +75,7 @@ func (a *Attributes) Keys() []string { return keys } -// Clone creates a deep copy of the entire Attributes map. +// Clone creates a deep copy of the entire attribute map. func (a *Attributes) Clone() *Attributes { clone := NewAttributes() a.data.Range(func(key, value any) bool { diff --git a/pkg/epp/datalayer/collector.go b/pkg/epp/datalayer/collector.go new file mode 100644 index 000000000..94aa9b6bd --- /dev/null +++ b/pkg/epp/datalayer/collector.go @@ -0,0 +1,137 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package datalayer + +import ( + "context" + "errors" + "sync" + "time" + + "sigs.k8s.io/controller-runtime/pkg/log" + + "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/logging" +) + +// TODO: +// currently the data store is expected to manage the state of multiple +// Collectors (e.g., using sync.Map mapping pod to its Collector). Alternatively, +// this can be encapsulated in this file, providing the data store with an interface +// to only update on endpoint addition/change and deletion. This can also be used +// to centrally track statistics such errors, active routines, etc. + +const ( + defaultCollectionTimeout = time.Second +) + +// Ticker implements a time source for periodic invocation. +// The Ticker is passed in as parameter a Collector to allow control over time +// progress in tests, ensuring tests are deterministic and fast. +type Ticker interface { + Channel() <-chan time.Time + Stop() +} + +// TimeTicker implements a Ticker based on time.Ticker. +type TimeTicker struct { + *time.Ticker +} + +// NewTimeTicker returns a new time.Ticker with the configured duration. +func NewTimeTicker(d time.Duration) Ticker { + return &TimeTicker{ + Ticker: time.NewTicker(d), + } +} + +// Channel exposes the ticker's channel. +func (t *TimeTicker) Channel() <-chan time.Time { + return t.C +} + +// Collector runs the data collection for a single endpoint. +type Collector struct { + // per-endpoint context and cancellation + ctx context.Context + cancel context.CancelFunc + + // goroutine management + startOnce sync.Once + stopOnce sync.Once + + // TODO: optional metrics tracking collection (e.g., errors, invocations, ...) +} + +// NewCollector returns a new collector. +func NewCollector() *Collector { + return &Collector{} +} + +// Start initiates data source collection for the endpoint. +func (c *Collector) Start(ctx context.Context, ticker Ticker, ep Endpoint, sources []DataSource) error { + started := false + c.startOnce.Do(func() { + c.ctx, c.cancel = context.WithCancel(ctx) + started = true + + go func(endpoint Endpoint, sources []DataSource) { + logger := log.FromContext(ctx).WithValues("endpoint", ep.GetPod().GetIPAddress()) + logger.V(logging.DEFAULT).Info("starting collection") + + defer func() { + logger.V(logging.DEFAULT).Info("terminating collection") + ticker.Stop() + }() + + for { + select { + case <-c.ctx.Done(): // per endpoint context cancelled + return + case <-ticker.Channel(): + for _, src := range sources { + ctx, cancel := context.WithTimeout(c.ctx, defaultCollectionTimeout) + _ = src.Collect(ctx, endpoint) // TODO: track errors per collector? + cancel() // release the ctx timeout resources + } + } + } + }(ep, sources) + }) + + if !started { + return errors.New("collector start called multiple times") + } + return nil +} + +// Stop terminates the collector. +func (c *Collector) Stop() error { + if c.ctx == nil || c.cancel == nil { + return errors.New("collector stop called before start") + } + + stopped := false + c.stopOnce.Do(func() { + stopped = true + c.cancel() + }) + + if !stopped { + return errors.New("collector stop called multiple times") + } + return nil +} diff --git a/pkg/epp/datalayer/collector_test.go b/pkg/epp/datalayer/collector_test.go new file mode 100644 index 000000000..b5f348d24 --- /dev/null +++ b/pkg/epp/datalayer/collector_test.go @@ -0,0 +1,130 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package datalayer + +import ( + "context" + "sync/atomic" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datalayer/mocks" +) + +// --- Test Stubs --- + +type DummySource struct { + callCount int64 +} + +func (d *DummySource) Name() string { return "test-dummy-data-source" } +func (d *DummySource) AddExtractor(_ Extractor) error { return nil } +func (d *DummySource) Collect(ctx context.Context, ep Endpoint) error { + atomic.AddInt64(&d.callCount, 1) + return nil +} + +func defaultEndpoint() Endpoint { + ms := NewEndpoint() + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "pod-name", + Namespace: "default", + }, + Status: corev1.PodStatus{ + PodIP: "1.2.3.4", + }, + } + ms.UpdatePod(pod) + return ms +} + +// --- Tests --- + +var ( + endpoint = defaultEndpoint() + sources = []DataSource{&DummySource{}} +) + +func TestCollectorCanStartOnlyOnce(t *testing.T) { + c := NewCollector() + ctx := context.Background() + ticker := mocks.NewTicker() + + err := c.Start(ctx, ticker, endpoint, sources) + require.NoError(t, err, "first Start call should succeed") + + err = c.Start(ctx, ticker, endpoint, sources) + assert.Error(t, err, "multiple collector start should error") +} + +func TestCollectorStopBeforeStartIsAnError(t *testing.T) { + c := NewCollector() + err := c.Stop() + assert.Error(t, err, "collector stop called before start should error") +} + +func TestCollectorCanStopOnlyOnce(t *testing.T) { + c := NewCollector() + ctx := context.Background() + ticker := mocks.NewTicker() + + require.NoError(t, c.Start(ctx, ticker, endpoint, sources)) + require.NoError(t, c.Stop(), "first Stop should succeed") + assert.Error(t, c.Stop(), "second Stop should fail") +} + +func TestCollectorCollectsOnTicks(t *testing.T) { + source := &DummySource{} + c := NewCollector() + ticker := mocks.NewTicker() + ctx := context.Background() + require.NoError(t, c.Start(ctx, ticker, endpoint, []DataSource{source})) + + ticker.Tick() + ticker.Tick() + time.Sleep(20 * time.Millisecond) // let collector process the ticks + + got := atomic.LoadInt64(&source.callCount) + want := int64(2) + assert.Equal(t, want, got, "call count mismatch") + require.NoError(t, c.Stop()) +} + +func TestCollectorStopCancelsContext(t *testing.T) { + source := &DummySource{} + c := NewCollector() + ticker := mocks.NewTicker() + ctx := context.Background() + + require.NoError(t, c.Start(ctx, ticker, endpoint, []DataSource{source})) + ticker.Tick() // should be processed + time.Sleep(20 * time.Millisecond) + + require.NoError(t, c.Stop()) + before := atomic.LoadInt64(&source.callCount) + + ticker.Tick() + time.Sleep(20 * time.Millisecond) // let collector run again + after := atomic.LoadInt64(&source.callCount) + assert.Equal(t, before, after, "call count changed after stop") +} diff --git a/pkg/epp/datalayer/datasource.go b/pkg/epp/datalayer/datasource.go index 9539351fc..6ad7b290d 100644 --- a/pkg/epp/datalayer/datasource.go +++ b/pkg/epp/datalayer/datasource.go @@ -17,6 +17,7 @@ limitations under the License. package datalayer import ( + "context" "errors" "fmt" "reflect" @@ -36,7 +37,7 @@ type DataSource interface { // Collect is triggered by the data layer framework to fetch potentially new // data for an endpoint. Collect calls registered Extractors to convert the // raw data into structured attributes. - Collect(ep Endpoint) + Collect(ctx context.Context, ep Endpoint) error } // Extractor transforms raw data into structured attributes. @@ -46,7 +47,7 @@ type Extractor interface { ExpectedInputType() reflect.Type // Extract transforms the raw data source output into a concrete structured // attribute, stored on the given endpoint. - Extract(data any, ep Endpoint) + Extract(ctx context.Context, data any, ep Endpoint) error } var defaultDataSources = DataSourceRegistry{} diff --git a/pkg/epp/datalayer/datasource_test.go b/pkg/epp/datalayer/datasource_test.go index c5e7cd549..90919cc16 100644 --- a/pkg/epp/datalayer/datasource_test.go +++ b/pkg/epp/datalayer/datasource_test.go @@ -17,6 +17,7 @@ limitations under the License. package datalayer import ( + "context" "reflect" "testing" @@ -27,9 +28,9 @@ type mockDataSource struct { name string } -func (m *mockDataSource) Name() string { return m.name } -func (m *mockDataSource) AddExtractor(_ Extractor) error { return nil } -func (m *mockDataSource) Collect(_ Endpoint) {} +func (m *mockDataSource) Name() string { return m.name } +func (m *mockDataSource) AddExtractor(_ Extractor) error { return nil } +func (m *mockDataSource) Collect(_ context.Context, _ Endpoint) error { return nil } func TestRegisterAndGetSource(t *testing.T) { reg := DataSourceRegistry{} diff --git a/pkg/epp/datalayer/endpoint.go b/pkg/epp/datalayer/endpoint.go index 74c0c0eb1..31f24c222 100644 --- a/pkg/epp/datalayer/endpoint.go +++ b/pkg/epp/datalayer/endpoint.go @@ -17,6 +17,9 @@ limitations under the License. package datalayer import ( + "fmt" + "sync/atomic" + corev1 "k8s.io/api/core/v1" ) @@ -38,3 +41,60 @@ type Endpoint interface { EndpointMetricsState AttributeMap } + +// ModelServer is an implementation of the Endpoint interface. +type ModelServer struct { + pod atomic.Pointer[PodInfo] + metrics atomic.Pointer[Metrics] + attributes *Attributes +} + +// NewEndpoint return a new (uninitialized) ModelServer. +func NewEndpoint() *ModelServer { + return &ModelServer{ + attributes: NewAttributes(), + } +} + +// String returns a representation of the ModelServer. For brevity, only names of +// extended attributes are returned and not the values. +func (srv *ModelServer) String() string { + return fmt.Sprintf("Pod: %v; Metrics: %v; Attributes: %v", srv.GetPod(), srv.GetMetrics(), srv.Keys()) +} + +func (srv *ModelServer) GetPod() *PodInfo { + return srv.pod.Load() +} + +func (srv *ModelServer) UpdatePod(pod *corev1.Pod) { + srv.pod.Store(ToPodInfo(pod)) +} + +func (srv *ModelServer) GetMetrics() *Metrics { + return srv.metrics.Load() +} + +func (srv *ModelServer) UpdateMetrics(metrics *Metrics) { + srv.metrics.Store(metrics) +} + +func (srv *ModelServer) Put(key string, value Cloneable) { + srv.attributes.Put(key, value) +} + +func (srv *ModelServer) Get(key string) (Cloneable, bool) { + return srv.attributes.Get(key) +} + +func (srv *ModelServer) Keys() []string { + return srv.attributes.Keys() +} + +func (srv *ModelServer) Clone() *ModelServer { + clone := &ModelServer{ + attributes: srv.attributes.Clone(), + } + clone.pod.Store(srv.pod.Load().Clone()) + clone.metrics.Store(srv.metrics.Load().Clone()) + return clone +} diff --git a/pkg/epp/datalayer/metrics/client.go b/pkg/epp/datalayer/metrics/client.go new file mode 100644 index 000000000..7961b9247 --- /dev/null +++ b/pkg/epp/datalayer/metrics/client.go @@ -0,0 +1,83 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/prometheus/common/expfmt" + + "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datalayer" +) + +// Client is an interface for retrieving the metrics from an endpoint URL. +type Client interface { + Get(ctx context.Context, target *url.URL, ep datalayer.Addressable) (PrometheusMetricMap, error) +} + +// -- package implementations -- +const ( + maxIdleConnections = 5000 + maxIdleTime = 10 * time.Second + timeout = 10 * time.Second +) + +var ( + defaultClient = &client{ + Client: http.Client{ + Timeout: timeout, + Transport: &http.Transport{ + MaxIdleConns: maxIdleConnections, + MaxIdleConnsPerHost: 4, // host is defined as scheme://host:port + }, + // TODO: set additional timeouts, transport options, etc. + }, + } +) + +type client struct { + http.Client +} + +func (cl *client) Get(ctx context.Context, target *url.URL, ep datalayer.Addressable) (PrometheusMetricMap, error) { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, target.String(), nil) + if err != nil { + return nil, fmt.Errorf("failed to create request: %v", err) + } + resp, err := defaultClient.Do(req) + if err != nil { + return nil, fmt.Errorf("failed to fetch metrics from %s: %w", ep.GetNamespacedName(), err) + } + defer func() { + _ = resp.Body.Close() + }() + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected status code from %s: %v", ep.GetNamespacedName(), resp.StatusCode) + } + + parser := expfmt.TextParser{} + metricFamilies, err := parser.TextToMetricFamilies(resp.Body) + if err != nil { + return nil, err + } + return metricFamilies, err +} diff --git a/pkg/epp/datalayer/metrics/datasource.go b/pkg/epp/datalayer/metrics/datasource.go new file mode 100644 index 000000000..5ff7ef9bf --- /dev/null +++ b/pkg/epp/datalayer/metrics/datasource.go @@ -0,0 +1,118 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "context" + "errors" + "fmt" + "net" + "net/url" + "strconv" + "sync" + "sync/atomic" + + "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datalayer" +) + +const ( + dataSourceName = "metrics-data-source" +) + +// DataSource is a Model Server Protocol (MSP) compliant metrics data source, +// returning Prometheus formatted metrics for an endpoint. +type DataSource struct { + metricsScheme string // scheme to use in metrics URL + metricsPort atomic.Pointer[string] // target port to use in metrics URL + metricsPath string // path to use in metrics URL + + client Client // client (e.g. a wrapped http.Client) used to get metrics + extractors sync.Map // key: name, value: extractor +} + +// NewDataSource returns a new MSP compliant metrics data source, configured with the provided +// client factory. If ClientFactory is nil, a default factory is used. +func NewDataSource(metricsScheme string, metricsPort int32, metricsPath string, cl Client) *DataSource { + if cl == nil { + cl = defaultClient + } + + dataSrc := &DataSource{ + metricsScheme: metricsScheme, + metricsPath: metricsPath, + client: cl, + } + dataSrc.SetPort(metricsPort) + return dataSrc +} + +// SetPort updates the port used for metrics scraping. +func (dataSrc *DataSource) SetPort(metricsPort int32) { + port := strconv.Itoa(int(metricsPort)) + dataSrc.metricsPort.Store(&port) +} + +// Name returns the metrics data source name. +func (dataSrc *DataSource) Name() string { + return dataSourceName +} + +// AddExtractor adds an extractor to the data source, validating it can process +// the metrics' data source output type. +func (dataSrc *DataSource) AddExtractor(extractor datalayer.Extractor) error { + if err := datalayer.ValidateExtractorType(PrometheusMetricType, extractor.ExpectedInputType()); err != nil { + return err + } + if _, loaded := dataSrc.extractors.LoadOrStore(extractor.Name(), extractor); loaded { + return fmt.Errorf("attempt to add extractor with duplicate name %s to %s", extractor.Name(), dataSrc.Name()) + } + return nil +} + +// Collect is triggered by the data layer framework to fetch potentially new +// MSP metrics data for an endpoint. +func (dataSrc *DataSource) Collect(ctx context.Context, ep datalayer.Endpoint) error { + target := dataSrc.getMetricsEndpoint(ep.GetPod()) + families, err := dataSrc.client.Get(ctx, target, ep.GetPod()) + + if err != nil { + return err + } + + var errs []error + dataSrc.extractors.Range(func(_, val any) bool { + if ex, ok := val.(datalayer.Extractor); ok { + if err = ex.Extract(ctx, families, ep); err != nil { + errs = append(errs, err) + } + } + return true // continue iteration + }) + + if len(errs) != 0 { + return errors.Join(errs...) + } + return nil +} + +func (dataSrc *DataSource) getMetricsEndpoint(ep datalayer.Addressable) *url.URL { + return &url.URL{ + Scheme: dataSrc.metricsScheme, + Host: net.JoinHostPort(ep.GetIPAddress(), *dataSrc.metricsPort.Load()), + Path: dataSrc.metricsPath, + } +} diff --git a/pkg/epp/datalayer/metrics/extractor.go b/pkg/epp/datalayer/metrics/extractor.go new file mode 100644 index 000000000..d7a75b16e --- /dev/null +++ b/pkg/epp/datalayer/metrics/extractor.go @@ -0,0 +1,155 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "context" + "errors" + "fmt" + "reflect" + "strconv" + "strings" + "time" + + dto "github.com/prometheus/client_model/go" + + "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datalayer" +) + +const ( + extractorName = "model-server-protocol-metrics" + + // LoRA metrics based on MSP + LoraInfoRunningAdaptersMetricName = "running_lora_adapters" + LoraInfoWaitingAdaptersMetricName = "waiting_lora_adapters" + LoraInfoMaxAdaptersMetricName = "max_lora" +) + +// Extractor implements the metrics extraction based on the model +// server protocol standard. +type Extractor struct { + mapping *Mapping +} + +// NewExtractor returns a new model server protocol (MSP) metrics extractor, +// configured with the given metrics' specifications. +// These are mandatory metrics per the MSP specification, and are used +// as the basis for the built-in scheduling plugins. +func NewExtractor(queueSpec, kvusageSpec, loraSpec string) (*Extractor, error) { + mapping, err := NewMapping(queueSpec, kvusageSpec, loraSpec) + if err != nil { + return nil, fmt.Errorf("failed to create extractor metrics Mapping - %w", err) + } + return &Extractor{ + mapping: mapping, + }, nil +} + +// Name returns the name of the metrics.Extractor. +func (ext *Extractor) Name() string { + return extractorName +} + +// ExpectedType defines the type expected by the metrics.Extractor - a +// parsed output from a Prometheus metrics endpoint. +func (ext *Extractor) ExpectedInputType() reflect.Type { + return PrometheusMetricType +} + +// Extract transforms the data source output into a concrete attribute that +// is stored on the given endpoint. +func (ext *Extractor) Extract(ctx context.Context, data any, ep datalayer.Endpoint) error { + families, ok := data.(PrometheusMetricMap) + if !ok { + return fmt.Errorf("unexpected input in Extract: %T", data) + } + + var errs []error + current := ep.GetMetrics() + clone := current.Clone() + updated := false + + if spec := ext.mapping.TotalQueuedRequests; spec != nil { // extract queued requests + if metric, err := spec.getLatestMetric(families); err != nil { + errs = append(errs, err) + } else { + clone.WaitingQueueSize = int(extractValue(metric)) + updated = true + } + } + + if spec := ext.mapping.KVCacheUtilization; spec != nil { // extract KV cache usage + if metric, err := spec.getLatestMetric(families); err != nil { + errs = append(errs, err) + } else { + clone.KVCacheUsagePercent = extractValue(metric) + updated = true + } + } + + if spec := ext.mapping.LoraRequestInfo; spec != nil { // extract LoRA-specific metrics + metric, err := spec.getLatestMetric(families) + if err != nil { + errs = append(errs, err) + } else if metric != nil { + populateLoRAMetrics(clone, metric, &errs) + updated = true + } + } + + if updated { + clone.UpdateTime = time.Now() + ep.UpdateMetrics(clone) + } + + if len(errs) != 0 { + return errors.Join(errs...) + } + return nil +} + +// populateLoRAMetrics updates the metrics with LoRA adapter info from the metric labels. +func populateLoRAMetrics(clone *datalayer.Metrics, metric *dto.Metric, errs *[]error) { + clone.ActiveModels = map[string]int{} + clone.WaitingModels = map[string]int{} + + for _, label := range metric.GetLabel() { + switch label.GetName() { + case LoraInfoRunningAdaptersMetricName: + addAdapters(clone.ActiveModels, label.GetValue()) + case LoraInfoWaitingAdaptersMetricName: + addAdapters(clone.WaitingModels, label.GetValue()) + case LoraInfoMaxAdaptersMetricName: + if label.GetValue() != "" { + if val, err := strconv.Atoi(label.GetValue()); err == nil { + clone.MaxActiveModels = val + } else { + *errs = append(*errs, err) + } + } + } + } +} + +// addAdapters splits a comma-separated adapter list and stores keys with default value 0. +func addAdapters(m map[string]int, csv string) { + for _, name := range strings.Split(csv, ",") { + if trimmed := strings.TrimSpace(name); trimmed != "" { + m[trimmed] = 0 + } + } +} diff --git a/pkg/epp/datalayer/metrics/loraspec.go b/pkg/epp/datalayer/metrics/loraspec.go new file mode 100644 index 000000000..fa9503f08 --- /dev/null +++ b/pkg/epp/datalayer/metrics/loraspec.go @@ -0,0 +1,73 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "fmt" + + dto "github.com/prometheus/client_model/go" +) + +// LoRASpec extends the standard Spec to allow special case +// handling for retrieving the latest metrics value for LoRAs. +type LoRASpec struct { + *Spec +} + +// parseStringToLoRASpec parses the metric specification but +// wraps the return in a LoRASpec. +func parseStringToLoRASpec(spec string) (*LoRASpec, error) { + baseSpec, err := parseStringToSpec(spec) + if err != nil { + return nil, err + } + return &LoRASpec{ + Spec: baseSpec, + }, nil +} + +// getLatestMetric retrieves the latest LoRA metric based on Spec. +// We can't use the standard Spec method since, in the case of +// LoRA (i.e., `vllm:lora_requests_info`), each label key-value pair permutation +// generates new series and only most recent should be used. The value of each +// series is its creation timestamp so we can retrieve the latest by sorting on +// that the value first. +func (spec *LoRASpec) getLatestMetric(families PrometheusMetricMap) (*dto.Metric, error) { + family, err := extractFamily(spec.Spec, families) + if err != nil { + return nil, err + } + + var latest *dto.Metric + var recent float64 = -1 + + for _, metric := range family.GetMetric() { + if spec.labelsMatch(metric.GetLabel()) { + value := extractValue(metric) // metric value is its creation timestamp + if value > recent { + recent = value + latest = metric + } + } + } + + if latest == nil { + return nil, fmt.Errorf("no matching lora metric found for %q with labels %v", spec.Name, spec.Labels) + } + + return latest, nil +} diff --git a/pkg/epp/datalayer/metrics/mapping.go b/pkg/epp/datalayer/metrics/mapping.go new file mode 100644 index 000000000..1c3c3827d --- /dev/null +++ b/pkg/epp/datalayer/metrics/mapping.go @@ -0,0 +1,55 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "errors" +) + +// Mapping holds specifications for the well-known metrics defined +// in the Model Server Protocol. +type Mapping struct { + TotalQueuedRequests *Spec + KVCacheUtilization *Spec + LoraRequestInfo *LoRASpec +} + +// NewMapping creates a metrics.Mapping from the input specification strings. +func NewMapping(queue, kvusage, lora string) (*Mapping, error) { + var errs []error + + queueSpec, err := parseStringToSpec(queue) + if err != nil { + errs = append(errs, err) + } + kvusageSpec, err := parseStringToSpec(kvusage) + if err != nil { + errs = append(errs, err) + } + loraSpec, err := parseStringToLoRASpec(lora) + if err != nil { + errs = append(errs, err) + } + if len(errs) != 0 { + return nil, errors.Join(errs...) + } + return &Mapping{ + TotalQueuedRequests: queueSpec, + KVCacheUtilization: kvusageSpec, + LoraRequestInfo: loraSpec, + }, nil +} diff --git a/pkg/epp/datalayer/metrics/spec.go b/pkg/epp/datalayer/metrics/spec.go new file mode 100644 index 000000000..a079c135e --- /dev/null +++ b/pkg/epp/datalayer/metrics/spec.go @@ -0,0 +1,157 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "errors" + "fmt" + "regexp" + "strings" + + dto "github.com/prometheus/client_model/go" + "github.com/prometheus/prometheus/model/labels" + "github.com/prometheus/prometheus/promql/parser" +) + +// Spec represents a single metric's specification. +type Spec struct { + Name string // the metric's name + Labels map[string]string // maps metric's label name to value +} + +// parseStringToSpec converts a string to a metrics.Spec. +// Inputs are expected in PromQL Instant Vector Selector syntax: +// metric_name{label1=value1,label2=value2}, where labels are optional. +func parseStringToSpec(spec string) (*Spec, error) { + if spec == "" { + return nil, nil // allow empty string to represent the nil Spec + } + + // Be liberal in accepting inputs that are missing quotes around label values, + // allowing both {label=value} and {label=\"value\"} inputs + quoted := addQuotesToLabelValues(spec) + expr, err := parser.ParseExpr(quoted) + if err != nil { + return nil, err + } + + // cast to prometheus' VectorSelector to extract metric name and labels + if vs, ok := expr.(*parser.VectorSelector); ok { + metricLabels := make(map[string]string) + for _, matcher := range vs.LabelMatchers { + // do not insert pseudo labels (such as __name__, __meta_*, etc.) + if matcher.Type == labels.MatchEqual && !strings.HasPrefix(matcher.Name, "__") { + metricLabels[matcher.Name] = matcher.Value + } + } + + if vs.Name == "" { + return nil, fmt.Errorf("empty metric name in specification: %q", spec) + } + return &Spec{ + Name: vs.Name, + Labels: metricLabels, + }, nil + } + + return nil, errors.New("not a valid metric specification") +} + +// addQuotesToLabelValues wraps label values with quotes, if missing. +// TODO: compile regexp once as file scoped var? Seems that this won't be +// a performance hot spot. +func addQuotesToLabelValues(input string) string { + re := regexp.MustCompile(`(\w+)\s*=\s*([^",}\s]+)`) + return re.ReplaceAllString(input, `$1="$2"`) +} + +// extract the metric family is common to standard and LoRA spec's. +func extractFamily(spec *Spec, families PrometheusMetricMap) (*dto.MetricFamily, error) { + if spec == nil { + return nil, errors.New("metric specification is nil") + } + + family, exists := families[spec.Name] + if !exists { + return nil, fmt.Errorf("metric family %q not found", spec.Name) + } + + if len(family.GetMetric()) == 0 { + return nil, fmt.Errorf("no metrics found for %q", spec.Name) + } + return family, nil +} + +// getLatestMetric retrieves the latest metric based on Spec. +func (spec *Spec) getLatestMetric(families PrometheusMetricMap) (*dto.Metric, error) { + family, err := extractFamily(spec, families) + if err != nil { + return nil, err + } + + var latest *dto.Metric + var recent int64 = -1 + + for _, metric := range family.GetMetric() { + if spec.labelsMatch(metric.GetLabel()) { + ts := metric.GetTimestampMs() + if ts > recent { + recent = ts + latest = metric + } + } + } + + if latest == nil { + return nil, fmt.Errorf("no matching metric found for %q with labels %v", spec.Name, spec.Labels) + } + + return latest, nil +} + +// labelsMatch checks if metric labels match the specification labels. +func (spec *Spec) labelsMatch(metricLabels []*dto.LabelPair) bool { + if len(spec.Labels) == 0 { + return true // no label requirements + } + + metricLabelMap := make(map[string]string) + for _, label := range metricLabels { + metricLabelMap[label.GetName()] = label.GetValue() + } + + // check if all spec labels match + for name, value := range spec.Labels { + if metricValue, exists := metricLabelMap[name]; !exists || metricValue != value { + return false + } + } + + return true +} + +// extractValue gets the numeric value from different metric types. +// Currently only Gauge and Counter are supported. +func extractValue(metric *dto.Metric) float64 { + if gauge := metric.GetGauge(); gauge != nil { + return gauge.GetValue() + } + if counter := metric.GetCounter(); counter != nil { + return counter.GetValue() + } + return 0 +} diff --git a/pkg/epp/datalayer/metrics/spec_test.go b/pkg/epp/datalayer/metrics/spec_test.go new file mode 100644 index 000000000..b4ad28509 --- /dev/null +++ b/pkg/epp/datalayer/metrics/spec_test.go @@ -0,0 +1,479 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "errors" + "strconv" + "strings" + "testing" + + dto "github.com/prometheus/client_model/go" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" +) + +// --- Test Helpers --- + +func makeMetric(labels map[string]string, value float64, timestampMs int64) *dto.Metric { + labelPairs := []*dto.LabelPair{} + for k, v := range labels { + labelPairs = append(labelPairs, &dto.LabelPair{Name: proto.String(k), Value: proto.String(v)}) + } + return &dto.Metric{ + Label: labelPairs, + Gauge: &dto.Gauge{Value: &value}, + TimestampMs: ×tampMs, + } +} + +func makeMetricFamily(name string, metrics ...*dto.Metric) *dto.MetricFamily { + return &dto.MetricFamily{ + Name: &name, + Type: dto.MetricType_GAUGE.Enum(), + Metric: metrics, + } +} + +// TestStringToMetricSpec determines parsing of metric's specification. +func TestStringToMetricSpec(t *testing.T) { + tests := []struct { + name string + input string + want *Spec + wantErr bool + }{ + { + name: "empty string", + input: "", + want: nil, + wantErr: false, + }, + { + name: "no labels", + input: "my_metric", + want: &Spec{ + Name: "my_metric", + Labels: map[string]string{}, + }, + wantErr: false, + }, + { + name: "one label", + input: "my_metric{label1=value1}", + want: &Spec{ + Name: "my_metric", + Labels: map[string]string{ + "label1": "value1", + }, + }, + wantErr: false, + }, + { + name: "label with quoted value", + input: "my_metric{label1=\"value1\"}", + want: &Spec{ + Name: "my_metric", + Labels: map[string]string{ + "label1": "value1", + }, + }, + wantErr: false, + }, + { + name: "multiple labels", + input: "my_metric{label1=value1,label2=value2}", + want: &Spec{ + Name: "my_metric", + Labels: map[string]string{ + "label1": "value1", + "label2": "value2", + }, + }, + wantErr: false, + }, + { + name: "extra whitespace", + input: " my_metric { label1 = value1 , label2 = value2 } ", + want: &Spec{ + Name: "my_metric", + Labels: map[string]string{ + "label1": "value1", + "label2": "value2", + }, + }, + wantErr: false, + }, + { + name: "missing closing brace", + input: "my_metric{label1=value1", + want: nil, + wantErr: true, + }, + { + name: "missing opening brace", + input: "my_metriclabel1=value1}", + want: nil, + wantErr: true, + }, + { + name: "invalid label pair", + input: "my_metric{label1}", + want: nil, + wantErr: true, + }, + { + name: "empty label name", + input: "my_metric{=value1}", + want: nil, + wantErr: true, + }, + { + name: "empty label value", + input: "my_metric{label1=}", + want: nil, + wantErr: true, + }, + { + name: "empty label name and value with spaces", + input: "my_metric{ = }", + want: nil, + wantErr: true, + }, + { + name: "characters after closing brace", + input: "my_metric{label=val}extra", + want: nil, + wantErr: true, + }, + { + name: "empty metric name", + input: "{label=val}", + want: nil, + wantErr: true, + }, + { + name: "no labels and just metric name with space", + input: "my_metric ", + want: &Spec{ + Name: "my_metric", + Labels: map[string]string{}, + }, + wantErr: false, + }, + { + name: "no labels and just metric name with space before and after", + input: " my_metric ", + want: &Spec{ + Name: "my_metric", + Labels: map[string]string{}, + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := parseStringToSpec(tt.input) + + if tt.wantErr { + assert.Error(t, err, "expected error but got none") + } else { + assert.NoError(t, err, "unexpected error from parseStringToSpec") + if tt.want != nil && got != nil { + assert.Equal(t, tt.want, got) + } else { + assert.Equal(t, tt.want, got, "expected and actual values don't match") + } + } + }) + } +} + +// TestGetMetric checks retrieving of standard metrics from a metric families. +func TestGetMetric(t *testing.T) { + metricFamilies := PrometheusMetricMap{ + "metric1": makeMetricFamily("metric1", + makeMetric(map[string]string{"label1": "value1"}, 1.0, 1000), + makeMetric(map[string]string{"label1": "value2"}, 2.0, 2000), + ), + "metric2": makeMetricFamily("metric2", + makeMetric(map[string]string{"labelA": "A1", "labelB": "B1"}, 3.0, 1500), + makeMetric(map[string]string{"labelA": "A2", "labelB": "B2"}, 4.0, 2500), + ), + "metric3": makeMetricFamily("metric3", + makeMetric(map[string]string{}, 5.0, 3000), + makeMetric(map[string]string{}, 6.0, 1000), + ), + } + + tests := []struct { + name string + spec Spec + expected float64 + wantError bool + }{ + { + name: "get labeled metric, exists", + spec: Spec{ + Name: "metric1", + Labels: map[string]string{"label1": "value1"}, + }, + expected: 1.0, + wantError: false, + }, + { + name: "get labeled metric, wrong value", + spec: Spec{ + Name: "metric1", + Labels: map[string]string{"label1": "value3"}, + }, + expected: -1, // Expect an error, not a specific value + wantError: true, + }, + { + name: "get labeled metric, missing label", + spec: Spec{ + Name: "metric1", + Labels: map[string]string{"label2": "value2"}, + }, + expected: -1, + wantError: true, + }, + { + name: "get labeled metric, extra label present", + spec: Spec{ + Name: "metric2", + Labels: map[string]string{"labelA": "A1"}, + }, + expected: 3.0, + wantError: false, + }, + { + name: "get unlabeled metric, exists", + spec: Spec{ + Name: "metric3", + Labels: nil, // Explicitly nil + }, + expected: 5.0, // latest metric, which occurs first in our test data + wantError: false, + }, + { + name: "get unlabeled metric, metric family not found", + spec: Spec{ + Name: "metric4", + Labels: nil, + }, + expected: -1, + wantError: true, + }, + { + name: "get labeled metric, metric family not found", + spec: Spec{ + Name: "metric4", + Labels: map[string]string{"label1": "value1"}, + }, + expected: -1, + wantError: true, + }, + { + name: "get metric, no metrics available", + spec: Spec{ + Name: "empty_metric", + }, + expected: -1, + wantError: true, + }, + { + name: "get latest metric", + spec: Spec{ + Name: "metric3", + Labels: map[string]string{}, // Empty map, not nil + }, + expected: 5.0, + wantError: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + metric, err := tt.spec.getLatestMetric(metricFamilies) + if tt.wantError { + assert.Error(t, err, "expected error but got nil") + } else { + require.NoError(t, err, "unexpected error from getLatestMetric") + value := extractValue(metric) + assert.Equal(t, tt.expected, value, "metric value mismatch") + } + }) + } +} + +func TestGetLoRAMetric(t *testing.T) { + loraSpec := &LoRASpec{ + Spec: &Spec{ + Name: "vllm:lora_requests_info", + }, + } + + testCases := []struct { + name string + metricFamilies PrometheusMetricMap + expectedAdapters map[string]int + expectedMax int + expectedErr error + spec *LoRASpec + }{ + { + name: "no lora metrics", + metricFamilies: PrometheusMetricMap{ + "some_other_metric": makeMetricFamily("some_other_metric", + makeMetric(nil, 1.0, 1000), + ), + }, + expectedAdapters: map[string]int{}, + expectedMax: 0, + expectedErr: errors.New("metric family \"vllm:lora_requests_info\" not found"), // Expect an error because the family is missing + spec: loraSpec, + }, + { + name: "basic lora metrics", + metricFamilies: PrometheusMetricMap{ + "vllm:lora_requests_info": makeMetricFamily("vllm:lora_requests_info", + makeMetric(map[string]string{"running_lora_adapters": "lora1", "max_lora": "2"}, 3000.0, 1000), // Newer + makeMetric(map[string]string{"running_lora_adapters": "lora2,lora3", "max_lora": "4"}, 1000.0, 1000), // Older + + ), + }, + expectedAdapters: map[string]int{"lora1": 0}, + expectedMax: 2, + expectedErr: nil, + spec: loraSpec, + }, + { + name: "no matching lora metrics", + metricFamilies: PrometheusMetricMap{ + "vllm:lora_requests_info": makeMetricFamily("vllm:lora_requests_info", + makeMetric(map[string]string{"other_label": "value"}, 5.0, 3000), + ), + }, + expectedAdapters: map[string]int{}, + expectedMax: 0, + expectedErr: nil, // Expect *no* error; just no adapters found + spec: loraSpec, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + metric, err := tc.spec.getLatestMetric(tc.metricFamilies) + + if tc.expectedErr != nil { + assert.Error(t, err) + assert.EqualError(t, err, tc.expectedErr.Error()) + return + } + + require.NoError(t, err) + + if tc.spec == nil { + assert.Nil(t, metric) + return + } + + if tc.expectedAdapters == nil && metric == nil { + return + } + + require.NotNil(t, metric, "expected non-nil metric") + + adaptersFound := make(map[string]int) + maxLora := 0 + + for _, label := range metric.GetLabel() { + switch label.GetName() { + case "running_lora_adapters", "waiting_lora_adapters": + if label.GetValue() != "" { + for _, adapter := range strings.Split(label.GetValue(), ",") { + adaptersFound[adapter] = 0 + } + } + case "max_lora": + parsed, parseErr := strconv.Atoi(label.GetValue()) + require.NoError(t, parseErr, "failed to parse max_lora") + maxLora = parsed + } + } + + assert.Equal(t, tc.expectedAdapters, adaptersFound, "adapters mismatch") + assert.Equal(t, tc.expectedMax, maxLora, "maxLora mismatch") + }) + } +} + +func TestLabelsMatch(t *testing.T) { + tests := []struct { + name string + metricLabels []*dto.LabelPair + spec *Spec + want bool + }{ + { + name: "empty spec labels, should match", + metricLabels: []*dto.LabelPair{{Name: proto.String("a"), Value: proto.String("b")}}, + spec: &Spec{Labels: map[string]string{}}, + want: true, + }, + { + name: "nil spec labels, should match", + metricLabels: []*dto.LabelPair{{Name: proto.String("a"), Value: proto.String("b")}}, + spec: &Spec{}, + want: true, + }, + { + name: "exact match", + metricLabels: []*dto.LabelPair{{Name: proto.String("a"), Value: proto.String("b")}}, + spec: &Spec{Labels: map[string]string{"a": "b"}}, + want: true, + }, + { + name: "extra labels in metric", + metricLabels: []*dto.LabelPair{{Name: proto.String("a"), Value: proto.String("b")}, {Name: proto.String("c"), Value: proto.String("d")}}, + spec: &Spec{Labels: map[string]string{"a": "b"}}, + want: true, + }, + { + name: "missing label in metric", + metricLabels: []*dto.LabelPair{{Name: proto.String("a"), Value: proto.String("b")}}, + spec: &Spec{Labels: map[string]string{"a": "b", "c": "d"}}, + want: false, + }, + { + name: "value mismatch", + metricLabels: []*dto.LabelPair{{Name: proto.String("a"), Value: proto.String("b")}}, + spec: &Spec{Labels: map[string]string{"a": "c"}}, + want: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := tt.spec.labelsMatch(tt.metricLabels) + assert.Equal(t, tt.want, got, "labelsMatch() mismatch") + }) + } +} diff --git a/pkg/epp/datalayer/metrics/types.go b/pkg/epp/datalayer/metrics/types.go new file mode 100644 index 000000000..9ee13b301 --- /dev/null +++ b/pkg/epp/datalayer/metrics/types.go @@ -0,0 +1,29 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "reflect" + + dto "github.com/prometheus/client_model/go" +) + +type PrometheusMetricMap = map[string]*dto.MetricFamily + +var ( + PrometheusMetricType = reflect.TypeOf(PrometheusMetricMap{}) +) diff --git a/pkg/epp/datalayer/mocks/ticker.go b/pkg/epp/datalayer/mocks/ticker.go new file mode 100644 index 000000000..751704dfc --- /dev/null +++ b/pkg/epp/datalayer/mocks/ticker.go @@ -0,0 +1,45 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package mocks + +import ( + "time" +) + +// -- Ticker is a mock time source -- +type Ticker struct { + ch chan time.Time +} + +func NewTicker() *Ticker { + return &Ticker{ + ch: make(chan time.Time, 10), + } +} + +func (t *Ticker) Channel() <-chan time.Time { + return t.ch +} + +func (t *Ticker) Tick() { + select { + case t.ch <- time.Now(): + default: // if buffer is full, or channel closed + } +} + +func (t *Ticker) Stop() {}