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

feat(kuma-cp) delete zone #1348

Merged
merged 9 commits into from
Dec 22, 2020
Merged

feat(kuma-cp) delete zone #1348

merged 9 commits into from
Dec 22, 2020

Conversation

lobkovilya
Copy link
Contributor

Summary

Right now if someone is trying to delete ZoneResource in Global, all corresponding resources won't be gone. So Dataplanes and DataplaneInsights will stuck in the cluster until you explicitly wipe them out.

Also deleting ZoneResource while Remote Kuma CP in that zone is still alive, probably not a great idea. Since we create zone automatically there is the method createOrUpdateZone, which will actually be triggered if someone deletes ZoneResource. So the user's intention to delete a zone should ally with the actual Remote CP state. But at the same time, if we have networking issues between Remote CP and Global CP we shouldn't delete ZoneResource automatically, we should show this zone as offline.

So, in order to support these requirements current PR introduces new scenarios:

Delete zone

The user can't delete ZoneResource in Global while Remote CP is alive and connected. Current PR introduces validation for that:

zone: unable to delete Zone, Remote CP is still connected, please shut it down first

So the user has to shutdown Remote CP at first, and only then go and delete ZoneResource.
Also current PR adds ownership relation between synced resources and ZoneResource that allows to cleanup Dataplanes and DataplaneInsights automatically.

Disable zone

There are might be situations when the user doesn't have access to Remote CP but there is a need to stop routing traffic to some specific zone. Current PR introduces a new field in ZoneResources:

spec:
  enabled: true

Changing enabled: false will allow the user to exclude the zone's ingress from all other zones, so traffic won't be directed to the disabled zone. The disabled zone is considered as offline.

Documentation

TBD

Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
@lobkovilya lobkovilya requested a review from a team as a code owner December 22, 2020 13:17
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
@@ -52,7 +52,7 @@ func toZones(rlist system.ZoneOverviewResourceList) Zones {
for _, overview := range rlist.Items {
zones = append(zones, Zone{
Name: overview.GetMeta().GetName(),
Active: overview.Spec.ZoneInsight.IsOnline(),
Active: overview.Spec.GetZoneInsight().IsOnline() && overview.Spec.GetZone().GetEnabled(),
})
}
return zones
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this API still used somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I get it right it is used here:
image
Is it correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Checked the GUI code. Yeah, for some reason it is used. I was pretty sure we want to drop this in favor of insights.

I think we should have a column called enabled / disabled. Putting zone offline when we disable it is not exactly correct.

Let's keep it for now because I don't think it matters, but create a card for getting rid of this endpoint and changing the GUI

@@ -295,6 +296,10 @@ func initializeResourceManager(cfg kuma_cp.Config, builder *core_runtime.Builder
dpInsightManager := dataplaneinsight.NewDataplaneInsightManager(builder.ResourceStore(), builder.Config().Metrics.Dataplane)
customManagers[mesh.DataplaneInsightType] = dpInsightManager

zoneValidater := zone.Validator{Store: builder.ResourceStore()}
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: validater

if err := rm.Get(context.Background(), zone, store.GetByKey(util.ZoneTag(r), model.NoMesh)); err != nil {
kdsGlobalLog.Error(err, "failed to get zone", "zone", util.ZoneTag(r))
// since there is no explicit "enabled: false" sync anyway
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.

shouldn't this be false if we cannot find the zone?

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, I think it can be false. I wasn't sure about ordering, what if there is no Zone when we build a Snapshot. But I see now that it's not cached or something and we build Snapshot from the scratch every time, so delay with Zone creation won't be a problem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed and decided to go with return true to avoid unneeded deletions

@@ -116,13 +125,29 @@ func (s *syncResourceStore) Sync(upstream model.ResourceList, fs ...SyncOptionFu
}
}

zone := system.NewZoneResource()
if opts.Zone != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

in which case it can be ""?
Can we do the Get only when len(onCreate) > 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be "" if you didn't pass Zone("some_zone") option to the Sync.
Yes, good point with checking len(onCreate) > 0

message Zone {
// enable allows to turn the zone on/off and exclude the whole zone from
// balancing traffic on it
bool enabled = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

that's a breaking change. We could do a BoolWrapper and treat nil as true

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, we should!

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a card that for 1.1 we should change this to true by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean treat nil as false since 1.1?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>

# Conflicts:
#	api/go.sum
#	pkg/plugins/resources/k8s/native/go.sum
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
@nickolaev nickolaev merged commit 9d9ee96 into master Dec 22, 2020
@nickolaev nickolaev deleted the feat/delete-zone branch December 22, 2020 18:55
mergify bot pushed a commit that referenced this pull request Dec 22, 2020
* feat(kuma-cp) delete and disable zones

* fix(kuma-cp) display disabled zones as 'offline'
* fix(kuma-cp) fix `kumactl inspect zone` tests

Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
(cherry picked from commit 9d9ee96)
nickolaev pushed a commit that referenced this pull request Dec 22, 2020
* feat(kuma-cp) delete and disable zones

* fix(kuma-cp) display disabled zones as 'offline'
* fix(kuma-cp) fix `kumactl inspect zone` tests

Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
(cherry picked from commit 9d9ee96)

Co-authored-by: Ilya Lobkov <ilya.lobkov@konghq.com>
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.

None yet

3 participants