Repository navigation
listwatch: do not duplicate resource versions - #3340
Conversation
2ca9f6d to
34ef014
Compare
34ef014 to
85c6afd
Compare
|
lgtm |
| if len(rvs) != len(mlw) { | ||
| return nil, fmt.Errorf("expected resource version to have %d parts to match the number of ListerWatchers", len(mlw)) | ||
| if len(rvs) != 1 { | ||
| return nil, fmt.Errorf("expected resource version to have 1 parts to match the number of ListerWatchers, got %d", len(rvs)) |
There was a problem hiding this comment.
I don't understand the logic here. The reason we combine multiple resource versions with a slash is to later be able to distribute the resources to multiple watchers. Yet here we are enforcing that there should only be one version. So why not simply not join versions in the first place rather than fail if we did join then?
There was a problem hiding this comment.
Yes you are right but the new exception is that we always must have a single resource version (I realize this makes use of implemention details of resourceVersion right now, but until refactoring its reliable enough judging by our tests and manual testing) there is certainly room for refactoring but we would end up refactoring or removing the entire thing, the aim is to do the minimal to fix the bug yet not modify as this is aimed at 0.40 release. See #3218 for background of this specific one.
| for _, lw := range lws { | ||
| o := options.DeepCopy() | ||
| o.ResourceVersion = resourceVersions[i] | ||
| o.ResourceVersion = resourceVersions[0] |
There was a problem hiding this comment.
This will produce odd results if more than one listerwatcher is given since they'll now be watching from the wrong version. Why not enforce that lws has length == 1? Or that it is a single instance vs a slice?
There was a problem hiding this comment.
Or that it is a single instance vs a slice?
Yes exactly we could simply not pass in a slice and instead a single instance and refactor the entire function, but as mentioned in the description I did not want to focus too much on refactoring the entire thing as this fixes a bug in 0.40 version, but in master as per the linked issue we want to move away from custom multi listwatcher as we had a few bugs with it and it has known issues as we know now as from the research Paul did #3218. Hope that clarifies it? :)
There was a problem hiding this comment.
I'm perfectly happy with a short term fix, just the string slice should be a single string, and we have a single call site, so it's a 3 line change from this one :)
There was a problem hiding this comment.
Agreed, as mentioned, let's make this a single string vs a slice to avoid confusion and unexpected results/usages
There was a problem hiding this comment.
Sure will make the change, but FYI it's not a 3 line change from this one ;)
There was a problem hiding this comment.
My apologies, if it does turn out to be way to complicated I'm happy with not doing it, just wanted us to try.
There was a problem hiding this comment.
No worries, just need to adjust all the unit tests and retest on vanilla k8s and OpenShift clusters and CI so might take a day or two longer depending on CI. :) WIP until then.
There was a problem hiding this comment.
just chiming in that my fear is that without this last change we are leaving the library in a particularly weird place where it doesn't attempt to do the things it is supposedly designed for (even if the original impl has bugs). I am worried that this will be confusing and could lead to future issues or misunderstandings
There was a problem hiding this comment.
understandable, I'm not too worried since this is just on the release branch, and not into master, but leaving it up to Lili to judge the trade-offs, I'm happy with going either way
brancz
left a comment
There was a problem hiding this comment.
lgtm once we change the resourceVersion to a single string
| for _, lw := range lws { | ||
| o := options.DeepCopy() | ||
| o.ResourceVersion = resourceVersions[i] | ||
| o.ResourceVersion = resourceVersions[0] |
There was a problem hiding this comment.
I'm perfectly happy with a short term fix, just the string slice should be a single string, and we have a single call site, so it's a 3 line change from this one :)
7a69396 to
a07e6c5
Compare
a07e6c5 to
47dd8c7
Compare
|
We have one failure:
But I have checked and seems like we have had this failure or similar before a few times. Will restart the build. |
|
I believe the code here introduces cascading failures again. The way I read the code here is that we might join resource versions in [1] [2] prometheus-operator/pkg/listwatch/listwatch.go Lines 176 to 178 in 0dca0f2 |
|
Also, I am trying to understand the reasoning for the fix. Do we assume here, that we will always get only one resource version from all underlying watchers the rationale being that API server always returns the latest resource version independent of the namespace being watched? |
prometheus-operator#3340 added a workaround to err out if multiple resource versions are reported from api server. However the preceeding List function allows multiple resource versions to slip through. This causes potential cascading failures.
prometheus-operator#3340 added a workaround to err out if multiple resource versions are reported from api server. However the preceeding List function allows multiple resource versions to slip through. This causes potential cascading failures.
This fixes a known bug #3218 as well as an unknown until the 0.39 release where List and Watch were producing a large amount of errors most likely due to a combination of bumping client-go, using multi namespace watcher and removing the CRD management done by operator. This left the option of the multi list watcher to create a wrong set of resourceVersions because of duplicates, most likely due to large amount of resources filling the cache at startup. As all of these things combined is very rare, even hard to reproduce, which is why this was most likely not experienced by a lot of users, hence lack of bug reports.
Note: I really want to move away from using a custom multi namespace watcher very soon so did not spend too much time on refactor. #3339
This was tested on both vanilla k8s 1.18.3 and more complex setup of OpenShift monitoring where we make heavy use of this feature.
cc @coreos/team-monitoring
Thanks @mfojtik for the initial fix.
Fixes #3218