You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/09/18 15:46:26 UTC

(tooling-trusted-releases) branch sbp updated: Allow admins to toggle bypassing the vote process for presentations

This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/sbp by this push:
     new 4c8ff2b7 Allow admins to toggle bypassing the vote process for presentations
4c8ff2b7 is described below

commit 4c8ff2b7cc98ccf444d1f395eab254a4e4eff2b2
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Fri Sep 18 16:44:35 2026 +0100

    Allow admins to toggle bypassing the vote process for presentations
---
 atr/admin/__init__.py              | 36 +++++++++++++++++++-
 atr/config.py                      |  1 +
 atr/db/interaction.py              | 10 +++---
 atr/get/resolve.py                 |  2 ++
 atr/storage/__init__.py            |  1 +
 atr/storage/writers/vote.py        | 15 +++++++++
 tests/unit/test_vote_resolution.py | 69 ++++++++++++++++++++++++++++----------
 7 files changed, 111 insertions(+), 23 deletions(-)

diff --git a/atr/admin/__init__.py b/atr/admin/__init__.py
index 36ad891e..686fdad9 100644
--- a/atr/admin/__init__.py
+++ b/atr/admin/__init__.py
@@ -145,6 +145,7 @@ type BANNER_SET = Literal["BANNER_SET"]
 type BROWSE_AS = Literal["BROWSE_AS"]
 type CATALOG_SITE_REBUILD = Literal["CATALOG_SITE_REBUILD"]
 type LDAP = Literal["LDAP"]
+type PRESENTATIONS_VOTE_BYPASS = Literal["PRESENTATIONS_VOTE_BYPASS"]
 type PROJECTS_UPDATE = Literal["PROJECTS_UPDATE"]
 type REVOKE_ALL_TOKENS = Literal["REVOKE_ALL_TOKENS"]
 type REVOKE_SSH_KEYS = Literal["REVOKE_SSH_KEYS"]
@@ -204,6 +205,16 @@ class LdapLookupForm(form.Form):
     )
 
 
+class PresentationsVoteBypassForm(form.Form):
+    variant: PRESENTATIONS_VOTE_BYPASS = form.value(PRESENTATIONS_VOTE_BYPASS)
+    enabled: form.Bool = form.label(
+        "Allow presentations vote shortcuts",
+        "Allow release managers to resolve tooling-presentations votes early or without enough trusted votes. "
+        "Resets to off when the web application restarts or reloads.",
+        default=False,
+    )
+
+
 class ProjectsUpdateForm(form.Form):
     variant: PROJECTS_UPDATE = form.value(PROJECTS_UPDATE)
 
@@ -332,7 +343,9 @@ class TestRosterResetForm(form.Form):
 type CatalogForm = Annotated[ProjectsUpdateForm | CatalogSiteRebuildForm, form.DISCRIMINATOR]
 
 
-type SystemForm = Annotated[EditBannerForm | RestoreBannerForm | SendTestMessageForm, form.DISCRIMINATOR]
+type SystemForm = Annotated[
+    EditBannerForm | PresentationsVoteBypassForm | RestoreBannerForm | SendTestMessageForm, form.DISCRIMINATOR
+]
 
 
 type TestRosterForm = Annotated[TestRosterSetForm | TestRosterRemoveForm | TestRosterResetForm, form.DISCRIMINATOR]
