-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually stop trying to time out finished Runs ⏰
In 10b6427 I got really enthusiastic about making sure even our reads were threadsafe and so I thought I would be clever and, instead of accessing attributes of a PipelineRun or TaskRun in a go routine, use a value that wouldn't change - specifically the address. But the address will change between reconcile loops, because the reconcile logic will create a new instance of the Run object every time! 🤦♀️ Fortunately this doesn't cause any serious problems, it just makes things slightly less efficient: for every Run you start, a go routine will remain open until the timeout occurs, and when it fires, it will be reconciled an extra time, even if it has completed. (In fact keeping this functionality completed and dropping the "done" map might be a reasonable option!) With this change, we now return to using the namespace + name as a key in the map that tracks the done channels; we pass these by value so that reads will be threadsafe. Instead of fixing this separately for the TaskRun and PipelineRun functions, I've collapsed these and the callback into one. Each handler instantiates its own timeout handler so there is no reason for the timeout handler to have special knowledge of one vs the other. Fixes #3047 _Test_ I tried several different approaches to add a test case that would reveal the underlying problem but I now feel like it's more hassle than it's worth. Approaches: 1. instantiate the controller in the reconciler tests with a custom timeout handler that has been overridden to use a custom logger, so we can check for the log indicating the timeout handler completed 2. Similar to (1) but instead of checking logs, just pass in a custom done channel and wait for it to close Both 1 + 2 require changing the way that NewController works, i.e. the way we always instantiate controllers. I tried working around this by taking the same approach as `TestHandlePodCreationError` and instantiating my own Reconciler but it a) wasn't instantiated properly no matter what I tried (trying to use it created panics) and b) had a confusingly different interface, exposing ReconcileKind instead of Reconcile I tried some other approaches but these went nowhere either; I don't think it's worth adding a test to cover this, but if folks feel strongly I don't mind opening an issue at least to continue to explore it? I feel that this bug is one that is very specific to the implementation and I'm not sure how valuable a test that covers it would be. If we do pursue it, we might want to do it at the level of an end to end test that actually checks the logs from a real running controller.
- Loading branch information
1 parent
3a4d59c
commit 2611ebf
Showing
12 changed files
with
114 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.