Skip to content

Return the same error from Updater after closing

Sami Hiltunen requested to merge smh-fix-flaky-updater-error into master

Updater's error handling is somewhat complicated as the actual update-ref command may error at any point between the calls. Some of the error conditions, like doing an invalid reference update, may only yield an error on the next method call as the update-ref process executes the commands asynchronously. This has then led to somewhat complicated error handling code which can currently return different errors from different methods. For example, context being canceled may not return a context canceled error but may actually lead to returning an invalid state transition error.

This commit tries to clean the error handling up by centralizing it in the Close method. The rules are as follows:

  1. If stderr contains an error we recognize, return the spcific error.
  2. If the command failed but we don't recognize the error, return the error from the command and add the stderr as metadata so the reason will be clear in logs.
  3. If the command didn't error but our logic did, return our error.

Once Close has been called, the error returned by the call will be returned from all methods. This will ensure for example that context cancellation errors are returned from every method call, not just the ones that check for it.

Closes #5476 (closed)

Merge request reports