kubernetes-sigs / cli-utils

This repo contains binaries that built from libraries in cli-runtime.
Apache License 2.0
155 stars 77 forks source link

safely consuming kstatus collector updates #626

Open ecordell opened 1 year ago

ecordell commented 1 year ago

The collector protects ResourceStatuses with a mutex for updates, but then passes the whole object to a notify callback:

https://github.com/kubernetes-sigs/cli-utils/blob/8609e42fe8677bfc3a8ae13583b4b31540f1f0a3/pkg/kstatus/polling/collector/collector.go#L91-L93

Since the callback runs in a goroutine without any synchronization, the read is racy (and potentially very out of date).

The simplest way to fix it would be to lock around the notify call, but of course then observers can potentially block the poller. I thought I'd open an issue since there should probably be some discussion around the intended use.

k8s-triage-robot commented 6 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 5 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

ecordell commented 5 months ago

/remove-lifecycle rotten

k8s-triage-robot commented 2 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 1 month ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

karlkfi commented 1 month ago

pkg/kstatus/polling should probably be deprecated. pkg/kstatus/watcher is the preferred way to get status updates now.

If you want to make a PR to fix it, I'll review it, but we're not really investing in the polling any more.