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

fix(kuma-cp) subscription finalizer #2444

Closed
wants to merge 7 commits into from
Closed

Conversation

lobkovilya
Copy link
Contributor

Summary

This is not exactly Solution 2 from #2320, slightly different approach and doesn't require real disconnections.

SubscriptionFinalizer is a new component that runs on the leader Kuma CP and every N second marks all Insights as a candidate for further disconnect. Those Insights that have connected DPPs (or Zone CPs) the "candidate" status will be unset almost immediately in StatusSink. So it's required 2*N second to finalize the subscription of disconnected DPP (or Zone CP).

Current implementation implies KDS traffic every N second. I think it's fine, but could be improved if we change kds.GenerateSnapshot. Instead of comparing the whole Resource (with Meta) we can check for equality only Resource.Spec, having previously set CandidateForDisconnect to false.

Full changelog

  • add subscriptionFinalizer
  • enable resilient tests
  • new idleTimeout property for kuma-cp config

Issues resolved

Fix #2320

Documentation

Testing

  • Unit tests
  • E2E tests
  • Manual testing on Universal
  • Manual testing on Kubernetes

Backwards compatibility

  • Add backport-to-stable label if the code is backwards compatible. Otherwise, list breaking changes.

Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
@lobkovilya lobkovilya requested a review from a team as a code owner July 28, 2021 14:57
@@ -123,7 +123,7 @@ func NewUpsertOpts(fs ...UpsertFunc) UpsertOpts {
return opts
}

func Upsert(manager ResourceManager, key model.ResourceKey, resource model.Resource, fn func(resource model.Resource), fs ...UpsertFunc) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to give a better name to the fn parameter or to type the func? It's tricky to give a good name because it often relies on side effect but maybe shouldUpdate(res)

api/mesh/v1alpha1/zone_ingress_insight_helpers.go Outdated Show resolved Hide resolved

// CandidateForDisconnect is an indicator if the data plane proxy should be
// disconnected in the near future
bool candidate_for_disconnect = 7;
Copy link
Contributor

Choose a reason for hiding this comment

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

Connection tracking seems like an implementation detail, not something that should be exposed as art of the API.

app/kuma-cp/cmd/run.go Outdated Show resolved Hide resolved
test/framework/interface.go Show resolved Hide resolved
dataplaneResource = ""
} else {
dataplaneResource = opts.appYaml
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we want to use the resource that kubectl rendered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have 2 ways to run DPP on Universal:

  • Create resource using kumactl apply -f ... and run kuma-dp
  • Pass resource directly to kuma-dp like kuma-dp run --dataplane-file ...

Rendering is supported only for the latter flow

pkg/gc/finalizer.go Outdated Show resolved Hide resolved
pkg/gc/finalizer.go Show resolved Hide resolved
err := manager.Upsert(f.rm, core_model.MetaToResourceKey(item.GetMeta()), upsertInsight, func(_ core_model.Resource) bool {
upsertInsight.GetSpec().(kuma_interfaces.Insight).UpdateSubscription(insight.GetLastSubscription())
return true
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way that we an avoid persisting this state, by keeping an in-memory candidate list? There's 2 issues that I'm concerned about (1) exposing this state in the API and (2) write amplification on the data store.

Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>

# Conflicts:
#	api/mesh/v1alpha1/dataplane_insight.pb.go
#	api/system/v1alpha1/zone_insight.pb.go
#	pkg/xds/server/callbacks/dataplane_status_sink_test.go
#	test/framework/universal_cluster.go
Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
@lobkovilya
Copy link
Contributor Author

closing in favor of #2526

@lobkovilya lobkovilya closed this Aug 19, 2021
@lobkovilya lobkovilya deleted the fix/status-finalizer branch October 18, 2021 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dataplane, Zone and ZoneIngress status problem
3 participants