[TECH DEBT] Encapsulate the sign-in state in AsyncAuth

オープン
#70,712 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@charzl がすでに取り組んでいます。

2026年11月6日 から。

評価

この issue はまだ評価されていません。

説明

tech-debt
Description of the tech debt to be addressed, include links and screenshots

The sign-in state in salt.crypt.AsyncAuth is spread over several places:

  • _authenticate_future is created in authenticate() and __singleton_init__, written by _authenticate(), read by authenticated and authenticate(), and deleted by invalidate(). It does not exist before the first sign-in, so every reader checks hasattr.
  • With #70603 it holds a task instead of a future, and the number of waiters lives in a second attribute, _authenticate_waiters.

This is hard to follow, and it is what #70642 had to untangle: a cancelled shared future, a result set twice, and authenticated raising CancelledError.

Only salt/crypt.py touches the attribute. The rest of the code uses authenticate(), authenticated and invalidate().

Proposed change

Keep the public API. Hold the current sign-in in one small object: the task and its waiter count, with the join, leave and cancel logic inside it. AsyncAuth keeps one attribute that is None until the first sign-in, and authenticated is derived from that object.

Steps, one commit each:

  1. Add tests that pin the current behavior: one cancelled caller does not cancel the others, an error reaches every caller, authenticated is false after a cancelled sign-in, the last caller leaving cancels the sign-in, and invalidate() makes the next call sign in again.
  2. Move the waiter counting and cleanup into the new object.
  3. Replace the uses of _authenticate_future.
  4. Remove the hasattr checks, the del, and _authenticate_waiters.

This should land after #70603, which already gives each caller its own waiter.

Out of scope: invalidate() clearing the shared creds_map, and removing the AsyncAuth singleton.

Related: #70642, #70603, #70366, #70714.

Versions Report

No user-visible change. Targets the master branch.

主要言語
Python
スター
15.8k
フォーク
5.6k
平均マージ
5日 9時間
マージ済み PR(30日)
99

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

saltstack/salt のほかの issue

saltstack/salt の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。