Skip to content

Commit

Permalink
Bump dependencies #1
Browse files Browse the repository at this point in the history
related to #697

 `k8s.io/*` bundle to `v0.22.2` (controller-gen tool makes changes in CRD description after bump)
 - `github.com/golang/mock` to `v1.6.0` (is not compiled into final binary but checked by dependabot)
 - `github.com/miekg/dns` to `v1.1.43`
 - `github.com/infobloxopen/infoblox-go-client` to `v1.1.1` (changes argument CreateTXTRecord from integer to uint)
 - `sigs.k8s.io/controller-runtime` to `v0.10.2`, had to fix the test, see comment below.
 - `sigs.k8s.io/external-dns` is problematic in terms it uses latest `github.com/go-logr/logr` which is incompatible
with previous versions. Will be part of followup PR

Controller-runtime works on copies of annotations rather than their pointers, so I had to modify the test.

```go
func TestGslbProperlyPropagatesAnnotationDownToIngress(t *testing.T) {
        // arrange
        settings := provideSettings(t, predefinedConfig)
        expectedAnnotations := map[string]string{"annotation": "test"}
        settings.gslb.Annotations = expectedAnnotations
        err := settings.client.Update(context.TODO(), settings.gslb)
        require.NoError(t, err, "Can't update gslb")
        // act
        reconcileAndUpdateGslb(t, settings)
        err2 := settings.client.Get(context.TODO(), settings.request.NamespacedName, settings.ingress)
        // assert
        assert.NoError(t, err2, "Failed to get expected ingress")
        assert.Equal(t, expectedAnnotations, settings.ingress.Annotations)
}
```

If I extend fial assertion the passing test is doing this:
```go
assert.Equal(t, map[string]string{"annotation": "test", "k8gb.io/strategy": "roundRobin"}, settings.ingress.Annotations)
assert.Equal(t, map[string]string{"annotation": "test", "k8gb.io/strategy": "roundRobin"}, settings.gslb.Annotations)
assert.Equal(t, map[string]string{"annotation": "test", "k8gb.io/strategy": "roundRobin"}, expectedAnnotations)
```

The `"k8gb.io/strategy": "roundRobin"` is added to `expectedAnnotations` during `reconcileAndUpdateGslb` and controlle-runtime
is the guy which extends `expectedAnnotations`.

I bumped controller runtime to `v0.10.2`, and only this concrete test has to be updated, because expectedAnnotations are not altered within controller-runtime:
```go
assert.Equal(t, map[string]string{"annotation": "test", "k8gb.io/strategy": "roundRobin"}, settings.ingress.Annotations)
assert.Equal(t, map[string]string{"annotation": "test", "k8gb.io/strategy": "roundRobin"}, settings.gslb.Annotations)
assert.Equal(t, map[string]string{"annotation": "test"}, expectedAnnotations)
```

Signed-off-by: kuritka <kuritka@gmail.com>
  • Loading branch information
kuritka committed Oct 27, 2021
1 parent b8e410f commit 123e6a2
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 559 deletions.
4 changes: 2 additions & 2 deletions chart/k8gb/templates/crds/k8gb.absa.oss_gslbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ spec:
of an incoming request. Currently it can contain
characters disallowed from the conventional
"path" part of a URL as defined by RFC 3986.
Paths must begin with a '/'. When unspecified,
all paths from incoming requests are matched.
Paths must begin with a '/' and must be present
when using PathType with value "Exact" or "Prefix".
type: string
pathType:
description: 'PathType determines the interpretation
Expand Down
5 changes: 3 additions & 2 deletions controllers/gslb_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,9 @@ func TestReturnsExternalRecordsUsingFailoverStrategyAndFallbackDNSserver(t *test

func TestGslbProperlyPropagatesAnnotationDownToIngress(t *testing.T) {
// arrange
expectedAnnotations := map[string]string{"annotation": "test", "k8gb.io/strategy": "roundRobin"}
settings := provideSettings(t, predefinedConfig)
expectedAnnotations := map[string]string{"annotation": "test"}
settings.gslb.Annotations = expectedAnnotations
settings.gslb.Annotations = map[string]string{"annotation": "test"}
err := settings.client.Update(context.TODO(), settings.gslb)
require.NoError(t, err, "Can't update gslb")
// act
Expand All @@ -726,6 +726,7 @@ func TestGslbProperlyPropagatesAnnotationDownToIngress(t *testing.T) {
// assert
assert.NoError(t, err2, "Failed to get expected ingress")
assert.Equal(t, expectedAnnotations, settings.ingress.Annotations)
assert.Equal(t, expectedAnnotations, settings.gslb.ObjectMeta.Annotations)
}

func TestReflectGeoTagInStatusAsUnsetByDefault(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion controllers/providers/dns/infoblox.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (p *InfobloxProvider) saveHeartbeatTXTRecord(objMgr *ibclient.ObjectManager
log.Info().
Str("HeartbeatTXTName", heartbeatTXTName).
Msg("Creating split brain TXT record")
_, err = objMgr.CreateTXTRecord(heartbeatTXTName, edgeTimestamp, gslb.Spec.Strategy.DNSTtlSeconds, "default")
_, err = objMgr.CreateTXTRecord(heartbeatTXTName, edgeTimestamp, uint(gslb.Spec.Strategy.DNSTtlSeconds), "default")
if err != nil {
m.InfobloxIncrementHeartbeatError(gslb)
return
Expand Down
18 changes: 8 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ module github.com/k8gb-io/k8gb
go 1.16

require (
github.com/AbsaOSS/env-binder v1.0.0
github.com/AbsaOSS/gopkg v0.1.2
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v0.4.0
github.com/golang/mock v1.5.0
github.com/infobloxopen/infoblox-go-client v1.1.0
github.com/miekg/dns v1.1.42
github.com/golang/mock v1.6.0
github.com/infobloxopen/infoblox-go-client v1.1.1
github.com/miekg/dns v1.1.43
github.com/prometheus/client_golang v1.11.0
github.com/rs/zerolog v1.21.0
github.com/stretchr/testify v1.7.0
k8s.io/api v0.21.2
k8s.io/apimachinery v0.21.2
k8s.io/client-go v0.21.2
sigs.k8s.io/controller-runtime v0.9.2
k8s.io/api v0.22.2
k8s.io/apimachinery v0.22.2
k8s.io/client-go v0.22.2
sigs.k8s.io/controller-runtime v0.10.2
sigs.k8s.io/external-dns v0.8.0
github.com/AbsaOSS/env-binder v1.0.0
)

replace golang.org/x/crypto => golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
Loading

0 comments on commit 123e6a2

Please sign in to comment.