@@ -27,6 +27,7 @@ type CacheInterface interface {
2727 Remove (ctx * contextargs.Context ) // remove a host from the cache
2828 MarkFailed (protoType string , ctx * contextargs.Context , err error ) // record a failure (and cause) for the host
2929 MarkFailedOrRemove (protoType string , ctx * contextargs.Context , err error ) // record a failure (and cause) for the host or remove it
30+ IsPermanentErr (ctx * contextargs.Context , err error ) bool // return true if the error is permanent for the host
3031}
3132
3233var (
@@ -137,8 +138,9 @@ func (c *Cache) Check(protoType string, ctx *contextargs.Context) bool {
137138 defer cache .mu .Unlock ()
138139
139140 if cache .isPermanentErr {
140- // skipping permanent errors is expected so verbose instead of info
141- gologger .Verbose ().Msgf ("Skipped %s from target list as found unresponsive permanently: %s" , finalValue , cache .cause )
141+ cache .Do (func () {
142+ gologger .Info ().Msgf ("Skipped %s from target list as found unresponsive permanently: %s" , finalValue , cache .cause )
143+ })
142144 return true
143145 }
144146
@@ -232,6 +234,28 @@ func (c *Cache) MarkFailedOrRemove(protoType string, ctx *contextargs.Context, e
232234 _ = c .failedTargets .Set (cacheKey , cache )
233235}
234236
237+ // IsPermanentErr returns true if the error is permanent for the host.
238+ func (c * Cache ) IsPermanentErr (ctx * contextargs.Context , err error ) bool {
239+ if err == nil {
240+ return false
241+ }
242+
243+ if errkit .IsKind (err , errkit .ErrKindNetworkPermanent ) {
244+ return true
245+ }
246+
247+ cacheKey := c .GetKeyFromContext (ctx , err )
248+ cache , cacheErr := c .failedTargets .GetIFPresent (cacheKey )
249+ if cacheErr != nil {
250+ return false
251+ }
252+
253+ cache .mu .Lock ()
254+ defer cache .mu .Unlock ()
255+
256+ return cache .isPermanentErr
257+ }
258+
235259// GetKeyFromContext returns the key for the cache from the context
236260func (c * Cache ) GetKeyFromContext (ctx * contextargs.Context , err error ) string {
237261 // Note:
0 commit comments