pkg/configmap/informer
Christie Wilson 2bc944bb68
Fix race: Make informed watcher start wait for Add event 🏎️ (#2036)
* Fix race: Make informed watcher start wait for Add event 🏎️

When using the informed watcher to watch a config map, previously add
events were being processed in a goroutine with no syncrhonization
making it so that code may try to access the values backed by the
configmaps before they are initialized.

This commit makes it so that the Start method of the informer will wait
for the add event to occur at least once for all config maps it is
watching.

This commit also undoes the workaround added in #1929 which was working
around the race condition identified in #1907 (and in
https://github.com/tektoncd/pipeline/issues/3720). This means that if
the synchronization was removed, the impacted test would start flaking
again. If we wanted it to reliably fail in that case, we could introduce
a sleep in the callback but that doesn't seem worth it.

I also tested this change by manually patching the changes into my
clone of tektoncd/pipeline and following the repro steps at
https://github.com/tektoncd/pipeline/issues/2815#issuecomment-733207368
Before the change I can reproduce the issue, and after the change, I
can't! :D

Fixes #1960

* Make synced callback and named wait group private 🕵️

These utility objects don't really make sense to expose as part of the
informed watcher package and are only used by the informed watcher.
Writing tests for unexported code makes me a bit :( but hopefully these
will get moved to some other package one day. And there's really no
reason to expose these to users of knative/pkg at the moment.
2021-03-02 11:58:15 -08:00
..
informed_watcher.go Fix race: Make informed watcher start wait for Add event 🏎️ (#2036) 2021-03-02 11:58:15 -08:00
informed_watcher_test.go Fix race: Make informed watcher start wait for Add event 🏎️ (#2036) 2021-03-02 11:58:15 -08:00
synced_callback.go Fix race: Make informed watcher start wait for Add event 🏎️ (#2036) 2021-03-02 11:58:15 -08:00
synced_callback_test.go Fix race: Make informed watcher start wait for Add event 🏎️ (#2036) 2021-03-02 11:58:15 -08:00