Skip to content

Add argument --iam-token-file in ydb-dstool #20303

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

kruall
Copy link
Collaborator

@kruall kruall commented Jun 27, 2025

Changelog entry

Add --iam-token-file argument to ydb-dstool

Changelog category

  • New feature

Description for reviewers

For IAM token need to add "Bearer " in begining of the token if use --token-file.
Added new argument --iam-token-file which will do it insead of user

@kruall kruall requested review from alexvru and Copilot June 27, 2025 13:13
@kruall kruall self-assigned this Jun 27, 2025
@kruall kruall added the area/blobstorage BlobStorage issues label Jun 27, 2025
Copilot

This comment was marked as outdated.

Copy link

github-actions bot commented Jun 27, 2025

2025-06-27 13:14:42 UTC Pre-commit check linux-x86_64-relwithdebinfo for 46e261f has started.
2025-06-27 13:14:54 UTC Artifacts will be uploaded here
2025-06-27 13:17:22 UTC ya make is running...
🟢 2025-06-27 13:18:04 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
45 45 0 0 0 0

🟢 2025-06-27 13:18:11 UTC Build successful.

Copy link

🟢 2025-06-27 13:15:59 UTC The validation of the Pull Request description is successful.

Copy link

github-actions bot commented Jun 27, 2025

2025-06-27 13:21:38 UTC Pre-commit check linux-x86_64-release-asan for 46e261f has started.
2025-06-27 13:22:06 UTC Artifacts will be uploaded here
2025-06-27 13:25:24 UTC ya make is running...
🟢 2025-06-27 13:26:17 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
43 43 0 0 0 0

🟢 2025-06-27 13:26:24 UTC Build successful.

@kruall kruall requested a review from Copilot June 27, 2025 13:35
Copilot

This comment was marked as outdated.

Copy link

github-actions bot commented Jun 27, 2025

2025-06-27 13:36:11 UTC Pre-commit check linux-x86_64-relwithdebinfo for 95a496b has started.
2025-06-27 13:36:19 UTC Artifacts will be uploaded here
2025-06-27 13:37:32 UTC Check cancelled

@kruall kruall requested a review from Copilot June 27, 2025 13:37
Copilot

This comment was marked as outdated.

@kruall kruall force-pushed the dstool/add_iam_token_file branch from 81c853c to 680decc Compare June 27, 2025 13:38
@kruall kruall requested a review from Copilot June 27, 2025 13:39
Copilot

This comment was marked as outdated.

Copy link

github-actions bot commented Jun 27, 2025

2025-06-27 13:51:36 UTC Pre-commit check linux-x86_64-release-asan for 829bec1 has started.
2025-06-27 13:51:47 UTC Artifacts will be uploaded here
2025-06-27 13:54:12 UTC ya make is running...
🟢 2025-06-27 13:54:53 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
43 43 0 0 0 0

🟢 2025-06-27 13:55:00 UTC Build successful.

Copy link

github-actions bot commented Jun 27, 2025

2025-06-27 13:55:47 UTC Pre-commit check linux-x86_64-relwithdebinfo for 829bec1 has started.
2025-06-27 13:55:59 UTC Artifacts will be uploaded here
2025-06-27 13:58:28 UTC ya make is running...
2025-06-27 13:59:21 UTC Check cancelled

@kruall kruall requested a review from Copilot June 27, 2025 13:59
Copilot

This comment was marked as outdated.

@kruall kruall requested a review from Copilot June 27, 2025 14:10
Copy link

github-actions bot commented Jun 27, 2025

2025-06-27 14:11:16 UTC Pre-commit check linux-x86_64-relwithdebinfo for 51491f4 has started.
2025-06-27 14:11:27 UTC Artifacts will be uploaded here
2025-06-27 14:13:54 UTC ya make is running...
🟢 2025-06-27 14:14:35 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
45 45 0 0 0 0

🟢 2025-06-27 14:14:42 UTC Build successful.

Copilot

This comment was marked as outdated.

Copy link

github-actions bot commented Jun 27, 2025

2025-06-27 14:11:39 UTC Pre-commit check linux-x86_64-release-asan for 51491f4 has started.
2025-06-27 14:12:16 UTC Artifacts will be uploaded here
2025-06-27 14:15:03 UTC ya make is running...
🟢 2025-06-27 14:15:59 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
43 43 0 0 0 0

🟢 2025-06-27 14:16:06 UTC Build successful.

Copy link

github-actions bot commented Jun 27, 2025

2025-06-27 14:43:00 UTC Pre-commit check linux-x86_64-relwithdebinfo for e40bb3e has started.
2025-06-27 14:43:11 UTC Artifacts will be uploaded here
2025-06-27 14:45:44 UTC ya make is running...
🟢 2025-06-27 14:46:21 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
45 45 0 0 0 0

🟢 2025-06-27 14:46:28 UTC Build successful.

Copy link

github-actions bot commented Jun 27, 2025

2025-06-27 14:43:04 UTC Pre-commit check linux-x86_64-release-asan for e40bb3e has started.
2025-06-27 14:43:39 UTC Artifacts will be uploaded here
2025-06-27 14:46:41 UTC ya make is running...
🟢 2025-06-27 14:47:18 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
43 43 0 0 0 0

🟢 2025-06-27 14:47:24 UTC Build successful.

@kruall kruall requested a review from Copilot June 27, 2025 14:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for an --iam-token-file CLI argument in ydb-dstool, automatically handling “Bearer” prefixing and fallback to IAM environment variables or default files.

  • Extend parse_token to accept iam_token_file, handle IAM_TOKEN env var, and default IAM token path.
  • Introduce helper methods read_token_from_file, read_token_file, and parse_token_value.
  • Update add_host_access_options to use a mutually exclusive group for --token-file and --iam-token-file.
Comments suppressed due to low confidence (2)

ydb/apps/dstool/lib/common.py:234

  • New IAM token handling logic should be covered by unit tests to verify behavior for --iam-token-file, IAM_TOKEN env var, and default file fallbacks.
        self.parse_token(args.token_file, args.iam_token_file)

ydb/apps/dstool/lib/common.py:195

  • The helper read_token_from_file_and_close is not defined, leading to a NameError. Consider using a context manager (e.g., with open(...) as f:) combined with read_token_from_file, or implement the missing function.
            return self.read_token_from_file_and_close(open(token_file_path, 'r'), default_token_type)

return default_token_type, None
try:
return self.read_token_from_file_and_close(open(token_file_path, 'r'), default_token_type)
except Exception:
Copy link
Preview

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid a bare except Exception: which can mask unrelated errors; catch specific file I/O exceptions like FileNotFoundError or OSError instead.

Suggested change
except Exception:
except (FileNotFoundError, OSError):

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants