Skip to content

Commit 44bc720

Browse files
author
Cornelius Weig
committed
Add workaround for k8s bug concerning componentstatus and selectors
1 parent 790bded commit 44bc720

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

pkg/ketall/client/client.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func GetAllServerResources(flags *genericclioptions.ConfigFlags) (runtime.Object
5252
return nil, errors.Wrap(err, "fetch available group resources")
5353
}
5454

55-
resources := extractRelevantResources(grs, viper.GetStringSlice(constants.FlagExclude))
55+
resources := extractRelevantResources(grs, getExclusions())
5656

5757
start := time.Now()
5858
response, err := fetchResourcesBulk(flags, resources...)
@@ -64,6 +64,17 @@ func GetAllServerResources(flags *genericclioptions.ConfigFlags) (runtime.Object
6464
return fetchResourcesIncremental(flags, resources...)
6565
}
6666

67+
func getExclusions() []string {
68+
exclusions := viper.GetStringSlice(constants.FlagExclude)
69+
70+
// This is a workaround for a k8s bug where componentstatus is reported even though the label selector does not apply
71+
if selector := viper.GetString(constants.FlagSelector); selector != "" {
72+
exclusions = append(exclusions, "componentstatuses")
73+
}
74+
75+
return exclusions
76+
}
77+
6778
func fetchAvailableGroupResources(cache bool, scope string, flags *genericclioptions.ConfigFlags) ([]groupResource, error) {
6879
client, err := flags.ToDiscoveryClient()
6980
if err != nil {

0 commit comments

Comments
 (0)