From 2aafab6c1950fbe3e216dec758d1ce786df84883 Mon Sep 17 00:00:00 2001
From: ERIK <bo.jiang@daocloud.io>
Date: Tue, 27 Jun 2023 09:08:30 +0800
Subject: [PATCH] fix etcdctl copy operation in crio (#10242)

Signed-off-by: bo.jiang <bo.jiang@daocloud.io>
---
 roles/etcdctl/tasks/main.yml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/roles/etcdctl/tasks/main.yml b/roles/etcdctl/tasks/main.yml
index d046c9fb2..3f0a9d2e1 100644
--- a/roles/etcdctl/tasks/main.yml
+++ b/roles/etcdctl/tasks/main.yml
@@ -42,7 +42,10 @@
     when: container_manager ==  "docker"
 
   - name: Copy etcdctl script to host
-    shell: "{{ bin_dir }}/nerdctl cp \"$({{ bin_dir }}/crictl ps -q --image {{ etcd_image_repo }}:{{ etcd_image_tag }})\":/usr/local/bin/etcdctl {{ etcd_data_dir }}/etcdctl"
+    shell: >-
+      etcd_ctr_id="$({{ bin_dir }}/crictl ps -q --image {{ etcd_image_repo }}:{{ etcd_image_tag }})" &&
+      etcd_ctr_pid="$({{ bin_dir }}/crictl inspect --output go-template --template '{{ '{{' }} .info.pid {{ '}}' }}' ${etcd_ctr_id})" &&
+      cp /proc/${etcd_ctr_pid}/root/usr/local/bin/etcdctl {{ etcd_data_dir }}/etcdctl
     when: container_manager in ['crio', 'containerd']
 
   - name: Copy etcdctl to {{ bin_dir }}
-- 
GitLab