Skip to content

Commit

Permalink
In case of 'src_path_content' in upstream does not exist,
Browse files Browse the repository at this point in the history
like was removed by PR,
then 'os.readlink(src_path_content)' failed with
traceback 'FileNotFoundError'.

See real error:
rh_cwt.main.distgit - DEBUG: unlink nginx-124/results/test/run-openshift
Traceback (most recent call last):
  File "/usr/local/bin/rhcwt", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/home/phracek/.local/lib/python3.12/site-packages/rh_cwt/cli.py", line 169, in run
    cli.run()
  File "/home/phracek/.local/lib/python3.12/site-packages/rh_cwt/cli.py", line 163, in run
    run_function()
  File "/home/phracek/.local/lib/python3.12/site-packages/rh_cwt/main.py", line 369, in dist_git_merge_changes
    super(RhelImageRebuilder, self).dist_git_merge_changes(rebase)
  File "/home/phracek/.local/lib/python3.12/site-packages/container_workflow_tool/main.py", line 578, in dist_git_merge_changes
    self.distgit.dist_git_merge_changes(images, rebase)
  File "/home/phracek/.local/lib/python3.12/site-packages/container_workflow_tool/distgit.py", line 99, in dist_git_merge_changes
    self.pull_upstream(component, path, url, repo, ups_name, commands)
  File "/home/phracek/.local/lib/python3.12/site-packages/container_workflow_tool/git_operations.py", line 259, in pull_upstream
    self.sync_handler.handle_dangling_symlinks(cp_path, component)
  File "/home/phracek/.local/lib/python3.12/site-packages/container_workflow_tool/sync.py", line 101, in handle_dangling_symlinks
    os.readlink(src_path_content))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'upstreams/nginx/1.24/results/test/run-openshift'

Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek committed Nov 11, 2024
1 parent d1fe4ee commit 61734a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
dockerfiles: ./Dockerfile.generator
image: cwt-generator
tags: latest 1 ${{ github.sha }} 1.5.9
tags: latest 1 ${{ github.sha }} 1.5.10

- name: Push cwt-generator image to Quay.io
id: push-to-quay
Expand Down
9 changes: 7 additions & 2 deletions container_workflow_tool/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ def handle_dangling_symlinks(self, src_parent, dest_parent):
src_path_content = os.path.join(src_parent, dest_path_rel)
self.logger.debug(f"unlink {dest_file}")
os.unlink(dest_file)
src_full = os.path.join(os.path.dirname(src_path_content),
os.readlink(src_path_content))
# Catch exception in case of 'os.readlink(src_path_content)' does not exist.
try:
src_full = os.path.join(os.path.dirname(src_path_content),
os.readlink(src_path_content))
except FileNotFoundError:
self.logger.debug(f"Source file {src_path_content} does not exist.")
continue
if os.path.isdir(src_full):
# In this case, when the source directory includes another symlinks outside
# of this directory, those wouldn't be fixed, so let's run the same function
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_dir(system_path=None, virtual_path=None):

setup(
name='container-workflow-tool',
version="1.5.9",
version="1.5.10",
description='A python3 tool to make rebuilding images easier by automating several steps of the process.',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 61734a2

Please sign in to comment.