Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GGabriele committed Aug 9, 2022
1 parent 9867f85 commit 3f75b4c
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 3 deletions.
20 changes: 17 additions & 3 deletions internal/server/kong/ws/config/compat/compatibility_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ func standardPluginNotAvailableMessage(pluginName string, versionWithFeatureSupp
)
}

func standardCoreEntityFieldsMessage(entityName string, fields []string, versionWithFeatureSupport string) string {
quotedFields := "'" + strings.Join(fields, "', '") + "'"

return fmt.Sprintf("For the '%s' entity, "+
"one or more of the following schema fields are set: %s "+
"but Kong gateway versions < %s do not support these fields. "+
entityName,
quotedFields,
versionWithFeatureSupport,
)
}

const (
versionsPre260 = 2005999999
versionsPre270 = 2006999999
Expand Down Expand Up @@ -443,9 +455,11 @@ var (
Description: fmt.Sprintf("For the 'upstreams' entity, "+
"one or more of the '%s' schema fields are set with one "+
"of the following values: %s, but Kong gateway versions < 3.0 "+
"do not support these values. ",
[]string{"hash_on", "hash_fallback"},
[]string{"path", "query_arg", "uri_capture"},
"do not support these values. Because of this, 'hash_on' and 'hash_fallback'"+
"have been changed in the data-plane to 'none' and hashing is "+
"not working as expected.",
strings.Join([]string{"hash_on", "hash_fallback"}, ","),
strings.Join([]string{"path", "query_arg", "uri_capture"}, ","),
),
Resolution: standardUpgradeMessage("3.0"),
},
Expand Down
115 changes: 115 additions & 0 deletions internal/server/kong/ws/config/version_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2648,6 +2648,121 @@ func TestVersionCompatibility_ProcessConfigTableUpdates(t *testing.T) {
}
}`,
},
{
name: "ensure unsupported upstreams fields values are changed to 'none'",
configTableUpdates: map[uint64][]ConfigTableUpdates{
3000000000: {
{
Type: Upstream,
FieldUpdates: []ConfigTableFieldCondition{
{
Field: "hash_on",
Condition: "hash_on=path",
Updates: []ConfigTableFieldUpdate{
{
Field: "hash_on",
Value: "none",
},
},
},
{
Field: "hash_on",
Condition: "hash_on=query_arg",
Updates: []ConfigTableFieldUpdate{
{
Field: "hash_on",
Value: "none",
},
},
},
{
Field: "hash_on",
Condition: "hash_on=uri_capture",
Updates: []ConfigTableFieldUpdate{
{
Field: "hash_on",
Value: "none",
},
},
},
{
Field: "hash_fallback",
Condition: "hash_fallback=path",
Updates: []ConfigTableFieldUpdate{
{
Field: "hash_fallback",
Value: "none",
},
},
},
{
Field: "hash_fallback",
Condition: "hash_fallback=query_arg",
Updates: []ConfigTableFieldUpdate{
{
Field: "hash_fallback",
Value: "none",
},
},
},
{
Field: "hash_fallback",
Condition: "hash_fallback=uri_capture",
Updates: []ConfigTableFieldUpdate{
{
Field: "hash_fallback",
Value: "none",
},
},
},
},
},
},
},
uncompressedPayload: `{
"config_table": {
"upstreams": [
{
"name": "upstream_1",
"hash_on": "path",
"hash_fallback": "path"
},
{
"name": "upstream_2",
"hash_on": "query_arg",
"hash_fallback": "query_arg"
},
{
"name": "upstream_3",
"hash_on": "uri_capture",
"hash_fallback": "uri_capture"
}
]
}
}`,
dataPlaneVersion: 2007000000,
expectedPayload: `{
"config_table": {
"upstreams": [
{
"name": "upstream_1",
"hash_on": "none",
"hash_fallback": "none"
},
{
"name": "upstream_2",
"hash_on": "none",
"hash_fallback": "none"
},
{
"name": "upstream_3",
"hash_on": "none",
"hash_fallback": "none"
}
]
}
}`,
},
}

for _, test := range tests {
Expand Down

0 comments on commit 3f75b4c

Please sign in to comment.