@@ -377,21 +377,37 @@ def get_service_images(kolla_ansible_path: str, services: str):
377377 """Get space separated list of images used by selected services in Kolla Ansible"""
378378 hierarchy = get_hierarchy (kolla_ansible_path )
379379 services_list = []
380+ is_filtered = False
380381 if services :
381382 services_list = services .split (" " )
382- reversed_hierarchy = []
383+ is_filtered = True
384+ images_list = []
383385 child_re = re .compile (r"^([a-z0-9_]+)_tag$" )
384386 parent_re = re .compile (r"{{[\s]*([a-z0-9_]+)_tag[\s]*}}" )
387+ parents_no_child_set = set ()
385388 for child , parent in hierarchy .items ():
386389 child_name = child_re .match (child ).group (1 )
387390 parent_name = parent_re .match (parent ).group (1 )
388- if (
389- parent_name == "openstack" or
390- (len (services_list ) > 0 and parent_name not in services_list )
391- ):
392- continue
393- reversed_hierarchy .append (child_name )
394- images_str = " " .join (reversed_hierarchy ).replace ("_" , "-" )
391+ # This is parent
392+ if parent_name == "openstack" :
393+ # And part of the query or no services specified
394+ if is_filtered and child_name in services_list or not is_filtered :
395+ parents_no_child_set .add (child_name ) # Add to parent list
396+ continue # Then move on
397+ # This service is not part of the query
398+ if is_filtered and parent_name not in services_list :
399+ continue # ignore
400+ # Child found
401+ if parent_name in parents_no_child_set :
402+ parents_no_child_set .discard (parent_name ) # Remove parent that has child
403+ images_list .append (child_name ) # Add the child to the list
404+ # Add parent with no child
405+ images_list += list (parents_no_child_set )
406+ # NOTE(seunghun1ee): Currently K-A has inconsistency on mariadb tag on 2025.1 release
407+ # Adding manually
408+ if is_filtered and "mariadb" in services_list or not is_filtered :
409+ images_list .append ("mariadb" )
410+ images_str = " " .join (images_list ).replace ("_" , "-" )
395411 print (images_str )
396412
397413
0 commit comments