You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
k8s_cp doesn't work correctly when k8s container deployed with WORKDIR other than '/'.
on uploading( state:to_pod ), k8s_cp copies to ${WORKDIR}/${remote_path} but not ${remote_path} even given remote_path is full path ('/tmp/...')
some docker image sets WORKDIR(workingDir in k8s) other than '/' , like official golang image sets to /go,
then, k8s_cp cannot work with such container.
deploy container on k8s with "workingDir:/otherthanRoot" (official golang image is easy to test)
k8s_cp with {local_path: /tmp/any.txt, remote_path: /tmp/any.txt, state: to_pod }
k8s_cp returns without error.
login the container shell with "kubectl exec ...", and check if /tmp/any.txt is exist.
=> file is uploaded in wrong path, ${workingDir}/tmp/any.txt but not /tmp/any.txt
official golang image set WORK_DIR as /go so, it cannot upload to golang based container.
Following are my test codes.
ansible-playbook -i hosts -e test=alpine:latest
=> when workindDir is '/home' => failed always (uploaded in wrong path, even official alpine nor debian)
=> if workingDir is '/', => succeeded (official golang as well)
=> if workingDir is undefined => depends on images's WORKDIR (may '/', '/go', ...)
if path (remote_path or local_path) is started with '/' (i.e. full path),
then k8s_cp should upload/download to the given path but not other place ( ${workingDir}/* )
ACTUAL RESULTS
k8s_cp upload files under ${workingDir}/tmp/... even remote_file is specified to /tmp/...
The text was updated successfully, but these errors were encountered:
to maintainers,
I investigated some about this issue and found that:
k8s_cp just calls REST API of /api/v1/namespaces/{namespace}/pods/{name}/execusing via connect_get_namespaced_pod_exec in kubernetes.client.api.core_v1_api
there is no param to change directory before executing command in the above REST API.
fortunately, tar command (which k8s_cp using) has special option '-C /changeDirectoryBeforeExection'.
so appending '-C /' may be easiest way when full path specified.
Thanks for taking the time to report this issue and provide full details to reproduce.
Thanks also for the pull request, we will take some time to review it.
#223)
fix k8s_cp uploading when deployed container's WORKDIR is other than '/'
SUMMARY
fix#222
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
k8s_cp
ADDITIONAL INFORMATION
Reviewed-by: Mike Graves <[email protected]>
Reviewed-by: None <None>
Reviewed-by: None <None>
SUMMARY
k8s_cp doesn't work correctly when k8s container deployed with WORKDIR other than '/'.
on uploading( state:to_pod ), k8s_cp copies to ${WORKDIR}/${remote_path} but not ${remote_path} even given remote_path is full path ('/tmp/...')
some docker image sets WORKDIR(workingDir in k8s) other than '/' , like official golang image sets to /go,
then, k8s_cp cannot work with such container.
ISSUE TYPE
COMPONENT NAME
not sure but may be somewhere kubernetes.core.k8s_cp to
https://github.com/kubernetesclient/python/blob/master/kubernetes/client/api/core_v1_api.py
ANSIBLE VERSION
COLLECTION VERSION
I install kubernetes.core with latest github main branch
CONFIGURATION
OS / ENVIRONMENT
debian:bullseye
STEPS TO REPRODUCE
install latest kubernetes.core by
ansible-galaxy collection install git+https://github.com/ansible-collections/kubernetes.core.git
deploy container on k8s with "workingDir:/otherthanRoot" (official golang image is easy to test)
k8s_cp with {local_path: /tmp/any.txt, remote_path: /tmp/any.txt, state: to_pod }
k8s_cp returns without error.
login the container shell with "kubectl exec ...", and check if /tmp/any.txt is exist.
=> file is uploaded in wrong path, ${workingDir}/tmp/any.txt but not /tmp/any.txt
official golang image set WORK_DIR as /go so, it cannot upload to golang based container.
Following are my test codes.
ansible-playbook -i hosts -e test=alpine:latest
=> when workindDir is '/home' => failed always (uploaded in wrong path, even official alpine nor debian)
=> if workingDir is '/', => succeeded (official golang as well)
=> if workingDir is undefined => depends on images's WORKDIR (may '/', '/go', ...)
EXPECTED RESULTS
if path (remote_path or local_path) is started with '/' (i.e. full path),
then k8s_cp should upload/download to the given path but not other place ( ${workingDir}/* )
ACTUAL RESULTS
k8s_cp upload files under ${workingDir}/tmp/... even remote_file is specified to /tmp/...
The text was updated successfully, but these errors were encountered: