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

feat: expand upstreams model and validation for 3.0 #311

Merged
merged 2 commits into from
Aug 23, 2022
Merged

Conversation

GGabriele
Copy link
Contributor

@GGabriele GGabriele commented Jul 22, 2022

Copy link
Member

@tjasko tjasko left a 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.

internal/server/kong/ws/config/version_compatibility.go Outdated Show resolved Hide resolved
@hbagdi
Copy link
Member

hbagdi commented Jul 25, 2022

Adding a hold to discuss downgrades.

@GGabriele GGabriele force-pushed the feat/upstream-vc branch 4 times, most recently from 06c482f to 9bf6ad1 Compare July 26, 2022 13:45
Copy link
Member

@hbagdi hbagdi left a 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).

internal/resource/upstream.go Outdated Show resolved Hide resolved
@hbagdi
Copy link
Member

hbagdi commented Jul 28, 2022

Please rebase.

@hbagdi
Copy link
Member

hbagdi commented Aug 1, 2022

@GGabriele Please rebase.

@GGabriele GGabriele changed the base branch from main to feat/services-vc August 2, 2022 11:22
@GGabriele GGabriele force-pushed the feat/upstream-vc branch 3 times, most recently from cfacd30 to 8bce826 Compare August 2, 2022 12:01
@GGabriele
Copy link
Contributor Author

@GGabriele Please rebase.

Rebased on top of the feat/services-vc branch in order to avoid duplicating effort

internal/test/e2e/version_compatibility_test.go Outdated Show resolved Hide resolved
conditionUpdate := fieldUpdate.Field
if fieldUpdate.Value == nil && len(fieldUpdate.ValueFromField) == 0 {
// Handle field removal
if updatedRaw, err = sjson.Delete(updatedRaw, conditionUpdate); err != nil {
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already tested

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing this on a 2.8 DP does not execute this code. Am I doing something wrong? This also does not run on a 3.0 DP (commented about this).

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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?

Copy link
Contributor Author

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!

Copy link
Member

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?

} 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

Copy link
Contributor Author

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 .

internal/server/kong/ws/config/version_compatibility.go Outdated Show resolved Hide resolved
@hbagdi
Copy link
Member

hbagdi commented Aug 4, 2022

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) {
Copy link
Member

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]

Copy link
Member

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

Copy link
Contributor

@omegabytes omegabytes Aug 11, 2022

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing this on a 2.8 DP does not execute this code. Am I doing something wrong? This also does not run on a 3.0 DP (commented about this).

@hbagdi
Copy link
Member

hbagdi commented Aug 10, 2022

@GGabriele Please work with Taylor to get his comments resolved.

@GGabriele GGabriele force-pushed the feat/upstream-vc branch 2 times, most recently from 6413278 to be56518 Compare August 11, 2022 11:36
@GGabriele GGabriele requested a review from tjasko August 11, 2022 11:46
@omegabytes
Copy link
Contributor

Also hitting this error when testing against 3.0

dp-stderr: 2022/08/11 20:34:25 [notice] 3000#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

@GGabriele GGabriele force-pushed the feat/upstream-vc branch 4 times, most recently from 8777f4a to d52ecfb Compare August 17, 2022 13:20
@GGabriele
Copy link
Contributor Author

@tjasko let me know if you have any more comments!

@hbagdi
Copy link
Member

hbagdi commented Aug 18, 2022

Please rebase.
I'll take a look after Taylor.

@GGabriele
Copy link
Contributor Author

Tests are passing with DP<3.0 (included in this branch) and I could successfully test this on DP>=3.0 (showed in the our last call). Let me know if we need anything else to move this forward! @tjasko @mikefero

Copy link
Member

@tjasko tjasko left a 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 "+
Copy link
Member

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:

  1. Data plane
  2. Dataplane
  3. Data-plane
  4. Kong Gateway

We're mostly using "Kong Gateway" when referring to DPs to users, so should we be consistent?

Copy link
Contributor Author

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.

Copy link
Member

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.

internal/server/kong/ws/config/version_compatibility.go Outdated Show resolved Hide resolved
internal/test/e2e/version_compatibility_test.go Outdated Show resolved Hide resolved
@GGabriele GGabriele force-pushed the feat/upstream-vc branch 2 times, most recently from 9af2384 to 18fbc3a Compare August 19, 2022 19:10
hbagdi
hbagdi previously approved these changes Aug 19, 2022
Copy link
Member

@hbagdi hbagdi left a 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.

@mikefero
Copy link
Contributor

Rebasing and fixing conflicts.

@mikefero mikefero merged commit d5af949 into main Aug 23, 2022
@mikefero mikefero deleted the feat/upstream-vc branch August 23, 2022 17:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants