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

Bump Infoblox go client to v2 (2.1.2-0.20220727224704-88a5ba602dbf) #931

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ mocks:
mockgen -source=controllers/providers/dns/dns.go -destination=controllers/providers/dns/dns_mock.go -package=dns
mockgen -source=controllers/providers/dns/infoblox-client.go -destination=controllers/providers/dns/infoblox-client_mock.go -package=dns
mockgen -source=controllers/depresolver/resolver.go -destination=controllers/depresolver/resolver_mock.go -package=depresolver
mockgen -destination=controllers/providers/dns/infoblox-connection_mock.go -package=dns github.com/infobloxopen/infoblox-go-client IBConnector
mockgen -destination=controllers/providers/dns/infoblox-connection_mock.go -package=dns github.com/infobloxopen/infoblox-go-client/v2 IBConnector
$(call golic)

# remove clusters and redeploy
Expand Down
34 changes: 17 additions & 17 deletions controllers/depresolver/resolver_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions controllers/providers/dns/infoblox-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
import (
"strconv"

ibclient "github.com/infobloxopen/infoblox-go-client"
ibclient "github.com/infobloxopen/infoblox-go-client/v2"
"github.com/k8gb-io/k8gb/controllers/depresolver"
)

type InfobloxClient interface {
GetObjectManager() (objMgr *ibclient.ObjectManager, err error)
GetObjectManager() (objMgr ibclient.IBObjectManager, err error)
}

type Client struct {
objMgr *ibclient.ObjectManager
objMgr ibclient.IBObjectManager
config depresolver.Config
}

Expand All @@ -40,18 +40,17 @@ func NewInfobloxClient(config depresolver.Config) *Client {
}
}

