From 2bdedeff621b223d63cebc4355fcf83bc68412cd Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:32:22 -0500 Subject: [PATCH] fix(compute/metadata): check error chain for retryable error (#10840) Thanks to @ianlancetaylor for pointing this out! --- compute/metadata/retry_linux.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compute/metadata/retry_linux.go b/compute/metadata/retry_linux.go index bb412f8917e3..2e53f0123009 100644 --- a/compute/metadata/retry_linux.go +++ b/compute/metadata/retry_linux.go @@ -17,10 +17,15 @@ package metadata -import "syscall" +import ( + "errors" + "syscall" +) func init() { // Initialize syscallRetryable to return true on transient socket-level // errors. These errors are specific to Linux. - syscallRetryable = func(err error) bool { return err == syscall.ECONNRESET || err == syscall.ECONNREFUSED } + syscallRetryable = func(err error) bool { + return errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.ECONNREFUSED) + } }