@@ -264,6 +264,7 @@ def run(self):
264264 self .errored = True
265265 logger .debug ("received exception: {exc}" .format (exc = str (exc )))
266266
267+ self .populate_container_info ()
267268 if self .timed_out or self .errored :
268269 self .kill_container ()
269270
@@ -472,6 +473,23 @@ def events(self):
472473 old_events = old_evnts
473474 yield event
474475
476+ @property
477+ def image_info (self ):
478+ '''
479+ Returns the containerized image hash
480+
481+ Example:
482+ sha256:1a12542b7621f221f3b7189cbddb6689f1f18f677366e66abf9c4719d3bc91be
483+ '''
484+ image_info_path = os .path .join (self .config .artifact_dir , "image_info" )
485+ if not self .config .containerized :
486+ logger .info ("Runner runtime is not containerized" )
487+ elif not os .path .exists (image_info_path ):
488+ logger .warn ("Container Image runtime information is not available" )
489+ return None
490+ with open (image_info_path ) as f :
491+ return f .read ()
492+
475493 @property
476494 def stats (self ):
477495 '''
@@ -513,10 +531,29 @@ def kill_container(self):
513531 proc = Popen (cmd , stdout = PIPE , stderr = PIPE )
514532 _ , stderr = proc .communicate ()
515533 if proc .returncode :
516- logger .info ('Error from {} kill {} command:\n {}' .format (container_cli , container_name , stderr ))
534+ logger .warn ('Error from {} kill {} command:\n {}' .format (container_cli , container_name , stderr ))
517535 else :
518536 logger .info ("Killed container {}" .format (container_name ))
519537
538+ def populate_container_info (self , filter_parameters = "{{Image}}" ):
539+ '''
540+ Gather the Execution Environment image id for storing alongside the runtime artifacts
541+ '''
542+ container_name = self .config .container_name
543+ if container_name :
544+ container_cli = self .config .process_isolation_executable
545+ cmd = [container_cli , 'inspect' ]
546+ if filter_parameters :
547+ cmd .append ("-f" )
548+ cmd .append (filter_parameters )
549+ filter_parameters .append (container_name )
550+ image_info = os .path .join (self .config .private_data_dir , "image_info" )
551+ with open (image_info ) as f :
552+ proc = Popen (cmd , stdout = f , stderr = PIPE )
553+ _ , stderr = proc .communicate ()
554+ if proc .returncode :
555+ logger .warn ('Error from {} inspect {} command:\n {}' .format (container_cli , container_name , stderr ))
556+
520557 @classmethod
521558 def handle_termination (cls , pid , pidfile = None , is_cancel = True ):
522559 '''
0 commit comments