Skip to content

Handle leading slash in samba path#18847

Merged
potiuk merged 1 commit into
apache:mainfrom
Opus-Interactive:sambaHandleLeadingSlashInPath
Oct 9, 2021
Merged

Handle leading slash in samba path#18847
potiuk merged 1 commit into
apache:mainfrom
Opus-Interactive:sambaHandleLeadingSlashInPath

Conversation

@fredthomsen

Copy link
Copy Markdown
Contributor

Fix issue that occurs when the path to a file on a samba share has a
slash prepended to it, then the SambaHook will treat the path as the
host instead likely resulting trying to connect to the wrong samba host.

For example, this code:

hook = SambaHook('samba_test')
hook.push_from_local(
    "/Sales/TestData/sometestfile.txt",
    "/tmp/somefile",
)

resulted in:

airflow/providers/samba/hooks/samba.py:246: in push_from_local
    with open(local_filepath, "rb") as f, self.open_file(destination_filepath, mode="wb") as g:
airflow/providers/samba/hooks/samba.py:135: in open_file
    **self._conn_kwargs,
/usr/local/lib/python3.6/site-packages/smbclient/_os.py:370: in open_file
    file_attributes=file_attributes, **kwargs)
/usr/local/lib/python3.6/site-packages/smbclient/_io.py:374: in __init__
    tree, fd_path = get_smb_tree(path, **kwargs)
/usr/local/lib/python3.6/site-packages/smbclient/_pool.py:301: in get_smb_tree
    auth_protocol=auth_protocol)
/usr/local/lib/python3.6/site-packages/smbclient/_pool.py:358: in register_session
    connection.connect(timeout=connection_timeout)
/usr/local/lib/python3.6/site-packages/smbprotocol/connection.py:719: in connect
    self.transport.connect()
/usr/local/lib/python3.6/site-packages/smbprotocol/transport.py:74: ValueError

ValueError: Failed to connect to 'Sales:445': [Errno -2] Name or service not known

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

Comment thread airflow/providers/samba/hooks/samba.py Outdated
Fix issue that occurs when the path to a file on a samba share has a
slash prepended to it, then the `SambaHook` will treat the path as the
host instead likely resulting trying to connect to the wrong samba host.
@fredthomsen
fredthomsen force-pushed the sambaHandleLeadingSlashInPath branch from 56e0e62 to e37872c Compare October 9, 2021 11:53
@github-actions

github-actions Bot commented Oct 9, 2021

Copy link
Copy Markdown
Contributor

The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions Bot added the okay to merge It's ok to merge this PR as it does not require more tests label Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers okay to merge It's ok to merge this PR as it does not require more tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants