Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to admiral IPAM #3145

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.22.0
require (
github.com/cenkalti/backoff/v4 v4.3.0
github.com/coreos/go-iptables v0.7.0
github.com/emirpasic/gods v1.18.1
github.com/kelseyhightower/envconfig v1.4.0
github.com/onsi/ginkgo/v2 v2.20.1
github.com/onsi/gomega v1.34.1
Expand All @@ -14,8 +13,8 @@ require (
github.com/pkg/errors v0.9.1
github.com/projectcalico/api v0.0.0-20230602153125-fb7148692637
github.com/prometheus-community/pro-bing v0.4.1
github.com/prometheus/client_golang v1.19.1
github.com/submariner-io/admiral v0.19.0-m2.0.20240819074554-489d309b67d9
github.com/prometheus/client_golang v1.20.2
github.com/submariner-io/admiral v0.19.0-m2.0.20240830124517-c377f350bf46
github.com/submariner-io/shipyard v0.19.0-m2.0.20240828133900-3d3c2316f606
github.com/vishvananda/netlink v1.3.0
golang.org/x/net v0.28.0
Expand All @@ -40,6 +39,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
Expand All @@ -61,6 +61,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
Expand Down
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand All @@ -280,6 +282,8 @@ github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffktY=
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
Expand Down Expand Up @@ -376,8 +380,8 @@ github.com/prometheus-community/pro-bing v0.4.1/go.mod h1:aLsw+zqCaDoa2RLVVSX3+U
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down Expand Up @@ -440,8 +444,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/submariner-io/admiral v0.19.0-m2.0.20240819074554-489d309b67d9 h1:fHQMyLyHCQQl29rW4Plt8Wuq46d2rBK1+cWgGuRf4Dg=
github.com/submariner-io/admiral v0.19.0-m2.0.20240819074554-489d309b67d9/go.mod h1:f4xzFML4SRqETWcyZ32iTy8DH0gLUt2+jrYu6VGXL4Q=
github.com/submariner-io/admiral v0.19.0-m2.0.20240830124517-c377f350bf46 h1:tFoPJtTD13X3xERe6UAJyph3hG00nX8UgdrkMNMu4TM=
github.com/submariner-io/admiral v0.19.0-m2.0.20240830124517-c377f350bf46/go.mod h1:mcqVtEdczVZPmqCzNsRwnPF3uSrqWLKUyQSs79J1MN8=
github.com/submariner-io/shipyard v0.19.0-m2.0.20240828133900-3d3c2316f606 h1:0C59+84WEc0n8yuFCL4xNKmDhAZ5o/cGLiIzZy1It/s=
github.com/submariner-io/shipyard v0.19.0-m2.0.20240828133900-3d3c2316f606/go.mod h1:Ith3HTqWhsEMmq26xw66OFYlGWO0p9Id86Cw0MIFbqQ=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
Expand Down
2 changes: 1 addition & 1 deletion pkg/globalnet/controllers/base_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (

"github.com/pkg/errors"
"github.com/submariner-io/admiral/pkg/federate"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/util"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
pfiface "github.com/submariner-io/submariner/pkg/globalnet/controllers/packetfilter"
"github.com/submariner-io/submariner/pkg/ipam"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down
2 changes: 1 addition & 1 deletion pkg/globalnet/controllers/cluster_egressip_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import (

"github.com/pkg/errors"
"github.com/submariner-io/admiral/pkg/federate"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/log"
"github.com/submariner-io/admiral/pkg/syncer"
"github.com/submariner-io/admiral/pkg/util"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"github.com/submariner-io/submariner/pkg/globalnet/constants"
"github.com/submariner-io/submariner/pkg/globalnet/controllers/packetfilter"
"github.com/submariner-io/submariner/pkg/globalnet/metrics"
"github.com/submariner-io/submariner/pkg/ipam"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/syncer"
"github.com/submariner-io/admiral/pkg/syncer/test"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"github.com/submariner-io/submariner/pkg/globalnet/constants"
"github.com/submariner-io/submariner/pkg/globalnet/controllers"
"github.com/submariner-io/submariner/pkg/ipam"
"github.com/submariner-io/submariner/pkg/globalnet/metrics"
"github.com/submariner-io/submariner/pkg/packetfilter"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -365,7 +366,7 @@ func newClusterGlobalEgressIPControllerTestDriver() *clusterGlobalEgressIPContro

var err error

t.pool, err = ipam.NewIPPool(t.globalCIDR)
t.pool, err = ipam.NewIPPool(t.globalCIDR, metrics.GlobalnetMetricsReporter)
Expect(err).To(Succeed())
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/globalnet/controllers/controllers_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
. "github.com/onsi/gomega"
"github.com/onsi/gomega/format"
fakeDynClient "github.com/submariner-io/admiral/pkg/fake"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/log/kzerolog"
"github.com/submariner-io/admiral/pkg/resource"
"github.com/submariner-io/admiral/pkg/syncer/test"
Expand All @@ -39,7 +40,6 @@ import (
"github.com/submariner-io/submariner/pkg/cni"
"github.com/submariner-io/submariner/pkg/globalnet/constants"
"github.com/submariner-io/submariner/pkg/globalnet/controllers"
"github.com/submariner-io/submariner/pkg/ipam"
"github.com/submariner-io/submariner/pkg/packetfilter"
fakePF "github.com/submariner-io/submariner/pkg/packetfilter/fake"
routeAgent "github.com/submariner-io/submariner/pkg/routeagent_driver/constants"
Expand Down
2 changes: 1 addition & 1 deletion pkg/globalnet/controllers/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (

"github.com/pkg/errors"
"github.com/submariner-io/admiral/pkg/federate"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/syncer"
admUtil "github.com/submariner-io/admiral/pkg/util"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"github.com/submariner-io/submariner/pkg/globalnet/constants"
"github.com/submariner-io/submariner/pkg/globalnet/controllers/packetfilter"
"github.com/submariner-io/submariner/pkg/ipam"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down
5 changes: 3 additions & 2 deletions pkg/globalnet/controllers/gateway_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/syncer"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"github.com/submariner-io/submariner/pkg/globalnet/constants"
"github.com/submariner-io/submariner/pkg/globalnet/controllers"
"github.com/submariner-io/submariner/pkg/ipam"
"github.com/submariner-io/submariner/pkg/globalnet/metrics"
"github.com/submariner-io/submariner/pkg/packetfilter"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -144,7 +145,7 @@ func newGatewayControllerTestDriver() *gatewayControllerTestDriver {

var err error

t.pool, err = ipam.NewIPPool(t.globalCIDR)
t.pool, err = ipam.NewIPPool(t.globalCIDR, metrics.GlobalnetMetricsReporter)
Expect(err).To(Succeed())

t.localCIDRs = []string{localCIDR}
Expand Down
5 changes: 3 additions & 2 deletions pkg/globalnet/controllers/gateway_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/pkg/errors"
"github.com/submariner-io/admiral/pkg/federate"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/log"
"github.com/submariner-io/admiral/pkg/syncer"
"github.com/submariner-io/admiral/pkg/syncer/broker"
Expand All @@ -36,7 +37,7 @@ import (
"github.com/submariner-io/submariner/pkg/event/controller"
"github.com/submariner-io/submariner/pkg/globalnet/constants"
gnpacketfilter "github.com/submariner-io/submariner/pkg/globalnet/controllers/packetfilter"
"github.com/submariner-io/submariner/pkg/ipam"
"github.com/submariner-io/submariner/pkg/globalnet/metrics"
"github.com/submariner-io/submariner/pkg/netlink"
"github.com/submariner-io/submariner/pkg/packetfilter"
routeAgent "github.com/submariner-io/submariner/pkg/routeagent_driver/constants"
Expand Down Expand Up @@ -351,7 +352,7 @@ func (g *gatewayMonitor) startControllers() error {
return err
}

pool, err := ipam.NewIPPool(g.GatewayMonitorConfig.Spec.GlobalCIDR[0])
pool, err := ipam.NewIPPool(g.GatewayMonitorConfig.Spec.GlobalCIDR[0], metrics.GlobalnetMetricsReporter)
if err != nil {
return errors.Wrap(err, "error creating the IP pool")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/globalnet/controllers/global_egressip_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (

"github.com/pkg/errors"
"github.com/submariner-io/admiral/pkg/federate"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/syncer"
"github.com/submariner-io/admiral/pkg/util"
"github.com/submariner-io/admiral/pkg/watcher"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"github.com/submariner-io/submariner/pkg/globalnet/controllers/packetfilter"
"github.com/submariner-io/submariner/pkg/globalnet/metrics"
"github.com/submariner-io/submariner/pkg/ipam"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
fakeDynClient "github.com/submariner-io/admiral/pkg/fake"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/syncer"
"github.com/submariner-io/admiral/pkg/syncer/test"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"github.com/submariner-io/submariner/pkg/globalnet/constants"
"github.com/submariner-io/submariner/pkg/globalnet/controllers"
"github.com/submariner-io/submariner/pkg/ipam"
"github.com/submariner-io/submariner/pkg/globalnet/metrics"
"github.com/submariner-io/submariner/pkg/packetfilter"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -597,7 +598,7 @@ func newGlobalEgressIPControllerTestDriver() *globalEgressIPControllerTestDriver

var err error

t.pool, err = ipam.NewIPPool(t.globalCIDR)
t.pool, err = ipam.NewIPPool(t.globalCIDR, metrics.GlobalnetMetricsReporter)
Expect(err).To(Succeed())

t.watches = fakeDynClient.NewWatchReactor(&t.dynClient.Fake)
Expand Down
2 changes: 1 addition & 1 deletion pkg/globalnet/controllers/global_ingressip_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
"github.com/pkg/errors"
"github.com/submariner-io/admiral/pkg/federate"
"github.com/submariner-io/admiral/pkg/finalizer"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/resource"
"github.com/submariner-io/admiral/pkg/syncer"
"github.com/submariner-io/admiral/pkg/util"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
pfiface "github.com/submariner-io/submariner/pkg/globalnet/controllers/packetfilter"
"github.com/submariner-io/submariner/pkg/globalnet/metrics"
"github.com/submariner-io/submariner/pkg/ipam"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/syncer"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"github.com/submariner-io/submariner/pkg/globalnet/constants"
"github.com/submariner-io/submariner/pkg/globalnet/controllers"
"github.com/submariner-io/submariner/pkg/ipam"
"github.com/submariner-io/submariner/pkg/globalnet/metrics"
"github.com/submariner-io/submariner/pkg/packetfilter"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -509,7 +510,7 @@ func newGlobalIngressIPControllerDriver() *globalIngressIPControllerTestDriver {

var err error

t.pool, err = ipam.NewIPPool(t.globalCIDR)
t.pool, err = ipam.NewIPPool(t.globalCIDR, metrics.GlobalnetMetricsReporter)
Expect(err).To(Succeed())
})

Expand Down
5 changes: 3 additions & 2 deletions pkg/globalnet/controllers/service_export_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/syncer"
"github.com/submariner-io/admiral/pkg/syncer/test"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"github.com/submariner-io/submariner/pkg/globalnet/controllers"
"github.com/submariner-io/submariner/pkg/ipam"
"github.com/submariner-io/submariner/pkg/globalnet/metrics"
"github.com/submariner-io/submariner/pkg/packetfilter"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -465,7 +466,7 @@ func newServiceExportControllerTestDriver() *serviceExportControllerTestDriver {
func (t *serviceExportControllerTestDriver) start() (*syncer.ResourceSyncerConfig, *controllers.IngressPodControllers, syncer.Interface) {
var err error

t.pool, err = ipam.NewIPPool(t.globalCIDR)
t.pool, err = ipam.NewIPPool(t.globalCIDR, metrics.GlobalnetMetricsReporter)
Expect(err).To(Succeed())

config := &syncer.ResourceSyncerConfig{
Expand Down
2 changes: 1 addition & 1 deletion pkg/globalnet/controllers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
"sync/atomic"
"time"

"github.com/submariner-io/admiral/pkg/ipam"
"github.com/submariner-io/admiral/pkg/log"
"github.com/submariner-io/admiral/pkg/syncer"
"github.com/submariner-io/admiral/pkg/watcher"
"github.com/submariner-io/submariner/pkg/event"
pfIface "github.com/submariner-io/submariner/pkg/globalnet/controllers/packetfilter"
"github.com/submariner-io/submariner/pkg/ipam"
"github.com/submariner-io/submariner/pkg/packetfilter"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
19 changes: 17 additions & 2 deletions pkg/globalnet/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ limitations under the License.

package metrics

import "github.com/prometheus/client_golang/prometheus"
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/submariner-io/admiral/pkg/ipam"
)

const (
cidrLabel = "cidr"
Expand Down Expand Up @@ -72,6 +75,10 @@ var (
)
)

var GlobalnetMetricsReporter ipam.MetricsReporter = GlobalnetMetrics{}

type GlobalnetMetrics struct{}

func init() {
prometheus.MustRegister(globalIPsAvailabilityGauge, globalIPsAllocatedGauge, globalEgressIPsAllocatedGauge,
clusterGlobalEgressIPsAllocatedGauge, globalIngressIPsAllocatedGauge)
Expand Down Expand Up @@ -116,6 +123,14 @@ func RecordDeallocateGlobalIngressIPs(cidr string, count int) {
globalIngressIPsAllocatedGauge.With(prometheus.Labels{cidrLabel: cidr}).Sub(float64(count))
}

func RecordAvailability(cidr string, count int) {
func (r GlobalnetMetrics) RecordAvailability(cidr string, count int) {
globalIPsAvailabilityGauge.With(prometheus.Labels{cidrLabel: cidr}).Set(float64(count))
}

func (r GlobalnetMetrics) RecordIPsAllocated(cidr string, count int) {
RecordAllocateGlobalIPs(cidr, count)
}

func (r GlobalnetMetrics) RecordIPDeallocated(cidr string) {
RecordDeallocateGlobalIP(cidr)
}
31 changes: 0 additions & 31 deletions pkg/ipam/ipam_suite_test.go

This file was deleted.

Loading
Loading