From 46bef931e971cfcea58165b0cbb84034c4fb164b Mon Sep 17 00:00:00 2001
From: Sergey Kolekonov <skolekonov@mirantis.com>
Date: Fri, 12 Jul 2019 14:29:07 +0400
Subject: [PATCH] Fix images info logic for containerd (#4965)

As crictl tool is used to download images, it must be also used to gather
images info
---
 roles/download/tasks/download_prep.yml | 42 --------------------------
 roles/download/tasks/prep_download.yml |  2 +-
 2 files changed, 1 insertion(+), 43 deletions(-)
 delete mode 100644 roles/download/tasks/download_prep.yml

diff --git a/roles/download/tasks/download_prep.yml b/roles/download/tasks/download_prep.yml
deleted file mode 100644
index ace884c25..000000000
--- a/roles/download/tasks/download_prep.yml
+++ /dev/null
@@ -1,42 +0,0 @@
----
-# Use the same format for Containerd images as for Docker images
-# ctr doesn't have inspect command
-
-- name: Set image info command for containerd
-  set_fact:
-    image_info_command: "{{ containerd_bin_dir }}/ctr images ls | tail -n +2 | awk -F '[ :]+' '{print $1\":\"$2\",\"$1\":\"$4\"@\"$5}' | tr '\n' ','"
-  when: container_manager == 'containerd'
-
-- name: Register docker images info
-  shell: "{{ image_info_command }}"
-  no_log: true
-  register: docker_images
-  failed_when: false
-  changed_when: false
-  check_mode: no
-  when: download_container
-
-- name: container_download | Create dest directory for saved/loaded container images
-  file:
-    path: "{{ local_release_dir }}/containers"
-    state: directory
-    recurse: yes
-    mode: 0755
-    owner: "{{ ansible_ssh_user|default(ansible_user_id) }}"
-  when: download_container
-
-- name: container_download | create local directory for saved/loaded container images
-  file:
-    path: "{{ local_release_dir }}/containers"
-    state: directory
-    recurse: yes
-  delegate_to: localhost
-  delegate_facts: false
-  become: false
-  run_once: true
-  when:
-    - download_run_once
-    - download_delegate == 'localhost'
-    - download_container
-  tags:
-    - localhost
diff --git a/roles/download/tasks/prep_download.yml b/roles/download/tasks/prep_download.yml
index c35634115..52fbfc854 100644
--- a/roles/download/tasks/prep_download.yml
+++ b/roles/download/tasks/prep_download.yml
@@ -7,7 +7,7 @@
 
 - name: Set image info command for containerd
   set_fact:
-    image_info_command: "{{ containerd_bin_dir }}/ctr images ls | tail -n +2 | awk -F '[ :]+' '{print $1\":\"$2\",\"$1\":\"$4\"@\"$5}' | tr '\n' ','"
+    image_info_command: "{{ bin_dir }}/crictl images --verbose | awk -F ': ' '/RepoTags|RepoDigests/ {print $2}' | tr '\n' ','"
   when: container_manager == 'containerd'
 
 - name: Register docker images info
-- 
GitLab