func (c *Client) GetObjectManager() (objMgr *ibclient.ObjectManager, err error) {
func (c *Client) GetObjectManager() (objMgr ibclient.IBObjectManager, err error) {
hostConfig := ibclient.HostConfig{
Host: c.config.Infoblox.Host,
Version: c.config.Infoblox.Version,
Port: strconv.Itoa(c.config.Infoblox.Port),
Username: c.config.Infoblox.Username,
Password: c.config.Infoblox.Password,
Host: c.config.Infoblox.Host,
Version: c.config.Infoblox.Version,
Port: strconv.Itoa(c.config.Infoblox.Port),
}
authConfig := ibclient.AuthConfig{Username: c.config.Infoblox.Username, Password: c.config.Infoblox.Password}
transportConfig := ibclient.NewTransportConfig("false", c.config.Infoblox.HTTPRequestTimeout, c.config.Infoblox.HTTPPoolConnections)
requestBuilder := &ibclient.WapiRequestBuilder{}
requestor := &ibclient.WapiHttpRequestor{}
conn, err := ibclient.NewConnector(hostConfig, transportConfig, requestBuilder, requestor)
conn, err := ibclient.NewConnector(hostConfig, authConfig, transportConfig, requestBuilder, requestor)
if err != nil {
return
}
Expand Down
6 changes: 3 additions & 3 deletions controllers/providers/dns/infoblox-client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions controllers/providers/dns/infoblox-connection_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion controllers/providers/dns/infoblox-sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
import (
"sort"

ibclient "github.com/infobloxopen/infoblox-go-client"
ibclient "github.com/infobloxopen/infoblox-go-client/v2"
)

type byAddress []ibclient.NameServer
Expand Down
38 changes: 23 additions & 15 deletions controllers/providers/dns/infoblox.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
*/

import (
"errors"
"fmt"
"reflect"
"time"

externaldns "sigs.k8s.io/external-dns/endpoint"

ibcl "github.com/infobloxopen/infoblox-go-client"
ibcl "github.com/infobloxopen/infoblox-go-client/v2"
k8gbv1beta1 "github.com/k8gb-io/k8gb/api/v1beta1"
"github.com/k8gb-io/k8gb/controllers/depresolver"
"github.com/k8gb-io/k8gb/controllers/providers/assistant"
Expand All @@ -40,6 +41,8 @@ type InfobloxProvider struct {

var m = metrics.Metrics()

const infobloxView = "default"

func NewInfobloxDNS(config depresolver.Config, assistant assistant.Assistant, client InfobloxClient) *InfobloxProvider {
return &InfobloxProvider{
client: client,
Expand Down Expand Up @@ -212,7 +215,7 @@ func (p *InfobloxProvider) String() string {
return "Infoblox"
}

func (p *InfobloxProvider) saveHeartbeatTXTRecord(objMgr *ibcl.ObjectManager, gslb *k8gbv1beta1.Gslb) (err error) {
func (p *InfobloxProvider) saveHeartbeatTXTRecord(objMgr ibcl.IBObjectManager, gslb *k8gbv1beta1.Gslb) (err error) {
var heartbeatTXTRecord *ibcl.RecordTXT
edgeTimestamp := fmt.Sprint(time.Now().UTC().Format("2006-01-02T15:04:05"))
heartbeatTXTName := p.config.GetClusterHeartbeatFQDN(gslb.Name)
Expand All @@ -224,7 +227,7 @@ func (p *InfobloxProvider) saveHeartbeatTXTRecord(objMgr *ibcl.ObjectManager, gs
log.Info().
Str("HeartbeatTXTName", heartbeatTXTName).
Msg("Creating split brain TXT record")
_, err = p.createTXTRecord(objMgr, heartbeatTXTName, edgeTimestamp, uint(gslb.Spec.Strategy.DNSTtlSeconds))
_, err = p.createTXTRecord(objMgr, heartbeatTXTName, edgeTimestamp, uint32(gslb.Spec.Strategy.DNSTtlSeconds))
if err != nil {
m.InfobloxIncrementHeartbeatError(gslb)
return
Expand All @@ -233,7 +236,7 @@ func (p *InfobloxProvider) saveHeartbeatTXTRecord(objMgr *ibcl.ObjectManager, gs
log.Info().
Str("HeartbeatTXTName", heartbeatTXTName).
Msg("Updating split brain TXT record")
_, err = p.updateTXTRecord(objMgr, heartbeatTXTName, edgeTimestamp)
_, err = p.updateTXTRecord(objMgr, heartbeatTXTName, edgeTimestamp, uint32(gslb.Spec.Strategy.DNSTtlSeconds))
if err != nil {
m.InfobloxIncrementHeartbeatError(gslb)
return
Expand Down Expand Up @@ -262,56 +265,61 @@ func (p *InfobloxProvider) filterOutDelegateTo(delegateTo []ibcl.NameServer, fqd
return
}

func (p *InfobloxProvider) createZoneDelegated(o *ibcl.ObjectManager, fqdn string, d []ibcl.NameServer) (res *ibcl.ZoneDelegated, err error) {
func (p *InfobloxProvider) createZoneDelegated(o ibcl.IBObjectManager, fqdn string, d []ibcl.NameServer) (res *ibcl.ZoneDelegated, err error) {
start := time.Now()
res, err = o.CreateZoneDelegated(fqdn, d)
m.InfobloxObserveRequestDuration(start, metrics.CreateZoneDelegated, err == nil)
return
}

func (p *InfobloxProvider) getZoneDelegated(o *ibcl.ObjectManager, fqdn string) (res *ibcl.ZoneDelegated, err error) {
func (p *InfobloxProvider) getZoneDelegated(o ibcl.IBObjectManager, fqdn string) (res *ibcl.ZoneDelegated, err error) {
start := time.Now()
res, err = o.GetZoneDelegated(fqdn)
m.InfobloxObserveRequestDuration(start, metrics.GetZoneDelegated, err == nil)
return
}

func (p *InfobloxProvider) updateZoneDelegated(o *ibcl.ObjectManager, fqdn string, d []ibcl.NameServer) (res *ibcl.ZoneDelegated, err error) {
func (p *InfobloxProvider) updateZoneDelegated(o ibcl.IBObjectManager, fqdn string, d []ibcl.NameServer) (res *ibcl.ZoneDelegated, err error) {
start := time.Now()
res, err = o.UpdateZoneDelegated(fqdn, d)
m.InfobloxObserveRequestDuration(start, metrics.UpdateZoneDelegated, err == nil)
return
}

func (p *InfobloxProvider) deleteZoneDelegated(o *ibcl.ObjectManager, fqdn string) (res string, err error) {
func (p *InfobloxProvider) deleteZoneDelegated(o ibcl.IBObjectManager, fqdn string) (res string, err error) {
start := time.Now()
res, err = o.DeleteZoneDelegated(fqdn)
m.InfobloxObserveRequestDuration(start, metrics.DeleteZoneDelegated, err == nil)
return
}

func (p *InfobloxProvider) createTXTRecord(o *ibcl.ObjectManager, name string, text string, ttl uint) (res *ibcl.RecordTXT, err error) {
func (p *InfobloxProvider) createTXTRecord(o ibcl.IBObjectManager, name string, text string, ttl uint32) (res *ibcl.RecordTXT, err error) {
start := time.Now()
res, err = o.CreateTXTRecord(name, text, ttl, "default")
res, err = o.CreateTXTRecord(infobloxView, name, text, ttl, true, "default", nil)
m.InfobloxObserveRequestDuration(start, metrics.CreateTXTRecord, err == nil)
return
}

func (p *InfobloxProvider) getTXTRecord(o *ibcl.ObjectManager, name string) (res *ibcl.RecordTXT, err error) {
func (p *InfobloxProvider) getTXTRecord(o ibcl.IBObjectManager, name string) (res *ibcl.RecordTXT, err error) {
start := time.Now()
res, err = o.GetTXTRecord(name)
res, err = o.GetTXTRecord(infobloxView, name)
e := &ibcl.NotFoundError{}
if errors.As(err, &e) {
// infoblox-client@v1 wasn't returning the error in case the record was not found, so preserving the contract from v1 here
err = nil
}
m.InfobloxObserveRequestDuration(start, metrics.GetTXTRecord, err == nil)
return
}

func (p *InfobloxProvider) updateTXTRecord(o *ibcl.ObjectManager, name string, text string) (res *ibcl.RecordTXT, err error) {
func (p *InfobloxProvider) updateTXTRecord(o ibcl.IBObjectManager, name string, text string, ttl uint32) (res *ibcl.RecordTXT, err error) {
start := time.Now()
res, err = o.UpdateTXTRecord(name, text)
res, err = o.UpdateTXTRecord("", name, text, ttl, true, "default", nil)
m.InfobloxObserveRequestDuration(start, metrics.UpdateTXTRecord, err == nil)
return
}

func (p *InfobloxProvider) deleteTXTRecord(o *ibcl.ObjectManager, name string) (res string, err error) {
func (p *InfobloxProvider) deleteTXTRecord(o ibcl.IBObjectManager, name string) (res string, err error) {
start := time.Now()
res, err = o.DeleteTXTRecord(name)
m.InfobloxObserveRequestDuration(start, metrics.DeleteTXTRecord, err == nil)
Expand Down
24 changes: 10 additions & 14 deletions controllers/providers/dns/infoblox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"testing"

"github.com/golang/mock/gomock"
ibclient "github.com/infobloxopen/infoblox-go-client"
ibclient "github.com/infobloxopen/infoblox-go-client/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -170,7 +170,7 @@ func TestInfobloxCreateZoneDelegationForExternalDNS(t *testing.T) {
a.EXPECT().GslbIngressExposedIPs(gomock.Any()).Return(ipRange, nil).Times(1)
con.EXPECT().CreateObject(gomock.Any()).Return(ref, nil).AnyTimes()
con.EXPECT().UpdateObject(gomock.Any(), gomock.Any()).Return(ref, nil).Times(1)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any()).SetArg(2, []ibclient.ZoneDelegated{defaultDelegatedZone}).Return(nil)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).SetArg(3, []ibclient.ZoneDelegated{defaultDelegatedZone}).Return(nil)
cl.EXPECT().GetObjectManager().Return(ibclient.NewObjectManager(con, "k8gbclient", ""), nil).Times(1)
config := defaultConfig
provider := NewInfobloxDNS(config, a, cl)
Expand All @@ -194,12 +194,10 @@ func TestInfobloxCreateZoneDelegationForExternalDNSWithSplitBrainEnabled(t *test
}).Return(nil).Times(1)
con.EXPECT().CreateObject(gomock.Any()).Return(ref, nil).AnyTimes()
con.EXPECT().UpdateObject(gomock.Any(), gomock.Any()).Return(ref, nil).Times(2)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any()).SetArg(2, []ibclient.ZoneDelegated{defaultDelegatedZone}).Return(nil)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).SetArg(3, []ibclient.ZoneDelegated{defaultDelegatedZone}).Return(nil)
cl.EXPECT().GetObjectManager().Return(ibclient.NewObjectManager(con, "k8gbclient", ""), nil).Times(1)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any()).SetArg(2, []ibclient.RecordTXT{{Ref: ref}}).
Return(nil).Do(func(arg0 *ibclient.RecordTXT, arg1, arg2 interface{}) {
require.Equal(t, "test-gslb-heartbeat-us-west-1.example.com", arg0.Name)
}).AnyTimes()
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).SetArg(3, []ibclient.RecordTXT{{Ref: ref}}).Times(1)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).SetArg(3, &ibclient.RecordTXT{Ref: ref}).AnyTimes()
config := defaultConfig
config.SplitBrainCheck = true
provider := NewInfobloxDNS(config, a, cl)
Expand All @@ -221,9 +219,10 @@ func TestInfobloxCreateZoneDelegationForExternalDNSWithSplitBrainEnabledCreating
a.EXPECT().InspectTXTThreshold(gomock.Any(), gomock.Any()).Return(nil).Times(1)
con.EXPECT().CreateObject(gomock.Any()).Return(ref, nil).AnyTimes()
con.EXPECT().UpdateObject(gomock.Any(), gomock.Any()).Return(ref, nil).Times(1)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any()).SetArg(2, []ibclient.ZoneDelegated{defaultDelegatedZone}).Return(nil)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).SetArg(3, []ibclient.ZoneDelegated{defaultDelegatedZone}).Return(nil)
cl.EXPECT().GetObjectManager().Return(ibclient.NewObjectManager(con, "k8gbclient", ""), nil).Times(1)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any()).SetArg(2, []ibclient.RecordTXT{}).Return(nil).AnyTimes()
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).SetArg(3, []ibclient.RecordTXT{}).Return(nil).Times(1)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).SetArg(3, &ibclient.RecordTXT{}).Return(nil).Times(1)
config := defaultConfig
config.SplitBrainCheck = true
provider := NewInfobloxDNS(config, a, cl)
Expand All @@ -244,12 +243,9 @@ func TestInfobloxFinalize(t *testing.T) {
con.EXPECT().DeleteObject(gomock.Any()).Return(ref, nil).Do(func(arg0 string) {
require.Equal(t, arg0, ref)
}).AnyTimes()
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any()).SetArg(2, []ibclient.ZoneDelegated{defaultDelegatedZone}).
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).SetArg(3, []ibclient.ZoneDelegated{defaultDelegatedZone}).
Return(nil).Times(1)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any()).SetArg(2, []ibclient.RecordTXT{{Ref: ref}}).
Return(nil).Do(func(arg0 *ibclient.RecordTXT, arg1, arg2 interface{}) {
require.Equal(t, "test-gslb-heartbeat-us-west-1.example.com", arg0.Name)
}).Times(1)
con.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).SetArg(3, []ibclient.RecordTXT{{Ref: ref}}).Times(1)
cl.EXPECT().GetObjectManager().Return(ibclient.NewObjectManager(con, "k8gbclient", ""), nil).Times(1)
config := defaultConfig
provider := NewInfobloxDNS(config, a, cl)
Expand Down
2 changes: 1 addition & 1 deletion controllers/weight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func TestWeight(t *testing.T) {
defer ctrl.Finish()
// settings := provideSettings(t, predefinedConfig)
m := dns.NewMockProvider(ctrl)
r := depresolver.NewMockResolver(ctrl)
r := depresolver.NewMockGslbResolver(ctrl)
m.EXPECT().GslbIngressExposedIPs(gomock.Any()).Return([]string{}, nil).Times(1)
m.EXPECT().SaveDNSEndpoint(gomock.Any(), gomock.Any()).Do(assertAnnotation).Return(fmt.Errorf("save DNS error")).Times(1)
m.EXPECT().CreateZoneDelegationForExternalDNS(gomock.Any()).Return(nil).AnyTimes()
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require (
github.com/google/uuid v1.1.2 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/infobloxopen/infoblox-go-client/v2 v2.1.2-0.20220727224704-88a5ba602dbf // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
Expand Down
Loading