Skip to content

Commit

Permalink
fix: Exclude duplicated resource types
Browse files Browse the repository at this point in the history
When resource types migrate to a new API group, its old version will
still be accessible for the next few versions of Kubernetes
(eg. "events.v1" -> "events.v1.events.k8s.io") so we filter them out to
avoid wasting effort on processing the same set of objects received
from the resource's old & new API twice.

Signed-off-by: Justin Toh <tohjustin@hotmail.com>
  • Loading branch information
tohjustin committed Sep 11, 2021
1 parent 6aa1f2c commit 481de38
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/cmd/lineage/lineage.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,19 @@ func (o *CmdOptions) getAPIResources() ([]Resource, error) {
continue
}
for _, resource := range list.APIResources {
// filter resources that can be watched, listed & get
// Filter resources that can be watched, listed & get
if len(resource.Verbs) == 0 || !sets.NewString(resource.Verbs...).HasAll("watch", "list", "get") {
continue
}
// Exclude duplicated resources (for Kubernetes v1.18 & above)
switch {
// migrated to "events.v1.events.k8s.io"
case gv.Group == "" && resource.Name == "events":
continue
// migrated to "ingresses.v1.networking.k8s.io"
case gv.Group == "extensions" && resource.Name == "ingresses":
continue
}
resources = append(resources, Resource{
APIGroupVersionResource: schema.GroupVersionResource{
Group: gv.Group,
Expand Down

0 comments on commit 481de38

Please sign in to comment.