@@ -1698,6 +1711,8 @@ async def system_post(
     match system_form:
         case EditBannerForm():
             return await _system_banner_set(session, system_form)
+        case PresentationsVoteBypassForm():
+            return await _system_presentations_vote_bypass(session, system_form)
         case RestoreBannerForm():
             return await _system_banner_restore(session, system_form)
         case SendTestMessageForm():
@@ -2738,6 +2753,15 @@ async def _system_configuration_tab() -> htm.Element:
     block = htm.Block()
     block.h2["Configuration"]
     block.pre[htm.code["\n".join(values)]]
+    block.h3(".mt-4")["Presentations vote shortcuts"]
+    block.append(
+        await form.render(
+            model_cls=PresentationsVoteBypassForm,
+            action=util.as_url(system_post, tab="configuration"),
+            submit_label="Save presentations setting",
+            defaults={"enabled": conf.PRESENTATIONS_VOTE_RESOLUTION_BYPASS},
+        )
+    )
     return block.collect()
 
 
@@ -2835,6 +2859,16 @@ async def _system_performance_tab() -> htm.Element:
     return htm.div[markupsafe.Markup(content)]
 
 
+async def _system_presentations_vote_bypass(
+    session: web.Committer, bypass_form: PresentationsVoteBypassForm
+) -> web.WerkzeugResponse:
+    async with storage.write(session) as write:
+        write.as_foundation_admin().vote.presentations_bypass_set(bypass_form.enabled)
+    state = "enabled" if bypass_form.enabled else "disabled"
+    await quart.flash(f"Presentations vote shortcuts are {state}.", "success")
+    return await session.redirect(system_get, tab="configuration")
+
+
 async def _system_tasks_tab(minutes: int) -> htm.Element:
     if minutes < 1:
         minutes = 1
diff --git a/atr/config.py b/atr/config.py
index 7b368928..2981a929 100644
--- a/atr/config.py
+++ b/atr/config.py
@@ -132,6 +132,7 @@ class AppConfig:
     LOG_JSON = _ENVIRONMENT_CONFIG("LOG_JSON", default=False, cast=bool)
     LOG_PUBLIC_KEY = _config_secrets("LOG_PUBLIC_KEY", STATE_DIR, default=None, cast=str)
     MAX_SESSION_AGE = _ENVIRONMENT_CONFIG("MAX_SESSION_AGE", default=60 * 60 * 72, cast=int)
+    PRESENTATIONS_VOTE_RESOLUTION_BYPASS: bool = False
     PUBSUB_URL = _config_secrets("PUBSUB_URL", STATE_DIR, default=None, cast=str)
     PUBSUB_USER = _config_secrets("PUBSUB_USER", STATE_DIR, default=None, cast=str)
     PUBSUB_PASSWORD = _config_secrets("PUBSUB_PASSWORD", STATE_DIR, default=None, cast=str)
diff --git a/atr/db/interaction.py b/atr/db/interaction.py
index c56d011e..1f6ef139 100644
--- a/atr/db/interaction.py
+++ b/atr/db/interaction.py
@@ -54,9 +54,6 @@ _ATR_DEV_VOTE_RESOLUTION_BYPASS_HOST: Final[str] = "tooling-vm-ec2-de.apache.org
 # audit_guidance required actor for ATR distribution workflows; must not be used for project TP workflows.
 _GITHUB_TRUSTED_ROLE_NID: Final[int] = 254436773
 _NO_EXPECTED_VOTE_ROUND: Final[object] = object()
-# The tooling-presentations bypass is inactive, pending us making this admin switchable with audit logging
-# _PRODUCTION_VOTE_RESOLUTION_BYPASS_PROJECT_KEYS: Final[frozenset[str]] = frozenset({"tooling-presentations"})
-_PRODUCTION_VOTE_RESOLUTION_BYPASS_PROJECT_KEYS: Final[frozenset[str]] = frozenset()
 _TOOLING_COMMITTEE_KEY: Final[str] = "tooling"
 
 
@@ -1214,10 +1211,13 @@ def vote_pass_fail_allowed(latest_vote_task: sql.Task | None) -> bool:
 
 
 def vote_resolution_bypass(release: sql.Release, asf_uid: str | None) -> bool:
-    app_host = config.get().APP_HOST.split(":", 1)[0]
+    conf = config.get()
+    app_host = conf.APP_HOST.split(":", 1)[0]
     if app_host == _ATR_DEV_VOTE_RESOLUTION_BYPASS_HOST:
         return user.is_admin(asf_uid) and (release.project.committee_key == _TOOLING_COMMITTEE_KEY)
-    return (not config.is_production_mode()) or (release.project_key in _PRODUCTION_VOTE_RESOLUTION_BYPASS_PROJECT_KEYS)
+    return (not config.is_production_mode()) or (
+        (release.project_key == "tooling-presentations") and conf.PRESENTATIONS_VOTE_RESOLUTION_BYPASS
+    )
 
 
 async def wait_for_task(
diff --git a/atr/get/resolve.py b/atr/get/resolve.py
index a1996f7f..27214230 100644
--- a/atr/get/resolve.py
+++ b/atr/get/resolve.py
@@ -359,6 +359,8 @@ async def selected(  # noqa: C901
                 f"The vote thread could not be tabulated, so {binding_label.lower()} vote requirements"
                 " could not be verified automatically."
             )
+        if bypass_active and is_trusted_mode:
+            message += " The vote resolution bypass allows this vote to be marked as passed anyway."
         pre_submit = htm.div(".border.rounded.bg-warning-subtle.p-3.mb-3")[icon, message]
 
     resolve_form = await atr.form.render(
diff --git a/atr/storage/__init__.py b/atr/storage/__init__.py
index 99516b20..6e479fa5 100644
--- a/atr/storage/__init__.py
+++ b/atr/storage/__init__.py
@@ -271,6 +271,7 @@ class WriteAsFoundationAdmin(WriteAsFoundationCommitter):
         self.release = writers.release.FoundationAdmin(write, self, data)
         self.ssh = writers.ssh.FoundationAdmin(write, self, data)
         self.tokens = writers.tokens.FoundationAdmin(write, self, data)
+        self.vote = writers.vote.FoundationAdmin(write, self, data)
 
 
 class WriteAsCommitteeAdmin(WriteAsCommitteeMember):
diff --git a/atr/storage/writers/vote.py b/atr/storage/writers/vote.py
index 3680ac32..913e4e5e 100644
--- a/atr/storage/writers/vote.py
+++ b/atr/storage/writers/vote.py
@@ -24,6 +24,7 @@ from typing import Literal
 import sqlalchemy
 import sqlmodel
 
+import atr.config as config
 import atr.construct as construct
 import atr.db as db
 import atr.db.interaction as interaction
@@ -211,6 +212,20 @@ class FoundationCommitter(GeneralPublic):
         return [email_to], ""
 
 
+class FoundationAdmin(FoundationCommitter):
+    def __init__(self, write: storage.Write, write_as: storage.WriteAsFoundationAdmin, data: db.Session):
+        super().__init__(write, write_as, data)
+        self.__write_as = write_as
+
+    def presentations_bypass_set(self, enabled: bool) -> None:
+        conf = config.get()
+        previous = conf.PRESENTATIONS_VOTE_RESOLUTION_BYPASS
+        if previous == enabled:
+            return
+        conf.PRESENTATIONS_VOTE_RESOLUTION_BYPASS = enabled
+        self.__write_as.append_to_audit_log(asf_uid=self.__write_as.asf_uid, previous=previous, enabled=enabled)
+
+
 class CommitteeParticipant(FoundationCommitter):
     def __init__(
         self,
diff --git a/tests/unit/test_vote_resolution.py b/tests/unit/test_vote_resolution.py
index 1875b79e..9115c542 100644
--- a/tests/unit/test_vote_resolution.py
+++ b/tests/unit/test_vote_resolution.py
@@ -593,6 +593,26 @@ async def test_podling_stale_round_one_cancel_after_pass() -> None:
     data.rollback.assert_awaited()
 
 
+def test_presentations_bypass_set_audits_only_changes(monkeypatch: pytest.MonkeyPatch) -> None:
+    conf = interaction.config.get()
+    assert conf.PRESENTATIONS_VOTE_RESOLUTION_BYPASS is False
+    monkeypatch.setattr(conf, "PRESENTATIONS_VOTE_RESOLUTION_BYPASS", False)
+    monkeypatch.setattr(storage.user, "is_admin", lambda _asf_uid: True)
+    audit = mock.Mock()
+    monkeypatch.setattr(storage, "audit", audit)
+    writer = storage.Write(SimpleNamespace(asf_uid="admin"), _mock_data()).as_foundation_admin().vote
+
+    writer.presentations_bypass_set(True)
+    assert conf.PRESENTATIONS_VOTE_RESOLUTION_BYPASS is True
+    writer.presentations_bypass_set(True)
+    writer.presentations_bypass_set(False)
+    assert conf.PRESENTATIONS_VOTE_RESOLUTION_BYPASS is False
+    assert audit.call_args_list == [
+        mock.call(asf_uid="admin", previous=False, enabled=True),
+        mock.call(asf_uid="admin", previous=True, enabled=False),
+    ]
+
+
 @pytest.mark.asyncio
 async def test_resolve_allows_cancelled_before_vote_end(monkeypatch: pytest.MonkeyPatch) -> None:
     """Writer allows Cancelled even before the end of the vote."""
@@ -624,7 +644,6 @@ async def test_resolve_allows_cancelled_before_vote_end(monkeypatch: pytest.Monk
     assert success == "Vote marked as cancelled"
 
 
-@pytest.mark.skip(reason="The production bypass is temporarily disabled")
 @pytest.mark.parametrize("vote_result", ["failed", "passed"])
 @pytest.mark.asyncio
 async def test_resolve_allows_early_result_for_production_bypass_project(
@@ -644,9 +663,13 @@ async def test_resolve_allows_early_result_for_production_bypass_project(
 
     future_task = _latest_vote_task_with_end(24)
     monkeypatch.setattr(interaction, "release_current_vote_task", mock.AsyncMock(return_value=future_task))
-    monkeypatch.setattr(interaction.config, "get", lambda: SimpleNamespace(APP_HOST="release-test.apache.org"))
+    monkeypatch.setattr(
+        interaction.config,
+        "get",
+        lambda: SimpleNamespace(APP_HOST="release-test.apache.org", PRESENTATIONS_VOTE_RESOLUTION_BYPASS=True),
+    )
     monkeypatch.setattr(interaction.config, "is_production_mode", lambda: True)
-    monkeypatch.setattr(interaction.user, "is_admin", lambda asf_uid: asf_uid == "chair")
+    monkeypatch.setattr(interaction.user, "is_admin", lambda _asf_uid: False)
 
     writer._ReleaseManager__resolve_release = mock.AsyncMock(
         return_value=(release, None, f"Vote marked as {vote_result}", None)
@@ -1082,7 +1105,6 @@ def test_trusted_email_context_labels_avoid_authoritative_terms() -> None:
     assert "Formal" not in {row.status_label for row in rows}
 
 
-@pytest.mark.skip(reason="The production bypass is temporarily disabled")
 @pytest.mark.asyncio
 async def test_trusted_resolve_allows_insufficient_votes_with_bypass(monkeypatch: pytest.MonkeyPatch) -> None:
     data = _mock_data()
@@ -1100,9 +1122,13 @@ async def test_trusted_resolve_allows_insufficient_votes_with_bypass(monkeypatch
     data.release = mock.MagicMock(return_value=query)
 
     monkeypatch.setattr(interaction, "release_current_vote_task", mock.AsyncMock(return_value=_latest_vote_task()))
-    monkeypatch.setattr(interaction.config, "get", lambda: SimpleNamespace(APP_HOST="release-test.apache.org"))
+    monkeypatch.setattr(
+        interaction.config,
+        "get",
+        lambda: SimpleNamespace(APP_HOST="release-test.apache.org", PRESENTATIONS_VOTE_RESOLUTION_BYPASS=True),
+    )
     monkeypatch.setattr(interaction.config, "is_production_mode", lambda: True)
-    monkeypatch.setattr(interaction.user, "is_admin", lambda asf_uid: asf_uid == "chair")
+    monkeypatch.setattr(interaction.user, "is_admin", lambda _asf_uid: False)
     monkeypatch.setattr(interaction, "ballots_for_resolution", mock.AsyncMock(return_value=[]))
     monkeypatch.setattr(
         interaction, "trusted_ballot_summary", mock.AsyncMock(return_value=interaction.TrustedVoteSummary())
@@ -1393,17 +1419,21 @@ def test_vote_pass_fail_allowed_returns_true_after_vote_end() -> None:
 
 
 @pytest.mark.parametrize(
-    ("app_host", "production_mode", "is_admin", "committee_key", "project_key", "expected"),
+    ("app_host", "production_mode", "is_admin", "committee_key", "project_key", "enabled", "expected"),
     [
-        ("tooling-vm-ec2-de.apache.org", True, True, "tooling", "tooling", True),
-        ("tooling-vm-ec2-de.apache.org:443", True, True, "tooling", "tooling-demo", True),
-        ("tooling-vm-ec2-de.apache.org", True, False, "tooling", "tooling", False),
-        ("tooling-vm-ec2-de.apache.org", True, True, "other", "tooling", False),
-        ("tooling-vm-ec2-de.apache.org", False, False, "tooling", "tooling", False),
-        ("release-test.apache.org", True, True, "tooling", "tooling", False),
-        ("release-test.apache.org", True, False, "tooling", "tooling-presentations", False),
-        ("127.0.0.1", False, False, "other", "project", True),
-        ("127.0.0.1", True, True, "tooling", "tooling", False),
+        ("tooling-vm-ec2-de.apache.org", True, True, "tooling", "tooling", False, True),
+        ("tooling-vm-ec2-de.apache.org:443", True, True, "tooling", "tooling-demo", False, True),
+        ("tooling-vm-ec2-de.apache.org", True, False, "tooling", "tooling", False, False),
+        ("tooling-vm-ec2-de.apache.org", True, True, "other", "tooling", False, False),
+        ("tooling-vm-ec2-de.apache.org", False, False, "tooling", "tooling", False, False),
+        ("tooling-vm-ec2-de.apache.org", True, False, "tooling", "tooling-presentations", True, False),
+        ("release-test.apache.org", True, True, "tooling", "tooling", False, False),
+        ("release-test.apache.org", True, False, "tooling", "tooling-presentations", False, False),
+        ("release-test.apache.org", True, False, "tooling", "tooling-presentations", True, True),
+        ("release-test.apache.org", True, True, "tooling", "tooling-presentations-other", True, False),
+        ("release-test.apache.org", True, True, "tooling", "tooling", True, False),
+        ("127.0.0.1", False, False, "other", "project", False, True),
+        ("127.0.0.1", True, True, "tooling", "tooling", False, False),
     ],
 )
 def test_vote_resolution_bypass(
@@ -1413,12 +1443,17 @@ def test_vote_resolution_bypass(
     is_admin: bool,
     committee_key: str,
     project_key: str,
+    enabled: bool,
     expected: bool,
 ) -> None:
     release = _candidate_release()
     release.project_key = project_key
     release.project.committee_key = committee_key
-    monkeypatch.setattr(interaction.config, "get", lambda: SimpleNamespace(APP_HOST=app_host))
+    monkeypatch.setattr(
+        interaction.config,
+        "get",
+        lambda: SimpleNamespace(APP_HOST=app_host, PRESENTATIONS_VOTE_RESOLUTION_BYPASS=enabled),
+    )
     monkeypatch.setattr(interaction.config, "is_production_mode", lambda: production_mode)
     monkeypatch.setattr(interaction.user, "is_admin", lambda _asf_uid: is_admin)
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org