File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -429,7 +429,12 @@ def process_metrics_collector(
429429 docker_prev_pids = set (docker_following_pids .keys ())
430430 docker_prev_notpids = set (docker_avoided_pids )
431431 for container in containers :
432- container_pid = container .attrs .get ("State" , {}).get ("Pid" )
432+ # Skip unidentified container instances
433+ if container .id is None :
434+ continue
435+ container_pid : "Optional[int]" = container .attrs .get (
436+ "State" , {}
437+ ).get ("Pid" )
433438 if container_pid is not None :
434439 if container_pid in docker_prev_pids :
435440 docker_prev_pids .remove (container_pid )
@@ -449,16 +454,20 @@ def process_metrics_collector(
449454 + matched .group (1 )
450455 + "+00:00"
451456 )
452- container_data .append (
453- (
454- container .id ,
455- datetime .datetime .fromisoformat (
456- container_created
457- ).timestamp (),
458- container .attrs ["Config" ].get ("Image" ),
459- container_pid ,
457+ container_image : "Optional[str]" = container .attrs [
458+ "Config"
459+ ].get ("Image" )
460+ if container_image is not None :
461+ container_data .append (
462+ (
463+ container .id ,
464+ datetime .datetime .fromisoformat (
465+ container_created
466+ ).timestamp (),
467+ container_image ,
468+ container_pid ,
469+ )
460470 )
461- )
462471
463472 # Keeping the internal lists clean
464473 if len (docker_prev_notpids ) > 0 :
You can’t perform that action at this time.
0 commit comments