Skip to content

Commit dcefba0

Browse files
authored
Add indexer to fix exec command (#1917)
1 parent d98e1ea commit dcefba0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

kubectl-fdb/cmd/k8s_client.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ func getKubeClient(ctx context.Context, o *fdbBOptions) (client.Client, error) {
9696
return nil, err
9797
}
9898

99+
// Setup index field to allow access to the status phase of a Pod more efficiently. The indexer must be created before the
100+
// informer is started.
101+
err = internalCache.IndexField(ctx, &corev1.Pod{}, "status.phase", func(object client.Object) []string {
102+
return []string{string(object.(*corev1.Pod).Status.Phase)}
103+
})
104+
105+
if err != nil {
106+
return nil, err
107+
}
108+
99109
// Make sure the internal cache is started.
100110
go func() {
101111
_ = internalCache.Start(ctx)

0 commit comments

Comments
 (0)