-
Notifications
You must be signed in to change notification settings - Fork 4
feat: expand upstreams model and validation for 3.0 #311
Conversation
e9df7b6
to
9fd5c9b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes seem sane but would require a bit deeper investigation to verify all the validation logic.
Adding a hold to discuss downgrades. |
06c482f
to
9bf6ad1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did an initial pass.
An integration test that ensures that these new fields make it down to the DP are missing.
The functionality for that is also missing (no proto updates in kong/kong or this repository).
Please rebase. |
@GGabriele Please rebase. |
9bf6ad1
to
2e9032e
Compare
cfacd30
to
8bce826
Compare
Rebased on top of the |
8bce826
to
7779ac8
Compare
9bf70ef
to
0a20d1f
Compare
conditionUpdate := fieldUpdate.Field | ||
if fieldUpdate.Value == nil && len(fieldUpdate.ValueFromField) == 0 { | ||
// Handle field removal | ||
if updatedRaw, err = sjson.Delete(updatedRaw, conditionUpdate); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we ensure this case is handled in the integration test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can run these together when you get online? I'm not able to run integration tests (running on a MacOS), but I test connecting a DP with koko and this is what I see when I push something like this (needing fields removal and updates):
http :3000/v1/upstreams\?cluster.id=4168295f-015e-4190-837e-0fcc5d72a52f name=foo-with-hash_on_query_arg hash_on=ip hash_on_query_arg=test
http :3000/v1/upstreams\?cluster.id=4168295f-015e-4190-837e-0fcc5d72a52f name=foo-with-hash_on hash_on=path hash_on_query_arg=test
http :3000/v1/upstreams\?cluster.id=4168295f-015e-4190-837e-0fcc5d72a52f name=foo-with-hash_fallback hash_on=ip hash_fallback=path hash_on_query_arg=test
2022-08-05T09:51:46.892+0200 warn config/version_compatibility.go:498 removing entity field which is incompatible with data plane {"component": "version-compatibility", "entity": "upstreams", "name": "\"foo-with-hash_on_query_arg\"", "field": "hash_on_query_arg", "data-plane": 2008000000}
2022-08-05T09:51:46.892+0200 warn config/version_compatibility.go:498 removing entity field which is incompatible with data plane {"component": "version-compatibility", "entity": "upstreams", "name": "\"foo-with-hash_on\"", "field": "hash_on_query_arg", "data-plane": 2008000000}
2022-08-05T09:51:46.892+0200 warn config/version_compatibility.go:561 removing entity field which is incompatible with data plane {"component": "version-compatibility", "entity": "upstreams", "field": "hash_on", "condition": "hash_on=path", "new-value": "none", "data-plane": 2008000000}
2022-08-05T09:51:46.892+0200 warn config/version_compatibility.go:498 removing entity field which is incompatible with data plane {"component": "version-compatibility", "entity": "upstreams", "name": "\"foo-with-hash_fallback\"", "field": "hash_on_query_arg", "data-plane": 2008000000}
2022-08-05T09:51:46.892+0200 warn config/version_compatibility.go:561 removing entity field which is incompatible with data plane {"component": "version-compatibility", "entity": "upstreams", "field": "hash_fallback", "condition": "hash_fallback=path", "new-value": "none", "data-plane": 2008000000}
Also things like this in the e2e should error out, but they pass, which confuses me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I have to work around some tooling to run them on macOS. I have some work tracked to get that improved, I do want to make testing of these things significantly easier.
We can pair on this & I can show you how I did this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we figure anything out here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah what you were asking for is now covered here. That's not a e2e test because we don't have a compatibility change leveraging that portion of the code just yet (and e2e tests use the "real" compatibility table used by koko), so I just added a test case in the unit tests for the upstreams making sure we hit that portion of logic not otherwise tested in the integrations.
Let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That part looks good now, can we get this covered part of the unit test too?
koko/internal/server/kong/ws/config/version_compatibility.go
Lines 590 to 598 in be56518
} else { | |
vc.logger.With(zap.String("entity", entityName)). | |
With(zap.String("field", update.Field)). | |
With(zap.String("condition", update.Condition)). | |
With(zap.Any("new-value", fieldUpdate.Value)). | |
With(zap.String("data-plane", dataPlaneVersion)). | |
With(zap.Error(err)). | |
Error("entity configuration does not contain field value") | |
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. Just note that we should never get hit this and it only goes here in case of errors .
7779ac8
to
ac793c9
Compare
0a20d1f
to
9e6b32c
Compare
ac793c9
to
31c17be
Compare
Please get the final review from Taylor and please merge feat/services-vc into main and then rebase this on top of main. |
@@ -371,6 +377,139 @@ func TestVersionCompatibility(t *testing.T) { | |||
}) | |||
} | |||
|
|||
func TestUpstreamsVersionCompatibility(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unable to get this test to pass on a 3.0 DP, it actually fails:
version_compatibility_test.go:466: upstreams validation failed can't match element at upstreams[0]
util.go:48: failed to complete operation: can't match element at upstreams[0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a deeper look into the logs here, may be wRPC related:
dp-stderr: 2022/08/10 15:04:51 [debug] 3001#0: *6 [lua] grpc.lua:29: safe_set_type_hook(): no type '.google.protobuf.Timestamp' defined
dp-stderr: 2022/08/10 15:04:52 [notice] 3001#0: *6 [lua] message.lua:128: handle_error(): [wRPC] Received error message, 5.4:1 (--: "invalid call: invalid rpc(4) for service(5)"), context: ngx.timer
Running the following DP image:
$ docker images kong/kong:master-ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
kong/kong master-ubuntu 6873404d2bc7 32 minutes ago 291MB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm told this resolves it: Kong/kong#9199
#344
conditionUpdate := fieldUpdate.Field | ||
if fieldUpdate.Value == nil && len(fieldUpdate.ValueFromField) == 0 { | ||
// Handle field removal | ||
if updatedRaw, err = sjson.Delete(updatedRaw, conditionUpdate); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9e6b32c
to
0e39ebf
Compare
3f75b4c
to
f579008
Compare
@GGabriele Please work with Taylor to get his comments resolved. |
6413278
to
be56518
Compare
Also hitting this error when testing against 3.0
|
8777f4a
to
d52ecfb
Compare
@tjasko let me know if you have any more comments! |
d52ecfb
to
84f5eb4
Compare
Please rebase. |
84f5eb4
to
4a617d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor nits. I'll take your word for it that you were able to test this on 3.0.
"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. Because of this, 'hash_on' and 'hash_fallback'"+ | ||
"have been changed in the data-plane to 'none' and hashing is "+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We have three ways of representing a DP within the code:
- Data plane
- Dataplane
- Data-plane
- Kong Gateway
We're mostly using "Kong Gateway" when referring to DPs to users, so should we be consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No objection, but maybe we should tackle this on a different branch? These inconsistencies are widespread in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially, because this is customer-facing, I'm treating it a bit differently from everything else.
9af2384
to
18fbc3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving the final approval and merging to @mikefero.
Rebasing and fixing conflicts. |
18fbc3a
to
1a5fb2b
Compare
Kong related changes