Skip to content

[python] Handle platforms without getuid in ticket-cache lookup - #10827

Merged
JingsongLi merged 1 commit into
apache:masterfrom
skyyyy955:fix/kerberos-cache-linux-final-20261026
Oct 27, 2026
Merged

JingsongLi merged 1 commit into
apache:masterfrom
skyyyy955:fix/kerberos-cache-linux-final-20261026

Conversation

@skyyyy955

Copy link
Copy Markdown
Contributor

Purpose

When KRB5CCNAME is unset, get_ticket_cache_path() calls os.getuid() to construct the Unix default cache path. On platforms without that function, including Windows, HDFS initialization can fail with AttributeError even when no Kerberos credentials are configured.

Return None when os.getuid is unavailable, after checking the explicit cache setting. This lets callers handle an unavailable cache through their existing branches. Keep explicit cache precedence, FILE: prefix handling, the Unix file-existence check, and error propagation from an available getuid. Keytab login without a discoverable cache still raises RuntimeError.

Add five regression tests and make the existing Unix-path mock work on platforms without getuid. No public API, configuration, data format or dependency changes are required. This is a platform availability fix; it does not add Kerberos cache types or certify HDFS authentication on Windows. No feature documentation changes are needed.

The existing Kerberos implementation and tests came from ChengHui Chen's #7716, merged as 81bc068. The shared helper and native backend came from chaoyang's #8031, merged as b839753. This change adds the availability guard and portability tests on top of that merged code.

Tests

The same 35 cases were run before and after the production fix against 3f5e9fcf62548a9f5bd110d4729e091b705a19b4:

Platform Python / PyArrow Without the production guard With the fix
Windows 3.10.11 / 19.0.1 27 passed, 8 failed 35 passed
Linux 3.6.15 / 6.0.1 33 passed, 2 failed 35 passed
Linux 3.7.17 / 12.0.1 33 passed, 2 failed 35 passed
Linux 3.10.22 / 19.0.1 33 passed, 2 failed 35 passed

There were no skipped tests or introduced failures. The two Linux failures without the guard simulate an unavailable getuid; the other 33 cases continue to pass. All environments use the same test IDs and unchanged source inputs. From paimon-python, the selection is:

python -B -m pytest -q -p no:cacheprovider \
  pypaimon/tests/kerberos_test.py \
  pypaimon/tests/file_io_test.py::HdfsFileIOTest \
  pypaimon/tests/file_io_test.py::FileIOTest::test_write_file_with_overwrite_flag \
  pypaimon/tests/file_io_test.py::FileIOTest::test_copy_file \
  pypaimon/tests/file_io_test.py::FileIOTest::test_try_to_write_atomic \
  pypaimon/tests/file_io_test.py::FileIOTest::test_rename_returns_false_when_dst_exists \
  pypaimon/tests/file_io_test.py::FileIOTest::test_get_file_status_raises_error_when_file_not_exists \
  pypaimon/tests/file_io_test.py::FileIOTest::test_local_directory_listing_propagates_permission_errors

Changed-file flake8, the project license-header check and Python 3.6 grammar checks passed. An additional probe using the real Windows os module covered cache lookup, the public FileIO.get entry and both backend wrappers' missing-cache errors after keytab login.

HDFS clients and kinit are mocked in these tests; local file operations use real temporary files. Native backend coverage is limited to the Python wrapper. Real KDC/HDFS authentication, HDFS cluster read/write and full upstream CI have not been run for this candidate; the available HDFS endpoint was unreachable.

@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi
JingsongLi merged commit 05b0656 into apache:master Oct 27, 2026
21 checks passed
@skyyyy955
skyyyy955 deleted the fix/kerberos-cache-linux-final-20261026 branch October 27, 2026 11:16
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