Skip to content

Commit

Permalink
fix(kuma-cp): filter out old dangling zone resources in global (#10245)
Browse files Browse the repository at this point in the history
Co-authored-by: Ilya Lobkov <lobkovilya@yandex.ru>
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont and lobkovilya authored May 16, 2024
1 parent 6808a51 commit 590d02c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions pkg/kds/global/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,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 @@ -366,11 +366,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

0 comments on commit 590d02c

Please sign in to comment.