diff options
author | Steve Milner <smilner@redhat.com> | 2017-08-15 17:57:45 -0400 |
---|---|---|
committer | Steve Milner <smilner@redhat.com> | 2017-08-15 18:02:28 -0400 |
commit | cba2765d6af705f66a806c55640ea3fd8a7e34f8 (patch) | |
tree | 4797ed69c5a963cf3206cbca73d7833bca6a97c4 | |
parent | bf27e05caafb41638f82a64dda7c9dc7fc3ce874 (diff) | |
download | openshift-cba2765d6af705f66a806c55640ea3fd8a7e34f8.tar.gz openshift-cba2765d6af705f66a806c55640ea3fd8a7e34f8.tar.bz2 openshift-cba2765d6af705f66a806c55640ea3fd8a7e34f8.tar.xz openshift-cba2765d6af705f66a806c55640ea3fd8a7e34f8.zip |
bug: container_binary_sync no longer moves upon symlinks
With origin 1.5, /usr/local/bin/oc was a symlink to
/usr/local/bin/openshift. During the container_binary_sync updated
versions of both binaries are copied to the host. First openshift is
copied to /usr/local/bin/openshift followed by copying oc to
/usr/local/bin/oc. Since oc is a symlink back to
/usr/local/bin/openshift the end result was everything linked to oc.
This change adds a check before copying a binary. If the destination is
a symlink then said symlink is removed before copying the new binary
over.
Fixed #4965
Reference: https://github.com/openshift/openshift-ansible/issues/4965
-rw-r--r-- | roles/openshift_cli/library/openshift_container_binary_sync.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/roles/openshift_cli/library/openshift_container_binary_sync.py b/roles/openshift_cli/library/openshift_container_binary_sync.py index c47203211..b40c49701 100644 --- a/roles/openshift_cli/library/openshift_container_binary_sync.py +++ b/roles/openshift_cli/library/openshift_container_binary_sync.py @@ -133,6 +133,11 @@ class BinarySyncer(object): dest_path = os.path.join(self.bin_dir, binary_name) incoming_checksum = self.module.run_command(['sha256sum', src_path])[1] if not os.path.exists(dest_path) or self.module.run_command(['sha256sum', dest_path])[1] != incoming_checksum: + + # See: https://github.com/openshift/openshift-ansible/issues/4965 + if os.path.islink(dest_path): + os.unlink(dest_path) + self.output.append('Removed old symlink {} before copying binary.'.format(dest_path)) shutil.move(src_path, dest_path) self.output.append("Moved %s to %s." % (src_path, dest_path)) self.changed = True |