-
Notifications
You must be signed in to change notification settings - Fork 327
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
Conversation
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>
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 |
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.
Is this API still used somewhere?
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.
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
pkg/core/bootstrap/bootstrap.go
Outdated
@@ -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()} |
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.
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 |
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.
shouldn't this be false if we cannot find the zone?
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 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
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.
Discussed and decided to go with return true
to avoid unneeded deletions
pkg/kds/store/sync.go
Outdated
@@ -116,13 +125,29 @@ func (s *syncResourceStore) Sync(upstream model.ResourceList, fs ...SyncOptionFu | |||
} | |||
} | |||
|
|||
zone := system.NewZoneResource() | |||
if opts.Zone != "" { |
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.
in which case it can be ""
?
Can we do the Get only when len(onCreate) > 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.
It will be ""
if you didn't pass Zone("some_zone")
option to the Sync
.
Yes, good point with checking len(onCreate) > 0
api/system/v1alpha1/zone.proto
Outdated
message Zone { | ||
// enable allows to turn the zone on/off and exclude the whole zone from | ||
// balancing traffic on it | ||
bool enabled = 1; |
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's a breaking change. We could do a BoolWrapper and treat nil
as true
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.
Agree, we should!
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.
Add a card that for 1.1 we should change this to true by default
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.
Do you mean treat nil
as false since 1.1?
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.
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>
* 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)
* 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>
Summary
Right now if someone is trying to delete
ZoneResource
in Global, all corresponding resources won't be gone. SoDataplanes
andDataplaneInsights
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 methodcreateOrUpdateZone
, which will actually be triggered if someone deletesZoneResource
. 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 deleteZoneResource
automatically, we should show this zone asoffline
.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: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 cleanupDataplanes
andDataplaneInsights
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
: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 asoffline
.Documentation
TBD