ansible-collections / community.kubernetes

Kubernetes Collection for Ansible
https://galaxy.ansible.com/community/kubernetes
GNU General Public License v3.0
265 stars 106 forks source link

Action plugins link not properly created in galaxy tar ball collection #288

Closed Spredzy closed 3 years ago

Spredzy commented 3 years ago
SUMMARY

All the action plugins are symlink to k8s_info.py - When retrieving the tar ball from https://galaxy.ansible.com/community/kubernetes and un-taring locally, those symlinks seem to have tared in a wrong way

[root@localhost foo]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.8 (Maipo)

[root@localhost foo]# tar --version
tar (GNU tar) 1.26

[root@localhost foo]# wget https://galaxy.ansible.com/download/community-kubernetes-1.1.1.tar.gz 2>/dev/null

[root@localhost foo]# tar -xhf community-kubernetes-1.1.1.tar.gz 
tar: plugins/action/helm_plugin.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/k8s_auth.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/helm_repository.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/k8s_scale.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/k8s.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/k8s_service.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/helm_plugin_info.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/k8s_log.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/k8s_exec.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/helm_info.py: implausibly old time stamp 1970-01-01 00:00:00
tar: plugins/action/helm.py: implausibly old time stamp 1970-01-01 00:00:00

[root@localhost foo]# ls -l plugins/action/
total 12
lrwxrwxrwx. 1 root root   11 Jan  1  1970 helm_info.py -> k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 helm_plugin_info.py -> k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 helm_plugin.py -> k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 helm.py -> k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 helm_repository.py -> k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 k8s_auth.py -> k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 k8s_exec.py -> k8s_info.py
-rw-r--r--. 1 root root 9372 Oct  9 18:48 k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 k8s_log.py -> k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 k8s.py -> k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 k8s_scale.py -> k8s_info.py
lrwxrwxrwx. 1 root root   11 Jan  1  1970 k8s_service.py -> k8s_info.py

Note: The Jan 1, 1970 date on all symlinks

ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS

No warnings, proper symlinks

ACTUAL RESULTS

Warnings, wrong date on symlinks

Akasurde commented 3 years ago

Seems like the following works -

diff --git a/lib/ansible/galaxy/collection/__init__.py b/lib/ansible/galaxy/collection/__init__.py
index 058977f8f9..3ddb1435b7 100644
--- a/lib/ansible/galaxy/collection/__init__.py
+++ b/lib/ansible/galaxy/collection/__init__.py
@@ -1079,6 +1079,7 @@ def _build_collection_tar(b_collection_path, b_tar_path, collection_manifest, fi
                         tarinfo.mode = 0o0755 if existing_is_exec or tarinfo.isdir() else 0o0644
                     tarinfo.uid = tarinfo.gid = 0
                     tarinfo.uname = tarinfo.gname = ''
+                    tarinfo.mtime = time.time()

                     return tarinfo
# ls -l plugins/action
total 24
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 helm.py -> k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 helm_info.py -> k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 helm_plugin.py -> k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 helm_plugin_info.py -> k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 helm_repository.py -> k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 k8s.py -> k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 k8s_auth.py -> k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 k8s_exec.py -> k8s_info.py
-rw-r--r--  1 akasurde  wheel  9405 Oct 30 16:26 k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 k8s_log.py -> k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 k8s_scale.py -> k8s_info.py
lrw-r--r--  1 akasurde  wheel    11 Oct 30 16:26 k8s_service.py -> k8s_info.py
tima commented 3 years ago

@Spredzy This looks like an ansible/ansible issue you'll need to open over there.