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

Fix for 'src_path_content' in upstream does not exist #85

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

phracek
Copy link
Member

@phracek phracek commented Nov 11, 2024

Fix for 'src_path_content' in upstream does not exist
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'

@phracek phracek requested a review from pkubatrh November 11, 2024 08:42
@phracek
Copy link
Member Author

phracek commented Nov 11, 2024

/test

Copy link

github-actions bot commented Nov 11, 2024

Testing Farm results

namecomposearchstatusstarted (UTC)timelogs
FedoraFedora-latestx86_64✅ passed12.11.2024 15:18:239min 1stest pipeline

@phracek phracek force-pushed the fix_traceback_missing_source branch from 61734a2 to d10e639 Compare November 11, 2024 09:00
@phracek
Copy link
Member Author

phracek commented Nov 11, 2024

/test

@phracek phracek force-pushed the fix_traceback_missing_source branch from d10e639 to 01b6533 Compare November 11, 2024 11:31
@pkubatrh
Copy link
Member

pkubatrh commented Nov 11, 2024

Code change looks fine to me.
I would appreciate seeing better documentation of the specific use case this is fixing in commit message and comment/debug message inside the code.
Specifically that the corner case we hit here happens when a symlink is removed in upstream repository but is still present in downstream repository. CWT then finds the existing downstream symlink, tries to look for it upstream and fails to do so. The fix here is ignoring the failure as we have already unlinked the symlink in preparation for the eventual copy.

The downstream file is properly deleted by `os.unlink` code, it is still present.
But the code that is now in Exception fixes the problem,
because upstream file is not present and 'os.readlink(src_path_content)'
failed with traceback FileNotFoundError.

The traceback is mentioned below in the commit message.

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 <phracek@redhat.com>
Update also debug log message, why the file does not exist

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
@phracek phracek force-pushed the fix_traceback_missing_source branch from 01b6533 to 92964fd Compare November 12, 2024 08:48
@phracek
Copy link
Member Author

phracek commented Nov 12, 2024

Code change looks fine to me.
I would appreciate seeing better documentation of the specific use case this is fixing in commit message and comment/debug message inside the code.
Specifically that the corner case we hit here happens when a symlink is removed in upstream repository but is still present in downstream repository. CWT then finds the existing downstream symlink, tries to look for it upstream and fails to do so. The fix here is ignoring the failure as we have already unlinked the symlink in preparation for the eventual copy.

@pkubatrh I have updated as code as a commit message with a detailed description.
Thanks for the review.

@phracek
Copy link
Member Author

phracek commented Nov 12, 2024

/test

@phracek phracek merged commit 4287e31 into master Nov 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants