Skip to content

Commit

Permalink
Merge refs/heads/main into stevenctl/allow-custom-translator
Browse files Browse the repository at this point in the history
  • Loading branch information
soloio-bulldozer[bot] authored Jun 17, 2024
2 parents 7cb0ba8 + 7e85ba5 commit 3dd15e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 83 deletions.
5 changes: 5 additions & 0 deletions changelog/v1.18.0-beta1/stop-status-spamming.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6252
resolvesIssue: false
description: Fix issue where Kube Gateway proxies would have errors regarding status logged constantly
21 changes: 2 additions & 19 deletions projects/gloo/pkg/syncer/envoy_translator_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ import (

"github.com/solo-io/go-utils/contextutils"
"github.com/solo-io/go-utils/hashutils"
"github.com/solo-io/solo-kit/pkg/api/v1/control-plane/cache"
envoycache "github.com/solo-io/solo-kit/pkg/api/v1/control-plane/cache"
"github.com/solo-io/solo-kit/pkg/api/v1/control-plane/types"
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
"github.com/solo-io/solo-kit/pkg/api/v2/reporter"

"github.com/solo-io/gloo/pkg/utils/syncutil"
"github.com/solo-io/gloo/projects/gateway2/translator/translatorutils"
gloov1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
v1snap "github.com/solo-io/gloo/projects/gloo/pkg/api/v1/gloosnapshot"
"github.com/solo-io/gloo/projects/gloo/pkg/plugins"
syncerstats "github.com/solo-io/gloo/projects/gloo/pkg/syncer/stats"
"github.com/solo-io/gloo/projects/gloo/pkg/utils"
"github.com/solo-io/gloo/projects/gloo/pkg/xds"
)

Expand Down Expand Up @@ -58,7 +55,7 @@ func init() {
const emptyVersionKey = "empty"

var (
emptyResource = cache.Resources{
emptyResource = envoycache.Resources{
Version: emptyVersionKey,
Items: map[string]envoycache.Resource{},
}
Expand Down Expand Up @@ -128,7 +125,7 @@ func (s *translatorSyncer) syncEnvoy(ctx context.Context, snap *v1snap.ApiSnapsh
var proxiesWithReports []translatorutils.ProxyWithReports
for _, proxy := range snap.Proxies {
proxyCtx := ctx
metaKey := GetKeyFromProxyMeta(proxy)
metaKey := xds.SnapshotCacheKey(proxy)
if ctxWithTags, err := tag.New(proxyCtx, tag.Insert(syncerstats.ProxyNameKey, metaKey)); err == nil {
proxyCtx = ctxWithTags
}
Expand Down Expand Up @@ -234,17 +231,3 @@ func prettify(original interface{}) string {

return string(b)
}

func GetKeyFromProxyMeta(proxy *gloov1.Proxy) string {
meta := proxy.GetMetadata()
metaKey := meta.Ref().Key()
labels := proxy.GetMetadata().GetLabels()
if labels != nil && labels[utils.ProxyTypeKey] == utils.GatewayApiProxyValue {
proxyNamespace := labels[utils.GatewayNamespaceKey]
if proxyNamespace != "" {
meta.Namespace = proxyNamespace
metaKey = meta.Ref().Key()
}
}
return metaKey
}
64 changes: 0 additions & 64 deletions projects/gloo/pkg/syncer/translator_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"github.com/solo-io/gloo/projects/gloo/pkg/servers/iosnapshot"

"github.com/solo-io/gloo/pkg/bootstrap/leaderelector/singlereplica"
gloov1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
"github.com/solo-io/gloo/projects/gloo/pkg/utils"

gloo_translator "github.com/solo-io/gloo/projects/gloo/pkg/translator"

Expand Down Expand Up @@ -344,68 +342,6 @@ var _ = Describe("Translate multiple proxies with errors", func() {

Expect(xdsCache.Called).To(BeTrue())
})

Describe("correctl returns metaKey for proxies", func() {
It("returns the correct key", func() {
// Create a proxy with metadata and labels
proxy := &gloov1.Proxy{
Metadata: &core.Metadata{
Name: "test-proxy",
Namespace: "test-namespace",
Labels: map[string]string{
utils.ProxyTypeKey: utils.GatewayApiProxyValue,
utils.GatewayNamespaceKey: "custom-namespace",
},
},
}

key := GetKeyFromProxyMeta(proxy)

// Assert that the returned key matches the expected value
expectedKey := "custom-namespace.test-proxy"
Expect(key).To(Equal(expectedKey))
})

It("returns the correct key when proxy has no custom namespace label", func() {

// Create a proxy with metadata and labels
proxy := &gloov1.Proxy{
Metadata: &core.Metadata{
Name: "test-proxy",
Namespace: "test-namespace",
Labels: map[string]string{
utils.ProxyTypeKey: utils.GatewayApiProxyValue,
},
},
}

key := GetKeyFromProxyMeta(proxy)

// Assert that the returned key matches the expected value
expectedKey := "test-namespace.test-proxy"
Expect(key).To(Equal(expectedKey))
})

It("returns the correct key when proxy is not a Gloo gateway proxy", func() {
// Create a proxy with metadata and labels
proxy := &gloov1.Proxy{
Metadata: &core.Metadata{
Name: "test-proxy",
Namespace: "test-namespace",
Labels: map[string]string{
utils.ProxyTypeKey: "some-other-value",
utils.GatewayNamespaceKey: "custom-namespace",
},
},
}

key := GetKeyFromProxyMeta(proxy)

// Assert that the returned key matches the expected value
expectedKey := "test-namespace.test-proxy"
Expect(key).To(Equal(expectedKey))
})
})
})

type mockTranslator struct {
Expand Down

0 comments on commit 3dd15e2

Please sign in to comment.