swarmkit icon indicating copy to clipboard operation
swarmkit copied to clipboard

[bump_20.10 backport ]Fix panic in agent

Open thaJeztah opened this issue 4 years ago • 2 comments

backport of https://github.com/docker/swarmkit/pull/3024 for 20.10 (already back ported to 19.03 through https://github.com/docker/swarmkit/pull/3031)

Previously, there was an issue where the agent could panic while attempting to determine if an error was temporary.

Before the change, in agent/exec/errors.go, the function IsTemporary attempted to drill down to a root cause by iterating through the causes of an error by calling errors.Cause. If an error has no cause, then errors.Cause returns that same error.

The issue is that somewhere in the depths of some code, it was posssible for the error to have an underlying type that was non-comparable; for example, maps and slices are uncomparable types. This would cause a panic, as the uncomparable type cannot be compared even to itself.

However, one can see that errors.Cause has its own loop, and drills down to the root cause in its own way. There is no need for us to iterate here.

Instead, we can just take a look at the error itself, and then take a look at its cause once. If neither is temporary, the error is not temporary, and we have nothing to worry about.

Signed-off-by: Drew Erny [email protected] (cherry picked from commit 39a4233ee6f3f87a83da0e64386fbeb09cdd88b7) Signed-off-by: Sebastiaan van Stijn [email protected]

- What I did

- How I did it

- How to test it

- Description for the changelog

thaJeztah avatar Oct 27 '21 09:10 thaJeztah

@dperny PTAL

thaJeztah avatar Oct 27 '21 09:10 thaJeztah

Codecov Report

Merging #3032 (2a87c2b) into bump_20.10 (286f457) will increase coverage by 0.01%. The diff coverage is 20.00%.

@@              Coverage Diff               @@
##           bump_20.10    #3032      +/-   ##
==============================================
+ Coverage       61.89%   61.91%   +0.01%     
==============================================
  Files             142      142              
  Lines           23031    23029       -2     
==============================================
+ Hits            14256    14258       +2     
+ Misses           7284     7277       -7     
- Partials         1491     1494       +3     

codecov[bot] avatar Oct 27 '21 10:10 codecov[bot]