Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Fix oc exec commands #1541

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,54 @@
debug:
msg: "Local storage job folder .......... {{ masbr_storage_job_folder }}"

# Condition 1. src_folder -> dest_folder: copy src_folder/* to dest_folder/*
# Condition 1. src_folder -> dest_folder: copy src_folder/* to dest_folder/*
#
# - exec into masbr_cf_pod_name/masbr_cf_container_name, create temp folder
# - cp from src_folder to temp folder inside masbr_cf_pod_name/masbr_cf_container_name
# - exec into masbr_cf_pod_name/masbr_cf_container_name, move temp_dest_folder to dest_folder and delete temp_dest_folder
- name: "Copy files from local storage folder to pod folder"
when:
- item.src_folder is defined and item.src_folder | length > 0
- item.dest_folder is defined and item.dest_folder | length > 0
shell: >-
oc exec {{ masbr_cf_pod_name }} -c {{ masbr_cf_container_name }} -n {{ masbr_cf_namespace }} -- bash -c
'temp_dest_folder={{ [item.dest_folder, masbr_job_version] | path_join }} &&
mkdir -p ${temp_dest_folder} &&
oc cp --retries=50 -c {{ masbr_cf_container_name }}
{{ [masbr_storage_job_folder, item.src_folder] | path_join }}
{{ masbr_cf_namespace }}/{{ masbr_cf_pod_name }}:${temp_dest_folder} &&
mv -f ${temp_dest_folder}/* {{ item.dest_folder }} &&
rm -rf ${temp_dest_folder}'
'temp_dest_folder={{ [item.dest_folder, masbr_job_version] | path_join }} && mkdir -p ${temp_dest_folder}'
&& oc cp --retries=50 -c {{ masbr_cf_container_name }}
{{ [masbr_storage_job_folder, item.src_folder] | path_join }}
{{ masbr_cf_namespace }}/{{ masbr_cf_pod_name }}:${temp_dest_folder}
&& oc exec {{ masbr_cf_pod_name }} -c {{ masbr_cf_container_name }} -n {{ masbr_cf_namespace }} -- bash -c
'mv -f ${temp_dest_folder}/* {{ item.dest_folder }} && rm -rf ${temp_dest_folder}'
loop: "{{ masbr_cf_paths }}"

# Condition 2. src_file -> dest_folder: copy src_file to dest_folder/src_file
# Condition 2. src_file -> dest_folder: copy src_file to dest_folder/src_file
- name: "Copy file from local storage folder to pod folder"
when:
- item.src_file is defined and item.src_file | length > 0
- item.dest_folder is defined and item.dest_folder | length > 0
shell: >-
oc exec {{ masbr_cf_pod_name }} -c {{ masbr_cf_container_name }} -n {{ masbr_cf_namespace }} -- bash -c
'mkdir -p {{ item.dest_folder }}' &&
oc cp --retries=50 -c {{ masbr_cf_container_name }}
{{ [masbr_storage_job_folder, item.src_file] | path_join }}
{{ masbr_cf_namespace }}/{{ masbr_cf_pod_name }}:{{ item.dest_folder }}
'mkdir -p {{ item.dest_folder }}'
&& oc cp --retries=50 -c {{ masbr_cf_container_name }}
{{ [masbr_storage_job_folder, item.src_file] | path_join }}
{{ masbr_cf_namespace }}/{{ masbr_cf_pod_name }}:{{ item.dest_folder }}
loop: "{{ masbr_cf_paths }}"

# Condition 3. src_file -> dest_file
# Condition 3. src_file -> dest_file
# - exec into masbr_cf_pod_name/masbr_cf_container_name, create temp folder
# - cp from src_folder to temp folder inside masbr_cf_pod_name/masbr_cf_container_name
# - exec into masbr_cf_pod_name/masbr_cf_container_name, move temp_dest_folder to dest_folder and delete temp_dest_folder
- name: "Copy file from local storage folder to pod file"
when:
- item.src_file is defined and item.src_file | length > 0
- item.dest_file is defined and item.dest_file | length > 0
shell: >-
oc exec {{ masbr_cf_pod_name }} -c {{ masbr_cf_container_name }} -n {{ masbr_cf_namespace }} -- bash -c
'temp_dest_folder={{ [item.dest_file|dirname, masbr_job_version] | path_join }} &&
mkdir -p ${temp_dest_folder} &&
oc cp --retries=50 -c {{ masbr_cf_container_name }}
{{ [masbr_storage_job_folder, item.src_file] | path_join }}
{{ masbr_cf_namespace }}/{{ masbr_cf_pod_name }}:${temp_dest_folder} &&
mv -f ${temp_dest_folder}/{{ item.src_file|basename }} {{ item.dest_file }} &&
rm -rf ${temp_dest_folder}'
'temp_dest_folder={{ [item.dest_file|dirname, masbr_job_version] | path_join }} && mkdir -p ${temp_dest_folder}'
&& oc cp --retries=50 -c {{ masbr_cf_container_name }}
{{ [masbr_storage_job_folder, item.src_file] | path_join }}
{{ masbr_cf_namespace }}/{{ masbr_cf_pod_name }}:${temp_dest_folder}
&& oc exec {{ masbr_cf_pod_name }} -c {{ masbr_cf_container_name }} -n {{ masbr_cf_namespace }} -- bash -c
'mv -f ${temp_dest_folder}/{{ item.src_file|basename }} {{ item.dest_file }} && rm -rf ${temp_dest_folder}'
loop: "{{ masbr_cf_paths }}"


Expand Down
Loading