Quellcode durchsuchen

[DockerRunner] fix metric incrementing and error logging

- do not log on first EPIPE
- inc 'container-inspect-epipe-error' on permanent error only

Co-Authored-By: Tim Alby <timothee.alby@gmail.com>
Jakob Ackermann vor 6 Jahren
Ursprung
Commit
cb9e9321f0
1 geänderte Dateien mit 10 neuen und 13 gelöschten Zeilen
  1. 10 13
      services/clsi/app/js/DockerRunner.js

+ 10 - 13
services/clsi/app/js/DockerRunner.js

@@ -408,31 +408,28 @@ module.exports = DockerRunner = {
           })
           })
         }
         }
       )
       )
-
-    const callbackWithRetry = error => {
-      if (error.message.match(/EPIPE/)) {
-        metrics.inc('container-inspect-epipe-retry')
-        return inspectContainer(container, callback)
-      }
-      callback(error)
-    }
-
-    var inspectContainer = (container, innerCallback) =>
+    var inspectContainer = (isRetry) =>
       container.inspect(function(error, stats) {
       container.inspect(function(error, stats) {
         if ((error != null ? error.statusCode : undefined) === 404) {
         if ((error != null ? error.statusCode : undefined) === 404) {
           return createAndStartContainer()
           return createAndStartContainer()
         } else if (error != null) {
         } else if (error != null) {
-          metrics.inc('container-inspect-epipe-error')
+          if (error.message.match(/EPIPE/)) {
+            if (!isRetry) {
+              metrics.inc('container-inspect-epipe-retry')
+              return inspectContainer(true)
+            }
+            metrics.inc('container-inspect-epipe-error')
+          }
           logger.err(
           logger.err(
             { container_name: name, error },
             { container_name: name, error },
             'unable to inspect container to start'
             'unable to inspect container to start'
           )
           )
-          return innerCallback(error)
+          return callback(error)
         } else {
         } else {
           return startExistingContainer()
           return startExistingContainer()
         }
         }
       })
       })
-    inspectContainer(container, callbackWithRetry)
+    inspectContainer(false)
   },
   },
 
 
   attachToContainer(containerId, attachStreamHandler, attachStartCallback) {
   attachToContainer(containerId, attachStreamHandler, attachStartCallback) {