Skip to content

context.TODO() used in production code (config_dump.go) #8121

@jaffarkeikei

Description

@jaffarkeikei

Found context.TODO() in production troubleshooting code at internal/troubleshoot/collect/config_dump.go:69

Current:

pods, err := listPods(context.TODO(), client, cd.Namespace, labels.SelectorFromSet(...))

Issue:

  • No cancellation/timeout support for Kubernetes API calls
  • Operations can hang indefinitely if API server is slow
  • Can't propagate context from caller

Fix:
Accept context parameter in Collect() method signature:

func (cd ConfigDump) Collect(ctx context.Context, _ chan<- interface{}) (tbcollect.CollectorResult, error) {
    pods, err := listPods(ctx, client, cd.Namespace, ...)
}

Similar pattern found in internal/troubleshoot/collect/prometheus_metrics.go

Location: internal/troubleshoot/collect/config_dump.go:69

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions