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): filter out old dangling zone resources in global (backport of #10245) #10268

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pkg/kds/global/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,15 @@ func Callbacks(s sync_store.ResourceSyncer, k8sStore bool, kubeFactory resources
}

return s.Sync(rs, sync_store.PrefilterBy(func(r model.Resource) bool {
if !supportsHashSuffixes {
// todo: remove in 2 releases after 2.6.x
return strings.HasPrefix(r.GetMeta().GetName(), fmt.Sprintf("%s.", clusterName))
}
return r.GetMeta().GetLabels()[mesh_proto.ZoneTag] == clusterName
// Assuming the global CP was updated first, the prefix check is only necessary
// if the client doesn't have `supportsHashSuffixes`.
// But maybe some prefixed resources were previously synced, we
// can filter them and the zone won't sync them again.
// When we are further from this migration we can remove this
// check.
hasOldStylePrefix := strings.HasPrefix(r.GetMeta().GetName(), fmt.Sprintf("%s.", clusterName))
hasZoneLabel := r.GetMeta().GetLabels()[mesh_proto.ZoneTag] == clusterName
return hasOldStylePrefix || hasZoneLabel
}), sync_store.Zone(clusterName))
},
}
Expand Down
14 changes: 9 additions & 5 deletions pkg/kds/v2/store/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,15 @@ func GlobalSyncCallback(
}

return syncer.Sync(ctx, upstream, PrefilterBy(func(r model.Resource) bool {
if !supportsHashSuffixes {
// todo: remove in 2 releases after 2.6.x
return strings.HasPrefix(r.GetMeta().GetName(), fmt.Sprintf("%s.", upstream.ControlPlaneId))
}
return r.GetMeta().GetLabels()[mesh_proto.ZoneTag] == upstream.ControlPlaneId
// Assuming the global CP was updated first, the prefix check is only necessary
// if the client doesn't have `supportsHashSuffixes`.
// But maybe some prefixed resources were previously synced, we
// can filter them and the zone won't sync them again.
// When we are further from this migration we can remove this
// check.
hasOldStylePrefix := strings.HasPrefix(r.GetMeta().GetName(), fmt.Sprintf("%s.", upstream.ControlPlaneId))
hasZoneLabel := r.GetMeta().GetLabels()[mesh_proto.ZoneTag] == upstream.ControlPlaneId
return hasOldStylePrefix || hasZoneLabel
}), Zone(upstream.ControlPlaneId))
},
}
Expand Down
Loading