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

dns v2 - both empty string and default should be allowed for namespace and partition in CE #21230

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions .changelog/21230.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
dns: new version was not supporting partition or namespace being set to 'default' in CE version.
```
1 change: 1 addition & 0 deletions agent/discovery/query_fetcher_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ RPC:
}

func (f *V1DataFetcher) ValidateRequest(_ Context, req *QueryPayload) error {
f.logger.Debug(fmt.Sprintf("req %+v", req))
zalimeni marked this conversation as resolved.
Show resolved Hide resolved
if req.EnableFailover {
return ErrNotSupported
}
Expand Down
2 changes: 1 addition & 1 deletion agent/discovery/query_fetcher_v1_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (f *V1DataFetcher) NormalizeRequest(req *QueryPayload) {
}

func validateEnterpriseTenancy(req QueryTenancy) error {
if req.Namespace != "" || req.Partition != acl.DefaultPartitionName {
if !(req.Namespace == "" || req.Namespace == acl.DefaultNamespaceName) || !(req.Partition == acl.DefaultPartitionName || req.Partition == "default") {
zalimeni marked this conversation as resolved.
Show resolved Hide resolved
return ErrNotSupported
}
return nil
Expand Down
53 changes: 53 additions & 0 deletions agent/discovery/query_fetcher_v1_ce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,60 @@

package discovery

import (
"github.com/stretchr/testify/require"
"testing"
)

const (
defaultTestNamespace = ""
defaultTestPartition = ""
)

func Test_validateEnterpriseTenancy(t *testing.T) {
testCases := []struct {
name string
req QueryTenancy
expected error
}{
{
name: "empty namespace and partition returns no error",
req: QueryTenancy{
Namespace: defaultTestNamespace,
Partition: defaultTestPartition,
},
expected: nil,
},
{
name: "namespace and partition set to 'default' returns no error",
req: QueryTenancy{
Namespace: "default",
Partition: "default",
},
expected: nil,
},
{
name: "namespace set to something other than empty string or `default` returns not supported error",
req: QueryTenancy{
Namespace: "namespace-1",
Partition: "default",
},
expected: ErrNotSupported,
},
{
name: "partition set to something other than empty string or `default` returns not supported error",
req: QueryTenancy{
Namespace: "default",
Partition: "partition-1",
},
expected: ErrNotSupported,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := validateEnterpriseTenancy(tc.req)
require.Equal(t, tc.expected, err)
})
}
}